Loki

  • By Canonical Observability
Channel Revision Published Runs on
latest/stable 124 10 Apr 2024
Ubuntu 20.04
latest/candidate 128 10 Apr 2024
Ubuntu 20.04
latest/beta 129 10 Apr 2024
Ubuntu 20.04
latest/edge 133 18 Apr 2024
Ubuntu 20.04
1.0/stable 104 12 Dec 2023
Ubuntu 20.04
1.0/candidate 104 22 Nov 2023
Ubuntu 20.04
1.0/beta 104 22 Nov 2023
Ubuntu 20.04
1.0/edge 104 22 Nov 2023
Ubuntu 20.04
juju deploy loki-k8s
Show information

Platform:

Juju topology labels are telemetry labels that are used for identifying the origin of metrics and logs in juju models. In other words, the Juju topology labels are a fingerprint of a unit in some juju model that is emitting telemetry. Especially when you have hundreds, thousands of nodes, it is essential to be able to locate that one unit that has been emitting alerts. For this reason, Juju topology labels play a key role in the Canonical observability stack (COS).

See also: Model-driven observability: the magic of Juju topology for metrics

This is what the Juju topology labels look like:

        labels:
          model: "some-juju-model"
          model_uuid: "00000000-0000-0000-0000-000000000001"
          application: "fancy-juju-application"
          unit: "fancy-juju-application/0"
          charm_name: "fancy-juju-application-k8s"

The COS charm libraries wrapping the observability relation endpoints inject these labels into any outgoing metric, log, trace, and dashboard, so that the charm using them doesn’t have to be aware of this at all. Any charm can ship with dashboards and (alert) rules and integrations with COS to monitor its lifecycle. These are the so-called “built-in” dashboards and rules. These are workload-specific. As the charm is deployed and related to COS, the charm libraries mediating said integration automatically inject the juju topology labels in all built-in dashboards and rules.

The following sections outline what this means in practice, and which juju-topology-related modifications are applied to the built-in rules and dashboards.

Dashboards

Depending on whether the charm where the dashboards reside is related directly to grafana-k8s, or whether the data flows through grafana-agent or cos-proxy, there are subtle differences in how the topology is injected.

Charms relating directly to grafana-k8s

Built-in dashboards are enriched with topology drop-downs. This allows filtering dashboard data by topology labels. You can opt out of this behaviour by calling a ._reinitialize_dashboard_data(inject_dropdowns=False) method on the GrafanaDashboardProvider relation wrapper object.

Charms relating through cos-configuration

Incidental dashboards coming in from a git-repo via the cos-configuration charm are left intact.

Charms relating through grafana-agent (-k8s or not)

When dashboards are forwarded through a grafana-agent intermediary, the juju topology labels of the charm of origin are injected (and not grafana-agent’s). Any subsequent chaining to additional grafana agent charms would leave the labels intact.

Charms relating through cos-proxy

TODO: what happens to dashboards via cos-proxy

Alert rules

For built-in alert rules,

  • Alert exprs are qualified with topology labels. This way, built-in alerts fire only for that particular unit
  • Alert labels are enriched with topology labels. This is meant for convenient reading of a rendered alert when presented to an on-caller. The labels would also be visible in the alert’s rendered expr, but alert labels are more convenient to read.
  • Alert rules are NOT enriched with the unit label, because alert rules are forwarded to prometheus/loki per related app, not unit. I.e. having multiple units does not result in prometheus having duplicated alerts per unit. If an alert was qualified with a unit (which one?), we wouldn’t get alerts from any other units.

Charms relating through cos-configuration

Incidental rule files coming in from a git-repo via the cos-configuration charm are left intact.

Charms relating through grafana-agent (-k8s or not)

When rule files are forwarded via grafana-agent, then they are enriched with juju topology labels of the relating charm (not grafana agent’s topology). Any subsequent chaining to additional grafana agent charms would leave the labels intact.

Charms relating through cos-proxy

TODO: what happens to rule files via cos-proxy

Logs

K8s charms can stream logs to loki using the charm lib. Behind the scenes this is accomplished using promtail, and log streams are enriched with juju topology labels.

Charms relating through grafana-agent (-k8s or not)

TODO: what happens to logs via grafana agent

Charms relating through cos-proxy

TODO: what happens to logs via cos-proxy

Additional notes

  • In the future, the grafana-agent charm may start exposing metrics and logs generated by its own workload, and those would be enriched by juju topology labels.
  • In the future, the cos-configuration charm may start exposing metrics and logs generated by its own workload, git-sync, and those would be enriched by juju topology labels.