canonical / pvcviewer-operator

Charm PVCViewer for visualizing PVC content
Apache License 2.0
2 stars 0 forks source link

Add metrics-endpoint and grafana-dashboard #48

Closed rgildein closed 1 month ago

rgildein commented 1 month ago

Add relation for metrics and dashboards. Right now there are no dashboards or alert rules, since I did not find any. I decide to add relations anyway, so in future we need only to add dashboard or alert rule without any need of changing the charm code.

Dropped rbac proxy, since this makes the metrics inaccessible.

fixes: #46

How I tested it:

$  tox -e integration -- --keep-models
$ juju switch test-charm-ximg
$ juju exec --unit grafana-agent-k8s/0 -- curl localhost:12345/agent/api/v1/metrics/targets | jq
...
{
      "instance": "243a344db344241f404868d04272fc76",
      "target_group": "juju_test-charm-ximg_a0815b23_pvcviewer-operator_prometheus_scrape-0",
      "endpoint": "http://10.1.23.250:8080/metrics",
      "state": "up",
      "labels": {
        "instance": "test-charm-ximg_a0815b23-9d7e-450e-8efb-8317b27de8a9_pvcviewer-operator_pvcviewer-operator/0",
        "job": "juju_test-charm-ximg_a0815b23_pvcviewer-operator_prometheus_scrape-0",
        "juju_application": "pvcviewer-operator",
        "juju_charm": "pvcviewer-operator",
        "juju_model": "test-charm-ximg",
        "juju_model_uuid": "a0815b23-9d7e-450e-8efb-8317b27de8a9",
        "juju_unit": "pvcviewer-operator/0"
...
$ juju exec --unit grafana-agent-k8s/0 -- curl http://10.1.23.250:8080/metrics
# HELP certwatcher_read_certificate_errors_total Total number of certificate read errors
# TYPE certwatcher_read_certificate_errors_total counter
certwatcher_read_certificate_errors_total 0
# HELP certwatcher_read_certificate_total Total number of certificate reads
# TYPE certwatcher_read_certificate_total counter
certwatcher_read_certificate_total 13
# HELP controller_runtime_active_workers Number of currently used workers per controller
# TYPE controller_runtime_active_workers gauge
...

full example here