|
| 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 | + |
| 7 | +* [Have a Charmed MySQLRouter K8s deployed](https://charmhub.io/mysql-router/docs/t-deploy-charm?channel=dpe/edge) |
| 8 | +* [Deploy cos-lite bundle in a Kubernetes environment](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s) |
| 9 | + |
| 10 | +Switch to the COS K8s environment and offer COS interfaces to be cross-model related with Charmed MySQLRouter K8s model: |
| 11 | + |
| 12 | +```shell |
| 13 | +# Switch to the Kubernetes controller, on the COS model |
| 14 | +juju switch <k8s_cos_controller>:<cos_model_name> |
| 15 | + |
| 16 | +juju offer grafana:grafana-dashboard |
| 17 | +juju offer loki:logging |
| 18 | +juju offer prometheus:receive-remote-write |
| 19 | +``` |
| 20 | + |
| 21 | +Switch to the Charmed MySQLRouter K8s model, find offers and consume them: |
| 22 | + |
| 23 | +```shell |
| 24 | +# We are on the Kubernetes controller, on the COS model. Switch the mysqlrouter model |
| 25 | +juju switch <k8s_db_controller>:<mysql_router_model_name> |
| 26 | + |
| 27 | +juju find-offers <k8s_cos_controller>: # Do not miss the ':' here! |
| 28 | +``` |
| 29 | + |
| 30 | +A similar output should appear, if `k8s` is the k8s controller name and `cos` is the model where cos-lite has been deployed: |
| 31 | + |
| 32 | +```shell |
| 33 | +Store URL Access Interfaces |
| 34 | +k8s admin/cos.grafana admin grafana_dashboard:grafana-dashboard |
| 35 | +k8s admin/cos.loki admin loki_push_api:logging |
| 36 | +k8s admin/cos.prometheus admin prometheus_remote_write:receive-remote-write |
| 37 | +``` |
| 38 | + |
| 39 | +Consume the offers to be reachable in the current model: |
| 40 | + |
| 41 | +```shell |
| 42 | +juju consume k8s:admin/cos.grafana |
| 43 | +juju consume k8s:admin/cos.loki |
| 44 | +juju consume k8s:admin/cos.prometheus |
| 45 | +``` |
| 46 | + |
| 47 | +Now, deploy ‘[grafana-agent-k8s](https://charmhub.io/grafana-agent-k8s)’ and integrate (relate) it with Charmed MySQLRouter K8s, then later integrate (relate) `grafana-agent-k8s` with the consumed COS offers: |
| 48 | + |
| 49 | +```shell |
| 50 | +juju deploy grafana-agent-k8s --trust |
| 51 | + |
| 52 | +juju integrate grafana-agent-k8s grafana |
| 53 | +juju integrate grafana-agent-k8s loki |
| 54 | +juju integrate grafana-agent-k8s prometheus |
| 55 | + |
| 56 | +juju integrate grafana-agent-k8s mysql-router-k8s:grafana-dashboard |
| 57 | +juju integrate grafana-agent-k8s mysql-router-k8s:logging |
| 58 | +juju integrate grafana-agent-k8s mysql-router-k8s:metrics-endpoint |
| 59 | +``` |
| 60 | + |
| 61 | +After this is complete, Grafana will show the new dashboards `MySQLRouter Exporter` and allow access for Charmed MySQLRouter K8s logs on Loki. |
| 62 | + |
| 63 | +An example of `juju status` on Charmed MySQLRouter K8s model: |
| 64 | + |
| 65 | +```shell |
| 66 | +ubuntu@localhost:~$ juju status |
| 67 | +Model Controller Cloud/Region Version SLA Timestamp |
| 68 | +database k8s microk8s/localhost 3.1.8 unsupported 13:27:08Z |
| 69 | + |
| 70 | +SAAS Status Store URL |
| 71 | +grafana active k8s admin/cos.grafana |
| 72 | +loki active k8s admin/cos.loki |
| 73 | +prometheus active k8s admin/cos.prometheus |
| 74 | + |
| 75 | +App Version Status Scale Charm Channel Rev Address Exposed Message |
| 76 | +grafana-agent-k8s 0.35.2 active 1 grafana-agent-k8s stable 64 10.152.183.141 no |
| 77 | +mysql-k8s 8.0.35-0ubuntu0.22.04.1 active 1 mysql-k8s 8.0/stable 127 10.152.183.105 no |
| 78 | +mysql-router-k8s 8.0.36-0ubuntu0.22.04.1 active 1 mysql-router-k8s 8.0/edge 102 10.152.183.92 no |
| 79 | +mysql-test-app 0.0.2 active 1 mysql-test-app stable 36 10.152.183.35 no |
| 80 | + |
| 81 | +Unit Workload Agent Address Ports Message |
| 82 | +grafana-agent-k8s/0* active idle 10.1.241.243 |
| 83 | +mysql-k8s/0* active idle 10.1.241.239 Primary |
| 84 | +mysql-router-k8s/0* active idle 10.1.241.240 |
| 85 | +mysql-test-app/0* active idle 10.1.241.241 |
| 86 | +``` |
| 87 | + |
| 88 | +An example of `juju status` on the COS K8s model: |
| 89 | + |
| 90 | +```shell |
| 91 | +ubuntu@localhost:~$ juju status |
| 92 | +Model Controller Cloud/Region Version SLA Timestamp |
| 93 | +cos k8s microk8s/localhost 3.1.8 unsupported 13:28:02Z |
| 94 | + |
| 95 | +App Version Status Scale Charm Channel Rev Address Exposed Message |
| 96 | +alertmanager 0.27.0 active 1 alertmanager-k8s stable 106 10.152.183.197 no |
| 97 | +catalogue active 1 catalogue-k8s stable 33 10.152.183.38 no |
| 98 | +grafana 9.5.3 active 1 grafana-k8s stable 106 10.152.183.238 no |
| 99 | +loki 2.9.4 active 1 loki-k8s stable 124 10.152.183.84 no |
| 100 | +prometheus 2.49.1 active 1 prometheus-k8s stable 171 10.152.183.182 no |
| 101 | +traefik 2.10.5 active 1 traefik-k8s stable 174 10.0.0.44 no |
| 102 | + |
| 103 | +Unit Workload Agent Address Ports Message |
| 104 | +alertmanager/0* active idle 10.1.241.222 |
| 105 | +catalogue/0* active idle 10.1.241.225 |
| 106 | +grafana/0* active idle 10.1.241.228 |
| 107 | +loki/0* active idle 10.1.241.226 |
| 108 | +prometheus/0* active idle 10.1.241.227 |
| 109 | +traefik/0* active idle 10.1.241.221 |
| 110 | + |
| 111 | +Offer Application Charm Rev Connected Endpoint Interface Role |
| 112 | +grafana grafana grafana-k8s 106 2/2 grafana-dashboard grafana_dashboard requirer |
| 113 | +loki loki loki-k8s 124 2/2 logging loki_push_api provider |
| 114 | +prometheus prometheus prometheus-k8s 171 2/2 receive-remote-write prometheus_remote_write provider |
| 115 | +``` |
| 116 | + |
| 117 | +To connect Grafana WEB interface, follow the COS section “[Browse dashboards](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s#heading--browse-dashboards)”: |
| 118 | + |
| 119 | +```shell |
| 120 | +juju run grafana/leader get-admin-password --model <k8s_controller>:<cos_model_name> |
| 121 | +``` |
0 commit comments