|
| 1 | +[note] |
| 2 | +**Note**: All commands are written for `juju >= v3.1` |
| 3 | + |
| 4 | +If you're using `juju 2.9`, check the [`juju 3.0` Release Notes](https://juju.is/docs/juju/roadmap#heading--juju-3-0-0---22-oct-2022). |
| 5 | +[/note] |
| 6 | + |
| 7 | +# Enable tracing |
| 8 | +This guide contains the steps to enable tracing with [Grafana Tempo](https://grafana.com/docs/tempo/latest/) for your MySQL Router K8s application. |
| 9 | + |
| 10 | +To summarize: |
| 11 | +* [Deploy the Tempo charm in a COS K8s environment](#heading--deploy) |
| 12 | +* [Integrate it with the COS charms](#heading--integrate) |
| 13 | +* [Offer interfaces for cross-model integrations](#heading--offer) |
| 14 | +* [View MySQL Router K8s traces on Grafana](#heading--view) |
| 15 | + |
| 16 | + |
| 17 | +[note type="caution"] |
| 18 | +**Warning:** This is feature is in development. It is **not recommended** for production environments. |
| 19 | + |
| 20 | +This feature is available for Charmed MySQL Router K8s revision 117+ only. |
| 21 | +[/note] |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | +Enabling tracing with Tempo requires that you: |
| 25 | +- Have deployed a Charmed MySQL Router K8s application |
| 26 | + - See [How to manage units](https://discourse.charmhub.io/t/mysql-router-k8s-how-to-manage-units/12240) |
| 27 | +- Have deployed a 'cos-lite' bundle from the `latest/edge` track in a Kubernetes environment |
| 28 | + - See [Getting started on MicroK8s](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s) |
| 29 | + |
| 30 | +--- |
| 31 | +<a href="#heading--deploy"><h2 id="heading--deploy"> Deploy Tempo </h2></a> |
| 32 | + |
| 33 | +First, switch to the Kubernetes controller where the COS model is deployed: |
| 34 | + |
| 35 | +```shell |
| 36 | +juju switch <k8s_controller_name>:<cos_model_name> |
| 37 | +``` |
| 38 | +Then, deploy the [`tempo-k8s`](https://charmhub.io/tempo-k8s) charm: |
| 39 | +```shell |
| 40 | +juju deploy -n 1 tempo-k8s --channel latest/edge |
| 41 | +``` |
| 42 | + |
| 43 | +<a href="#heading--integrate"><h2 id="heading--integrate"> Integrate with the COS charms </h2></a> |
| 44 | + |
| 45 | +Integrate `tempo-k8s` with the COS charms as follows: |
| 46 | + |
| 47 | +```shell |
| 48 | +juju integrate tempo-k8s:grafana-dashboard grafana:grafana-dashboard |
| 49 | +juju integrate tempo-k8s:grafana-source grafana:grafana-source |
| 50 | +juju integrate tempo-k8s:ingress traefik:traefik |
| 51 | +juju integrate tempo-k8s:metrics-endpoint prometheus:metrics-endpoint |
| 52 | +juju integrate tempo-k8s:logging loki:logging |
| 53 | +``` |
| 54 | +If you would like to instrument traces from the COS charms as well, create the following integrations: |
| 55 | +```shell |
| 56 | +juju integrate tempo-k8s:tracing alertmanager:tracing |
| 57 | +juju integrate tempo-k8s:tracing catalogue:tracing |
| 58 | +juju integrate tempo-k8s:tracing grafana:tracing |
| 59 | +juju integrate tempo-k8s:tracing loki:tracing |
| 60 | +juju integrate tempo-k8s:tracing prometheus:tracing |
| 61 | +juju integrate tempo-k8s:tracing traefik:tracing |
| 62 | +``` |
| 63 | + |
| 64 | +<a href="#heading--offer"><h2 id="heading--offer"> Offer interfaces </h2></a> |
| 65 | + |
| 66 | +Next, offer interfaces for cross-model integrations from the model where Charmed MySQL Router is deployed. |
| 67 | + |
| 68 | +To offer the Tempo integration, run |
| 69 | + |
| 70 | +```shell |
| 71 | +juju offer tempo-k8s:tracing |
| 72 | +``` |
| 73 | + |
| 74 | +Then, switch to the Charmed MySQL Router K8s model, find the offers, and integrate (relate) with them: |
| 75 | + |
| 76 | +```shell |
| 77 | +juju switch <k8s_controller_name>:<mysql_router_k8s_model_name> |
| 78 | + |
| 79 | +juju find-offers <k8s_controller_name>: |
| 80 | +``` |
| 81 | +> :exclamation: Do not miss the "`:`" in the command above. |
| 82 | +
|
| 83 | +Below is a sample output where `k8s` is the K8s controller name and `cos` is the model where `cos-lite` and `tempo-k8s` are deployed: |
| 84 | + |
| 85 | +```shell |
| 86 | +Store URL Access Interfaces |
| 87 | +k8s admin/cos.tempo-k8s admin tracing:tracing |
| 88 | +``` |
| 89 | + |
| 90 | +Next, consume this offer so that it is reachable from the current model: |
| 91 | + |
| 92 | +```shell |
| 93 | +juju consume k8s:admin/cos.tempo-k8s |
| 94 | +``` |
| 95 | + |
| 96 | +Relate Charmed MySQL Router K8s with the above consumed interface: |
| 97 | + |
| 98 | +```shell |
| 99 | +juju integrate mysql-router-k8s:tracing tempo-k8s:tracing |
| 100 | +``` |
| 101 | + |
| 102 | +Wait until the model settles. The following is an example of the `juju status --relations` on the Charmed MySQL Router K8s model: |
| 103 | + |
| 104 | +```shell |
| 105 | +Model Controller Cloud/Region Version SLA Timestamp |
| 106 | +database k8s microk8s/localhost 3.4.3 unsupported 20:15:35Z |
| 107 | + |
| 108 | +SAAS Status Store URL |
| 109 | +tempo-k8s active k8s admin/cos.tempo-k8s |
| 110 | + |
| 111 | +App Version Status Scale Charm Channel Rev Address Exposed Message |
| 112 | +mysql-k8s 8.0.36-0ubuntu0.22.04.1 active 1 mysql-k8s 8.0/edge 153 10.152.183.113 no |
| 113 | +mysql-router-k8s 8.0.36-0ubuntu0.22.04.1 active 1 mysql-router-k8s 8.0/edge 120 10.152.183.129 no |
| 114 | +mysql-test-app 0.0.2 active 1 mysql-test-app latest/stable 37 10.152.183.48 no Last written value=12318 |
| 115 | + |
| 116 | +Unit Workload Agent Address Ports Message |
| 117 | +mysql-k8s/0* active idle 10.1.241.204 Primary |
| 118 | +mysql-router-k8s/0* active idle 10.1.241.218 |
| 119 | +mysql-test-app/0* active idle 10.1.241.231 Last written value=12318 |
| 120 | + |
| 121 | +Integration provider Requirer Interface Type Message |
| 122 | +mysql-k8s:database mysql-router-k8s:backend-database mysql_client regular |
| 123 | +mysql-k8s:database-peers mysql-k8s:database-peers mysql_peers peer |
| 124 | +mysql-k8s:restart mysql-k8s:restart rolling_op peer |
| 125 | +mysql-k8s:upgrade mysql-k8s:upgrade upgrade peer |
| 126 | +mysql-router-k8s:cos mysql-router-k8s:cos cos peer |
| 127 | +mysql-router-k8s:database mysql-test-app:database mysql_client regular |
| 128 | +mysql-router-k8s:mysql-router-peers mysql-router-k8s:mysql-router-peers mysql_router_peers peer |
| 129 | +mysql-router-k8s:upgrade-version-a mysql-router-k8s:upgrade-version-a upgrade peer |
| 130 | +mysql-test-app:application-peers mysql-test-app:application-peers application-peers peer |
| 131 | +tempo-k8s:tracing mysql-router-k8s:tracing tracing regular |
| 132 | + |
| 133 | +``` |
| 134 | + |
| 135 | +[note] |
| 136 | +**Note:** All traces are exported to Tempo using HTTP. Support for sending traces via HTTPS is an upcoming feature. |
| 137 | +[/note] |
| 138 | + |
| 139 | +<a href="#heading--view"><h2 id="heading--view"> View traces </h2></a> |
| 140 | + |
| 141 | +After this is complete, the Tempo traces will be accessible from Grafana under the `Explore` section with `tempo-k8s` as the data source. You will be able to select `mysql` as the `Service Name` under the `Search` tab to view traces belonging to Charmed MySQL Router K8s. |
| 142 | + |
| 143 | +Below is a screenshot demonstrating a Charmed MySQL Router K8s trace: |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | +Feel free to read through the [Tempo documentation](https://discourse.charmhub.io/t/tempo-k8s-docs-index/14005) at your leisure to explore its deployment and its integrations. |
0 commit comments