|
| 1 | +# Enable monitoring |
| 2 | + |
| 3 | +> **:information_source: Hint**: Use [Juju 3](/t/5064). Otherwise replace `juju run ...` with `juju run-action --wait ...` and `juju integrate` with `juju relate` for Juju 2.9 |
| 4 | +
|
| 5 | +Enabling monitoring requires that you: |
| 6 | +* [Have a Charmed MySQL and Charmed MySQLRouter deployed](https://charmhub.io/mysql-router/docs/t-deploy-charm?channel=dpe/edge) |
| 7 | +* [Deploy ‘cos-lite’ bundle in a Kubernetes environment](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s) |
| 8 | + |
| 9 | +Switch to the COS K8s environment and offer COS interfaces to be cross-model integrated (related) with Charmed MySQLRouter VM model: |
| 10 | + |
| 11 | +```shell |
| 12 | +# Switch to the Kubernetes controller, in particular the COS model |
| 13 | +juju switch <k8s_controller>:<cos_model_name> |
| 14 | + |
| 15 | +juju offer grafana:grafana-dashboard |
| 16 | +juju offer loki:logging |
| 17 | +juju offer prometheus:receive-remote-write |
| 18 | +``` |
| 19 | + |
| 20 | + Switch to the Charmed MySQLRouter VM model, find offers and integrate (relate) with them: |
| 21 | + |
| 22 | +```shell |
| 23 | +# We are on the Kubernetes controller, for the COS model. Switch to the MySQLRouter model |
| 24 | +juju switch <machine_controller_name>:<mysql_router_model_name> |
| 25 | + |
| 26 | +juju find-offers <k8s_controller>: # Do not miss ':' here |
| 27 | +``` |
| 28 | + |
| 29 | +A similar output should appear, if `k8s` is the k8s controller name and `cos` is the model where cos-lite has been deployed: |
| 30 | + |
| 31 | +```shell |
| 32 | +Store URL Access Interfaces |
| 33 | +k8s admin/cos.grafana admin grafana_dashboard:grafana-dashboard |
| 34 | +k8s admin/cos.loki admin loki_push_api:logging |
| 35 | +k8s admin/cos.prometheus admin prometheus_remote_write:receive-remote-write |
| 36 | +``` |
| 37 | + |
| 38 | +Consume offers to be reachable in the current model: |
| 39 | + |
| 40 | +```shell |
| 41 | +juju consume k8s:admin/cos.grafana |
| 42 | +juju consume k8s:admin/cos.loki |
| 43 | +juju consume k8s:admin/cos.prometheus |
| 44 | +``` |
| 45 | + |
| 46 | +Now deploy ‘[grafana_agent](https://charmhub.io/grafana-agent)’ (subordinate charm) alongside the Charmed MySQL Router application (also subordinate) and integrate (relate) it with Charmed MySQLRouter, then later integrate (relate) `grafana-agent `with the consumed COS offers: |
| 47 | + |
| 48 | +```shell |
| 49 | +# Assume <client_application> is the principal application for the subordinate mysql router application |
| 50 | +juju deploy grafana-agent |
| 51 | +juju integrate <client_application> grafana-agent |
| 52 | +juju integrate grafana-agent mysql-router:cos-agent |
| 53 | +juju integrate grafana-agent grafana |
| 54 | +juju integrate grafana-agent loki |
| 55 | +juju integrate grafana-agent prometheus |
| 56 | +``` |
| 57 | + |
| 58 | +After this is complete, Grafana will show the new dashboards `MySQLRouter Exporter` and allows access for Charmed MySQLRouter logs on Loki. |
| 59 | + |
| 60 | +An example of `juju status` on the Charmed MySQLRouter VM model: |
| 61 | + |
| 62 | +```shell |
| 63 | +ubuntu@localhost:~$ juju status |
| 64 | +Model Controller Cloud/Region Version SLA Timestamp |
| 65 | +database lxd localhost/localhost 3.1.8 unsupported 12:34:26Z |
| 66 | + |
| 67 | +SAAS Status Store URL |
| 68 | +grafana active k8s admin/cos.grafana |
| 69 | +loki active k8s admin/cos.loki |
| 70 | +prometheus active k8s admin/cos.prometheus |
| 71 | + |
| 72 | +App Version Status Scale Charm Channel Rev Exposed Message |
| 73 | +grafana-agent active 1 grafana-agent stable 65 no |
| 74 | +mysql 8.0.34-0ubun... active 1 mysql 8.0/stable 196 no |
| 75 | +mysql-router 8.0.36-0ubun... active 1 mysql-router dpe/edge 153 no |
| 76 | +mysql-test-app 0.0.2 active 1 mysql-test-app stable 36 no |
| 77 | + |
| 78 | +Unit Workload Agent Machine Public address Ports Message |
| 79 | +mysql-test-app/0* active idle 1 10.205.193.82 |
| 80 | + grafana-agent/0* active idle 10.205.193.82 |
| 81 | + mysql-router/0* active idle 10.205.193.82 |
| 82 | +mysql/0* active idle 0 10.205.193.13 3306,33060/tcp Primary |
| 83 | + |
| 84 | +Machine State Address Inst id Base AZ Message |
| 85 | +0 started 10.205.193.13 juju-65afbd-0 [email protected] Running |
| 86 | +1 started 10.205.193.82 juju-65afbd-1 [email protected] Running |
| 87 | +``` |
| 88 | + |
| 89 | +Example of `juju status` on the COS K8s model: |
| 90 | + |
| 91 | +```shell |
| 92 | +ubuntu@localhost:~$ juju status |
| 93 | +Model Controller Cloud/Region Version SLA Timestamp |
| 94 | +cos k8s microk8s/localhost 3.1.8 unsupported 20:29:12Z |
| 95 | + |
| 96 | +App Version Status Scale Charm Channel Rev Address Exposed Message |
| 97 | +alertmanager 0.27.0 active 1 alertmanager-k8s stable 106 10.152.183.197 no |
| 98 | +catalogue active 1 catalogue-k8s stable 33 10.152.183.38 no |
| 99 | +grafana 9.5.3 active 1 grafana-k8s stable 106 10.152.183.238 no |
| 100 | +loki 2.9.4 active 1 loki-k8s stable 124 10.152.183.84 no |
| 101 | +prometheus 2.49.1 active 1 prometheus-k8s stable 171 10.152.183.182 no |
| 102 | +``` |
| 103 | + |
| 104 | +To connect to the Grafana WEB interface, follow the COS section “[Browse dashboards](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s#heading--browse-dashboards)”: |
| 105 | + |
| 106 | +```shell |
| 107 | +juju run grafana/leader get-admin-password --model <k8s_controller>:<cos_model_name> |
| 108 | +``` |
0 commit comments