i am wondering if anybody maanged to add additional scrape-jobs to the prometheus2 charm. If anyone can share how they did it from cli it will be great.
- Deploy prometheus2.
- Create a yaml file with your custom target configs, below is an example from my monitoring of 3 services related to a cryptocurrency node running on a LXD juju cloud:
- Use “juju config” to load the custom targets.
$ cat prom.yaml
- job_name: 'validator' scrape_interval: 30s scrape_timeout: 30s static_configs: - targets: ['127.0.0.1:8081'] - job_name: 'beacon' scrape_interval: 30s scrape_timeout: 30s static_configs: - targets: ['127.0.0.1:8080'] - job_name: 'ethereum1' scrape_interval: 30s scrape_timeout: 30s static_configs: - targets: ['juju-f4cf5f-5:9090']
Once you have your yaml, you simply configure as:
juju config prometheus2 scrape-jobs="$(cat ./prom.yaml)"
Then, you should be able to see your targets in the prometheus web interface under “Targets” and once the scrape has been run, data should be available.
Hope it helps, feel free to reach out for more help.
… oh, and a pro tip.
Deploy grafana in a separate model and use juju “Cross Model Relation” to allow your prometheus2 targets to be consumed from grafana.
Something like this:
Create a model with prometheus in it and offer it. (This is Cross Nodel Relations).
juju add-model prometheus juju deploy prometheus2 juju offer prometheus2:grafana-source
You will get a endpoint reference that looks something like this: “admin/ether2test.prometheus2”
Now, create a new model with grafana in it and relate the remote prometheus (admin/ether2test.prometheus2).
juju add-model grafana juju deploy grafana juju relate grafana admin/ether2test.prometheus2
Now, open up grafana instance, login as described in the documentation for grafana charm, and you will find your new datasource in grafana.