Skip to content

k8s import: hand an AlertmanagerConfig's route and receivers to the prometheus lexicon #5113

Closed

Description

@lex00

chant import of a Prometheus Operator AlertmanagerConfig (monitoring.coreos.com/v1alpha1) writes the whole spec as an untyped object on the k8s class. The prometheus lexicon has typed Route and Receiver declarations, and the k8s import already hands a PrometheusRule's spec.groups, an alertmanager.yml in a ConfigMap and several Grafana Operator kinds to their owning lexicons. AlertmanagerConfig is not on that list, so its routing tree gets no typed source and none of the prometheus lexicon's checks. On kubernetes/k8s.io there are two, in kubernetes/gke-utility/monitoring/alerts.yaml and kubernetes/eks-prow-build/monitoring/alerts.yaml, each routing to Slack.

Today

  • lexicons/k8s/src/import/embedded.ts lists the places it offers to other lexicons: ConfigMap data values, PrometheusRule spec.groups, OpenTelemetryCollector spec.config, GrafanaDashboard spec.json and the Grafana alerting kinds. AlertmanagerConfig is not one of them.
  • lexicons/prometheus/src/alertmanager.ts exports Route and Receiver. The prometheus lexicon registers an Alertmanager importer through embeddedImporters() in lexicons/prometheus/src/plugin.ts.
  • The CRD is in the k8s CRD sources (lexicons/k8s/src/crd/crd-sources.ts), and WK8703 checks that an Alertmanager selects each AlertmanagerConfig.

Wanted

  • The k8s import offers an AlertmanagerConfig's spec.route, spec.receivers, spec.inhibitRules and spec.muteTimeIntervals to the prometheus lexicon, with the whole spec as the document, as it does for the Grafana alerting kinds.
  • The prometheus side converts the CRD's field names (groupBy, slackConfigs, matchers as objects with matchType) to its Route and Receiver props, and back on build, so the built AlertmanagerConfig equals the input. A field it does not convert stays in the k8s object and is named in a warning.
  • A Secret reference in a receiver (apiURL: { name, key }) stays a reference and is never read.
  • Round-trip test over a fixture with a Slack receiver, a nested route and one matcher of each matchType.

Not in this

Alertmanager's own alertmanager.yml import, which exists. The YAML quoting of matchType: =, which #5074 covers.

Found while reading kubernetes/k8s.io offline, for #5067. Tracked on #5105.

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic:estate-read

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions