Canonical Observability Stack Lite
- Canonical Observability | bundle
Channel | Revision | Published |
---|---|---|
latest/stable | 11 | 21 Oct 2022 |
latest/candidate | 10 | 21 Oct 2022 |
latest/beta | 9 | 21 Oct 2022 |
latest/edge | 18 | 20 Jun 2023 |
1.0/stable | 16 | 21 Oct 2022 |
1.0/candidate | 14 | 21 Oct 2022 |
1.0/beta | 13 | 21 Oct 2022 |
1.0/edge | 12 | 21 Oct 2022 |
juju deploy cos-lite --channel edge
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
By default, the Prometheus charm allows for minimal configuration of the scrape jobs created when you relate it to a remote charm. Instead, we chose to put it in an adapter/config charm, allowing for it to be used when there is a need without adding complexity to the general use case.
Deploying the Scrape Config charm
Deploying the prometheus-scrape-config-k8s charm is accomplished through a single command. Here, we’ll deploy it from the edge channel:
$ juju deploy prometheus-scrape-config-k8s --channel latest/edge
Then relate it to the application you want to scrape, in this case zinc-k8s, as well as to Prometheus itself:
$ juju relate \
prometheus-scrape-config-k8s
zinc-k8s
$ juju relate \
prometheus-scrape-config-k8s
prometheus-k8s
With that done, you’ll now be able to tweak the configuration of the scrape job
For a list of configuration options and explanations about what they do as well as what their defaults are, we can run the juju config
command without any configuration option:
$ juju config prometheus-scrape-config-k8s
Changing the configuration of the scrape job
Let’s go ahead and have a look at how our scrape job currently looks:
$ juju show-unit prometheus-k8s/0
...
"scrape_jobs": "[{\"metrics_path\": \"/metrics\", \"static_configs\": [{\"labels\": {\"juju_model\": \"cos\", \"juju_model_uuid\": \"c3d3aa50-aefc-4511-8a0a-af825c838b64\", \"juju_application\": \"zinc-k8s\", \"juju_charm\": \"zinc-k8s\", \"juju_unit\": \"zinc-k8s/0\"}, \"targets\": [\"10.1.14.39:3100\"]}], \"job_name\": \"juju_cos_c3d3aa50_zinc_k8s_prometheus_scrape\", \"relabel_configs\": [{\"source_labels\": [\"juju_model\", \"juju_model_uuid\", \"juju_application\", \"juju_unit\"], \"separator\": \"_\", \"target_label\": \"instance\", \"regex\": \"(.*)\"}]}]"
...
Then, we will set the scrape_interval
in the prometheus-scrape-config-k8s charm:
$ juju config prometheus-scrape-config-k8s scrape_interval=2m
Let’s have a look again:
$ juju show-unit prometheus-k8s/0
...
"scrape_jobs": "[{\"metrics_path\": \"/metrics\", \"static_configs\": [{\"labels\": {\"juju_model\": \"cos\", \"juju_model_uuid\": \"c3d3aa50-aefc-4511-8a0a-af825c838b64\", \"juju_application\": \"zinc-k8s\", \"juju_charm\": \"zinc-k8s\", \"juju_unit\": \"zinc-k8s/0\"}, \"targets\": [\"10.1.14.39:3100\"]}], \"job_name\": \"juju_cos_c3d3aa50_zinc_k8s_prometheus_scrape\", \"relabel_configs\": [{\"source_labels\": [\"juju_model\", \"juju_model_uuid\", \"juju_application\", \"juju_unit\"], \"separator\": \"_\", \"target_label\": \"instance\", \"regex\": \"(.*)\"}],\"scrape_interval\": \"2m\"}]"
...
Notice how the last part of our scrape job changed? We are now sending a non-default scrape_interval
to Prometheus! If we visualize our deployment as a diagram, it will now instead look like this: