Prometheus scrape target
- Canonical Observability
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 34 | 10 Apr 2024 | |
latest/candidate | 34 | 26 Mar 2024 | |
latest/beta | 34 | 12 Mar 2024 | |
latest/edge | 34 | 29 Feb 2024 | |
1.0/stable | 31 | 12 Dec 2023 | |
1.0/candidate | 31 | 22 Nov 2023 | |
1.0/beta | 31 | 22 Nov 2023 | |
1.0/edge | 31 | 22 Nov 2023 |
juju deploy prometheus-scrape-target-k8s
Deploy universal operators easily with Juju, the Universal Operator Lifecycle Manager.
Platform:
Usage
Installation
Since this Charmed Operator is an auxiliary charm for Prometheus, you need to deploy both charms and relate them.
juju deploy prometheus-k8s
juju deploy prometheus-scrape-target-k8s
juju relate prometheus-k8s prometheus-scrape-target-k8s
Once both charms are deployed and related you can check this situation by running:
juju status --relations --color
Model Controller Cloud/Region Version SLA Timestamp
cos charm-dev microk8s/localhost 2.9.32 unsupported 12:07:32-03:00
App Version Status Scale Charm Channel Rev Address Exposed Message
prometheus-k8s 2.33.5 active 1 prometheus-k8s edge 55 10.152.183.199 no
prometheus-scrape-target-k8s active 1 prometheus-scrape-target-k8s edge 19 10.152.183.207 no
Unit Workload Agent Address Ports Message
prometheus-k8s/0* active idle 10.1.157.94
prometheus-scrape-target-k8s/0* active idle 10.1.157.98
Relation provider Requirer Interface Type Message
prometheus-k8s:prometheus-peers prometheus-k8s:prometheus-peers prometheus_peers peer
prometheus-scrape-target-k8s:metrics-endpoint prometheus-k8s:metrics-endpoint prometheus_scrape regular
Adding targets and labels
Now it is time to add a new scrape target to Prometheus that is outside any Juju model by running:
juju config prometheus-scrape-target-k8s targets=192.168.5.2:7000
After running this command you can verify that the new target is added to Prometheus by running:
juju ssh --container prometheus prometheus-k8s/0 \
cat /etc/prometheus/prometheus.yml | grep -B1 -A3 "external_jobs
- honor_labels: true
job_name: juju_cos_bf6a531_prometheus-scrape-target-k8s_external_jobs
static_configs:
- targets:
- 192.168.5.2:7000
But this new target is not labeled, to add labels to it:
juju config prometheus-scrape-target-k8s labels=label1:LABEL1,label2:LABEL2
You can verify that the new labels are added to Prometheus by running:
juju ssh --container prometheus prometheus-k8s/0 \
cat /etc/prometheus/prometheus.yml | grep -B1 -A6 "external_jobs
- honor_labels: true
job_name: juju_cos_bf6a531_prometheus-scrape-target-k8s_external_jobs
static_configs:
- labels:
label1: LABEL1
label2: LABEL2
targets:
- 192.168.5.2:7000
Removing targets and labels
To remove the targets and labels added we need to run:
juju config prometheus-scrape-target-k8s labels=""
juju config prometheus-scrape-target-k8s targets=""
And now we can check this target is no longer in Prometheus config by running again:
juju ssh --container prometheus prometheus-k8s/0 \
cat /etc/prometheus/prometheus.yml | grep -B1 -A6 "external_jobs
After removing targets and labels Prometheus scrape target charm ends in a blocked
status waiting for adding new targets.