How to view metrics
You can view Charmed MongoDB K8s metrics in two ways:
Query the metric endpoint
Charmed MongoDB K8s comes with MongoDB Exporter and provides replication and cluster metrics. The metrics can be queried by accessing the http://<unit-ip>:9216/metrics
endpoint.
To quickly view them, you can do the following:
- Identify the unit you would like to query by entering
juju status
. Choose a unit to gather metrics from and copy its “Public Address” curl
the metrics endpoint for your unit of interest withcurl http://<unit-ip>:9216/metrics
. This should show a long set of metrics.
Access metrics with Grafana
Charmed MongoDB K8s provides integration with the Canonical Observability Stack (COS) - which allows you to view the metrics in a GUI.
To view the GUI:
- Deploy the
cos-lite
bundle in a Kubernetes environment. This can be done by following the deployment tutorial. Wait for thecos-lite
bundle to become active and idle, by viewingjuju status
. Beware to use the following offers which contain theprometheus-scrape
endpoint, essential to our stack (this endpoint still exists but has been removed from the example offer of the bundle):
https://raw.githubusercontent.com/canonical/cos-lite-bundle/09715997467e1b568109064fa17ecefd4b574032/overlays/offers-overlay.yaml
https://raw.githubusercontent.com/canonical/cos-lite-bundle/09715997467e1b568109064fa17ecefd4b574032/overlays/storage-small-overlay.yaml
- Switch back to your model and consume offers from the COS bundle and relate COS bundle to your application:
juju consume <cos-controller-name>:admin/cos.prometheus-scrape
juju consume <cos-controller-name>:admin/cos.alertmanager-karma-dashboard
juju consume <cos-controller-name>:admin/cos.grafana-dashboards
juju consume <cos-controller-name>:admin/cos.loki-logging
juju consume <cos-controller-name>:admin/cos.prometheus-receive-remote-write
juju integrate mongodb-k8s prometheus-scrape
juju integrate mongodb-k8s loki-logging
juju integrate mongodb-k8s grafana-dashboards
- To view the dashboard we need to find the URL of grafana along with the password for the dashboard. Switch to the k8s model hosting the COS-lite bundle and show all applications:
juju switch <cos-controller>
juju status
Under the report of juju status, the IP address of the grafana GUI should be listed as the “Public Address” for the application grafana
. Copy this address and navigate to it in your browser. In your browser you should see a login. Use the username admin
, to retrieve the password go back to your terminal and run the action: juju run grafana/0 get-admin-password --wait
- use this password to access the Grafana Dashboard.