1
- # Enable monitoring
1
+ [ note]
2
+ ** Note** : All commands are written for [ ` juju >= v3.0 ` ] ( https://juju.is/docs/juju/roadmap#heading--juju-3-0-0---22-oct-2022 )
3
+ [ /note]
2
4
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
5
+ # How to enable monitoring with COS and Grafana
4
6
5
- Enabling monitoring requires that you:
7
+ This guide goes over the steps to integrate MySQL Router K8s deployment with COS to enable monitoring in Grafana.
6
8
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
+ To learn about Alert Rules, see [ Charmed MySQL K8s > How to enable COS Alert Rules] ( https://charmhub.io/mysql-k8s/docs/h-enable-alert-rules ) .
9
10
10
- Switch to the COS K8s environment and offer COS interfaces to be cross-model related with Charmed MySQLRouter K8s model:
11
+ ## Prerequisites
12
+ * A deployed [ Charmed MySQL Router K8s] ( /t/12233 ) operator
13
+ * A deployed [ ‘cos-lite’ bundle in a Kubernetes environment] ( https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s )
14
+
15
+ ## Summary
16
+ * [ Offer interfaces via the COS controller] ( #offer-interfaces-via-the-cos-controller )
17
+ * [ Consume offers via the MySQL Router K8s model] ( #consume-offers-via-the-mysql-router-k8s-model )
18
+ * [ Deploy and integrate Grafana] ( #deploy-and-integrate-grafana )
19
+ * [ Connect to the Grafana web interface] ( #connect-to-the-grafana-web-interface )
20
+
21
+ ---
22
+
23
+ ## Offer interfaces via the COS controller
24
+
25
+ First, we will switch to the COS K8s environment and offer COS interfaces to be cross-model integrated with the Charmed MySQLRouter K8s model.
26
+
27
+ To switch to the Kubernetes controller for the COS model, run
11
28
12
29
``` shell
13
- # Switch to the Kubernetes controller, on the COS model
14
- juju switch < k8s_cos_controller > : < cos_model_name >
30
+ juju switch < k8s_controller > : < cos_model_name >
31
+ ```
15
32
33
+ To offer the COS interfaces, run
34
+ ``` shell
16
35
juju offer grafana:grafana-dashboard
17
36
juju offer loki:logging
18
37
juju offer prometheus:receive-remote-write
19
38
```
39
+ ## Consume offers via the MySQL Router K8s model
20
40
21
- Switch to the Charmed MySQLRouter K8s model, find offers and consume them:
41
+ Next, we will switch to the Charmed MySQL Router K8s model, find offers, and consume them.
42
+
43
+ We are currently on the Kubernetes controller for the COS model. To switch to the MySQL Router K8smodel, run
22
44
23
45
``` shell
24
- # We are on the Kubernetes controller, on the COS model. Switch the mysqlrouter model
25
46
juju switch < k8s_db_controller> :< mysql_router_model_name>
26
-
47
+ ```
48
+ Display a list of available interfaces with the following command:
49
+ ``` shell
27
50
juju find-offers < k8s_cos_controller> : # Do not miss the ':' here!
28
51
```
29
52
30
- A similar output should appear, if ` k8s ` is the k8s controller name and ` cos ` is the model where cos-lite has been deployed:
53
+ In the sample output below, ` k8s ` is the k8s controller name and ` cos ` is the model where ` cos-lite ` has been deployed:
31
54
32
55
``` shell
33
56
Store URL Access Interfaces
@@ -36,31 +59,36 @@ k8s admin/cos.loki admin loki_push_api:logging
36
59
k8s admin/cos.prometheus admin prometheus_remote_write:receive-remote-write
37
60
```
38
61
39
- Consume the offers to be reachable in the current model:
62
+ To consume offers to be reachable in the current model, run
40
63
41
64
``` shell
42
65
juju consume k8s:admin/cos.grafana
43
66
juju consume k8s:admin/cos.loki
44
67
juju consume k8s:admin/cos.prometheus
45
68
```
46
69
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:
70
+ ## Deploy and integrate Grafana
48
71
72
+ First, deploy [ grafana-agent] ( https://charmhub.io/grafana-agent ) :
49
73
``` shell
50
74
juju deploy grafana-agent-k8s --trust
51
-
75
+ ```
76
+ Then, integrate (previously known as "[ relate] ( https://juju.is/docs/juju/integration ) ") ` grafana-agent ` with Charmed MySQL Router K8s:
77
+ ``` shell
52
78
juju integrate grafana-agent-k8s grafana
53
79
juju integrate grafana-agent-k8s loki
54
80
juju integrate grafana-agent-k8s prometheus
55
-
81
+ ```
82
+ Finally, integrate ` grafana-agent-k8s ` with the consumed COS offers:
83
+ ``` shell
56
84
juju integrate grafana-agent-k8s mysql-router-k8s:grafana-dashboard
57
85
juju integrate grafana-agent-k8s mysql-router-k8s:logging
58
86
juju integrate grafana-agent-k8s mysql-router-k8s:metrics-endpoint
59
87
```
60
88
61
- After this is complete, Grafana will show the new dashboards ` MySQLRouter Exporter ` and allow access for Charmed MySQLRouter K8s logs on Loki.
89
+ After this is complete, Grafana will show the new dashboards ` MySQLRouter Exporter ` and allow access for Charmed MySQL Router K8s logs on Loki.
62
90
63
- An example of ` juju status ` on Charmed MySQLRouter K8s model:
91
+ An example of ` juju status ` on Charmed MySQL Router K8s model:
64
92
65
93
``` shell
66
94
ubuntu@localhost:~ $ juju status
@@ -114,7 +142,9 @@ loki loki loki-k8s 124 2/2 logging loki_push_api
114
142
prometheus prometheus prometheus-k8s 171 2/2 receive-remote-write prometheus_remote_write provider
115
143
```
116
144
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 ) ”:
145
+ ## Connect to Grafana web interface
146
+
147
+ To connect to the Grafana web interface, follow the [ Browse dashboards] ( https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s?_ga=2.201254254.1948444620.1704703837-757109492.1701777558#heading--browse-dashboards ) section of the MicroK8s "Getting started" guide.
118
148
119
149
``` shell
120
150
juju run grafana/leader get-admin-password --model < k8s_controller> :< cos_model_name>
0 commit comments