canonical / alertmanager-k8s-operator

This charmed operator automates operation procedures of Alertmanager, the alerting component of Prometheus and Loki, among others.
https://charmhub.io/alertmanager-k8s
Apache License 2.0
4 stars 16 forks source link

add prometheus scrape jobs for all units #264

Closed ca-scribner closed 2 weeks ago

ca-scribner commented 1 month ago

Issue

closes #151

Solution

Extends AlertmanagerCharm.self_scraping_job() to include all units, not just the leader, for metrics scraping.

Testing Instructions

juju deploy prometheus-k8s --channel edge --trust
charmcraft pack
juju deploy ./*.charm --resource alertmanager-image=ubuntu/alertmanager:0-22.04 --trust
juju relate alertmanager-k8s:self-metrics-endpoint prometheus-k8s

# wait for things to settle

jhack show-relation alertmanager-k8s prometheus-k8s
# Should see a single target provided

juju scale-application alertmanager-k8s 3
# wait for things to settle
jhack show-relation alertmanager-k8s prometheus-k8s
# Should see a target for each unit

# Check if prometheus has the targets
curl $PROMETHEUS_IP:9090/api/v1/targets \
  | jq '.data.activeTargets | .[] | {scrapeUrl, health}'
# should see a target for each am unit (plus one for prometheus)

Upgrade Notes

Upgrade should happen seemlessly. Nothing has changed to affect upgrades