---
title: Charmhub | prometheus_scrape interface
description: Interfaces describe the relation between two charms. This interface shows
  opinionated, standardized interface specifications for charm relations.
url: https://charmhub.io/integrations/prometheus_scrape
---

# prometheus\_scrape

## Usage

This relation interface describes the expected behavior of any charm claiming to be able to provide or require Prometheus Scrape Endpoints.

In most cases, this will be accomplished using the [prometheus\_scrape library](https://charmhub.io/prometheus-k8s/libraries/prometheus_scrape), although charm developers are free to provide alternative libraries as long as they fulfill the behavioral and schematic requirements described in this document.

## Direction

```
flowchart TD
    Provider -- "Scrape Job(s), Alert Rules, Metadata" --> Requirer
    Requirer -- Scrapes --> Provider
```

As all Juju relations, the `prometheus_scrape` interface consists of a provider and a requirer. One of these, in this case the `Provider`, will be expected to stand up one or more scrape compatible metrics endpoint where the `Requirer` will be able to scrape the `Provider`s metrics.

## Behavior

Both the Requirer and the provider need to adhere to a certain set of criterias to be considered compatible with the interface.

### Provider

* Is expected to provide one or more Prometheus scrape jobs in the relation data bag.
* Is expected to respect the metrics topology set by the requirer.
* Is expected to provide alert rules over the relation data bag.
* Is expected to add any wanted topology labels to all metrics sent to the provider.
* Is expected to provide any wanted topology label matchers as labels on every alert rule in the relation data bag.
* Is expected to be able to expose both single alert rules and alert rule groups over the relation data bag.
* Is expected to send alert rules where the contain expressions lacks Juju topology label selectors.

### Requirer

* Is expected to be able to scrape Prometheus metrics from a metrics endpoint
* Is expected to be able to ingest alert rules exposed over the relation data bag.
* Is expected to fetch the target configuration from the relation data bag.
* Is expected to inject alert rule topology labels as label matchers in alert rule expressions.
* Is expected not to inject juju\_unit as a label matcher by default, but to honor it if hard-coded by the user.
* Is expected to be able to ingest both single alert rules and alert rule groups provided over the relation data bag.

## Relation Data

[[Pydantic Schema]](https://github.com/canonical/charmlibs/blob/main/interfaces/prometheus_scrape/interface/vv0/schema.py)

### Provider

* Exposes all scrape jobs the requirer should scrape metrics through. Should be placed in the **application** databag.
* Exposes the unit address of each unit to be scraped, along with the unit name. Additionally, it includes an optional path provided by the unit for Prometheus scraping. This path is present when the provider charm is backed by an Ingress or a Proxy. Should be placed in the **unit** databag of each scrapable unit.

#### Example

```
application-data:
  alert_rules: '{
    "groups": [
      {
        "name": "an_alert_rule_group",
        "rules": [
          {
            "alert": "SomethingIsUp",
            "expr": "something_bad == 1",
            "for": "0m",
            "labels": {
              "some-label": "some-value"
            },
            "annotations": {
              "some-annotation": "some-other-value"
            }
          }
        ]
      }
    ]
  }'
  scrape_jobs: '[
    {
      "metrics_path": "/metrics",
      "static_configs": [
        { "targets": ["*:4080"] }
      ]
    }
  ]'
  scrape_metadata: '{
    "model": "cos",
    "model_uuid": "c2e9f4d5-dcb3-4870-8509-330eb9745ee8",
    "application": "zinc-k8s",
    "unit": "zinc-k8s/0",
    "charm_name": "zinc-k8s"
  }'
related-units:
  zinc-k8s/0:
    data:
      prometheus_scrape_unit_address: zinc-k8s-0.zinc-k8s-endpoints.cos.svc.cluster.local
      prometheus_scrape_unit_name: zinc-k8s/0
      prometheus_scrape_unit_path: ""
```

### Requirer

No relation data should be exposed by the requirer of this relation.

## Charms implementing this interface

### Providers

* [prometheus-k8s](https://charmhub.io/prometheus-k8s)
* [loki-k8s](https://charmhub.io/loki-k8s)
* [grafana-k8s](https://charmhub.io/grafana-k8s)
* [prometheus-scrape-config-k8s](https://charmhub.io/prometheus-scrape-config-k8s)
* [prometheus-scrape-target-k8s](https://charmhub.io/prometheus-scrape-target-k8s)
* [alertmanager-k8s](https://charmhub.io/alertmanager-k8s)
* [zinc-k8s](https://charmhub.io/zinc-k8s)

### Requirers

* [prometheus-k8s](https://charmhub.io/prometheus-k8s)
* [grafana-agent-k8s](https://charmhub.io/grafana-agent-k8s)

## Other charms using this interface

### Providers

* [kafka-k8s](https://charmhub.io/kafka-k8s)
* [mongodb-k8s](https://charmhub.io/mongodb-k8s)
* [traefik-k8s](https://charmhub.io/traefik-k8s)
* [mysql-k8s](https://charmhub.io/mysql-k8s)
* [vault-k8s](https://charmhub.io/vault-k8s)
* [parca-k8s](https://charmhub.io/parca-k8s)
* [mysql-router-k8s](https://charmhub.io/mysql-router-k8s)
* [prometheus-k8s](https://charmhub.io/prometheus-k8s)
* [pgbouncer-k8s](https://charmhub.io/pgbouncer-k8s)
* [grafana-k8s](https://charmhub.io/grafana-k8s)
* [lxd](https://charmhub.io/lxd)
* [postgresql-k8s](https://charmhub.io/postgresql-k8s)
* [mattermost-k8s](https://charmhub.io/mattermost-k8s)
* [discourse-k8s](https://charmhub.io/discourse-k8s)
* [loki-k8s](https://charmhub.io/loki-k8s)
* [zookeeper-k8s](https://charmhub.io/zookeeper-k8s)
* [alertmanager-k8s](https://charmhub.io/alertmanager-k8s)
* [openfga-k8s](https://charmhub.io/openfga-k8s)
* [indico](https://charmhub.io/indico)
* [trino-k8s](https://charmhub.io/trino-k8s)
* [kratos](https://charmhub.io/kratos)
* [spark-history-server-k8s](https://charmhub.io/spark-history-server-k8s)
* [istio-pilot](https://charmhub.io/istio-pilot)
* [kubeflow-profiles](https://charmhub.io/kubeflow-profiles)
* [wordpress-k8s](https://charmhub.io/wordpress-k8s)
* [kfp-api](https://charmhub.io/kfp-api)
* [temporal-k8s](https://charmhub.io/temporal-k8s)
* [ceph-mon](https://charmhub.io/ceph-mon)
* [minio](https://charmhub.io/minio)
* [kubeflow-dashboard](https://charmhub.io/kubeflow-dashboard)
* [istio-k8s](https://charmhub.io/istio-k8s)
* [istio-ingress-k8s](https://charmhub.io/istio-ingress-k8s)
* [hydra](https://charmhub.io/hydra)
* [prometheus-scrape-target-k8s](https://charmhub.io/prometheus-scrape-target-k8s)
* [argo-controller](https://charmhub.io/argo-controller)
* [superset-k8s](https://charmhub.io/superset-k8s)
* [juju-jimm-k8s](https://charmhub.io/juju-jimm-k8s)
* [identity-platform-login-ui-operator](https://charmhub.io/identity-platform-login-ui-operator)
* [mimir-coordinator-k8s](https://charmhub.io/mimir-coordinator-k8s)
* [datahub-k8s](https://charmhub.io/datahub-k8s)
* [blackbox-exporter-k8s](https://charmhub.io/blackbox-exporter-k8s)
* [tempo-coordinator-k8s](https://charmhub.io/tempo-coordinator-k8s)
* [istio-beacon-k8s](https://charmhub.io/istio-beacon-k8s)
* [dex-auth](https://charmhub.io/dex-auth)
* [bingo](https://charmhub.io/bingo)
* [netbox-k8s](https://charmhub.io/netbox-k8s)
* [jupyter-controller](https://charmhub.io/jupyter-controller)
* [loki-coordinator-k8s](https://charmhub.io/loki-coordinator-k8s)
* [temporal-worker-k8s](https://charmhub.io/temporal-worker-k8s)
* [content-cache-k8s](https://charmhub.io/content-cache-k8s)
* [ranger-k8s](https://charmhub.io/ranger-k8s)
* [httprequest-lego-provider](https://charmhub.io/httprequest-lego-provider)
* [katib-controller](https://charmhub.io/katib-controller)
* [mlflow-server](https://charmhub.io/mlflow-server)
* [kyuubi-k8s](https://charmhub.io/kyuubi-k8s)
* [istio-gateway](https://charmhub.io/istio-gateway)
* [canonical-livepatch-server-k8s](https://charmhub.io/canonical-livepatch-server-k8s)
* [glauth-k8s](https://charmhub.io/glauth-k8s)
* [cos-configuration-k8s](https://charmhub.io/cos-configuration-k8s)

### Requirers

* [prometheus-k8s](https://charmhub.io/prometheus-k8s)
* [grafana-agent-k8s](https://charmhub.io/grafana-agent-k8s)
* [opentelemetry-collector-k8s](https://charmhub.io/opentelemetry-collector-k8s)
* [opentelemetry-collector](https://charmhub.io/opentelemetry-collector)
