|  | 
|  | 1 | +# Grafana / OTEL-LGTM Provisioning Guide | 
|  | 2 | + | 
|  | 3 | +This repository defines the provisioning setup for **Grafana** as part of the **[OpenTelemetry LGTM](https://hub.docker.com/r/grafana/otel-lgtm) (Loki, Grafana, Tempo, Prometheus)** stack.   | 
|  | 4 | +Provisioning allows you to **automatically configure dashboards, alerting rules, and contact points** through YAML files — ensuring consistent, version-controlled observability configurations. | 
|  | 5 | + | 
|  | 6 | +--- | 
|  | 7 | + | 
|  | 8 | +## Overview | 
|  | 9 | + | 
|  | 10 | +Provisioning in Grafana means preloading configuration files that are applied automatically when Grafana starts.   | 
|  | 11 | +This setup covers three main provisioning categories: | 
|  | 12 | + | 
|  | 13 | +1. **Dashboards** – Predefined visualizations for metrics, logs, and traces. | 
|  | 14 | +2. **Alerting Rules** – Conditions that trigger alerts based on metric or log thresholds. | 
|  | 15 | +3. **Contact Points** – Notification destinations for alert delivery (e.g., email, Discord, Slack). | 
|  | 16 | + | 
|  | 17 | +All provisioning files are placed inside the docker image under the directory `/otel-lgtm/grafana/conf/provisioning/` (or equivalent custom mount path defined in the [`docker-compose-satp.yml`](../docker-compose-satp.yml)). | 
|  | 18 | + | 
|  | 19 | +--- | 
|  | 20 | + | 
|  | 21 | +## Directory Structure | 
|  | 22 | + | 
|  | 23 | +To provision the monitor system with dashboards, alerts or contact points use the following repository layout: | 
|  | 24 | + | 
|  | 25 | +provisioning/<br> | 
|  | 26 | +├── dashboards/<br> | 
|  | 27 | +│ ├── [grafana-dashboards.yaml](#grafana-dashboardsyaml)     *# Dashboard provisioning configuration*<br> | 
|  | 28 | +│ ├── dashboard-#1.json       *# Dashboard #1 definition*<br> | 
|  | 29 | +│ ├── ...<br> | 
|  | 30 | +│ └── [dashboard-#n.json](#dashboard-njson)       *# Dashboard #n definition*<br> | 
|  | 31 | +├── alerting/<br> | 
|  | 32 | +│ ├── alert-#1.yaml          *# Alert group and rule definitions #1*<br> | 
|  | 33 | +│ ├── ...<br> | 
|  | 34 | +│ ├── [alert-#m.yaml](#alert-myaml)         *# Alert group and rule definitions #m*<br> | 
|  | 35 | +│ ├── contact-point-#1.yaml      *# Contact point definitions #1*<br> | 
|  | 36 | +│ ├── ...<br> | 
|  | 37 | +│ └── [contact-point-#p.yaml](#contact-point-pyaml)      *# Contact point definitions #p*<br> | 
|  | 38 | + | 
|  | 39 | +### grafana-dashboards.yaml | 
|  | 40 | + | 
|  | 41 | +This file contains the list of dashboards to be made available on start of the docker image. Each entry in the providers list defines a new dashboard. | 
|  | 42 | + | 
|  | 43 | +### dashboard-#n.json | 
|  | 44 | + | 
|  | 45 | +An example of a dashboard, that must be included in the [grafana-dashboards.yaml](#grafana-dashboardsyaml). Each dashboard is defined in a separate JSON file | 
|  | 46 | + | 
|  | 47 | +Official documentation for dashboard provisioning available [here](https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards). | 
|  | 48 | + | 
|  | 49 | +### alert-#m.yaml | 
|  | 50 | + | 
|  | 51 | +An example of an alert. Alerts are defined in yaml files. | 
|  | 52 | + | 
|  | 53 | +Official documentation for alert provisioning available [here](https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/#import-alert-rules). | 
|  | 54 | + | 
|  | 55 | +### contact-point-#p.yaml | 
|  | 56 | + | 
|  | 57 | +An example of a contact point. Contact points are defined in yaml files. | 
|  | 58 | + | 
|  | 59 | +Official documentation for contact point provisioning available [here](https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/#import-contact-points). | 
|  | 60 | + | 
|  | 61 | +## Usage Explanation | 
|  | 62 | + | 
|  | 63 | +To customize the available dashboards, alerts and contact points, there are some files that require creation or modification. To create these elements there are 2 possible options: | 
|  | 64 | + | 
|  | 65 | +- Read the [official documentation](https://grafana.com/docs/grafana/latest/) (less intuitive). | 
|  | 66 | +- Initiate the docker image, create the element and export it (more interactive). | 
|  | 67 | + | 
|  | 68 | +In this explanation, we will provide a step-by-step tutorial on how to create a [dashboard](#dashboard-creation), an [alert rule](#alert-rule-creation) or a [contact point](#contact-point-creation) with the help of Grafana's built-in tools (the second option). | 
|  | 69 | + | 
|  | 70 | +### Dashboard Creation | 
|  | 71 | + | 
|  | 72 | +1. Go to the [`test file`](../src/test/typescript/integration/monitoring/functionality.test.ts) for monitoring and comment the lines that call the function `stopDockerComposeService`. | 
|  | 73 | + | 
|  | 74 | +2. Run the test using `npx jest ./packages/cactus-plugin-satp-hermes/src/test/typescript/integration/monitoring/functionality.test.ts` from the project root. | 
|  | 75 | + | 
|  | 76 | +*Note: This is done to make the metrics appear in Grafana, facilitating the process of creation.* | 
|  | 77 | + | 
|  | 78 | +3. Login into Grafana using the following [link](http://localhost:3000/login) using `admin` as both *username* and *password*. | 
|  | 79 | + | 
|  | 80 | +*Note: You might require to change the address in case it is not running on localhost.* | 
|  | 81 | + | 
|  | 82 | +4. Access the Grafana dashboard endpoint using the following [link](http://localhost:3000/dashboards). | 
|  | 83 | + | 
|  | 84 | +*Note: You might require to change the address in case it is not running on localhost.* | 
|  | 85 | + | 
|  | 86 | +5. Click the `New` button and then the `New dashboard` button. | 
|  | 87 | + | 
|  | 88 | +6. Click the `Add visualization` and select a data source for the data visualization. | 
|  | 89 | + | 
|  | 90 | +7. Configure the panel with the desired data. | 
|  | 91 | + | 
|  | 92 | +8. Click `Save dashboard`, name the dashboard and click `Save`. | 
|  | 93 | + | 
|  | 94 | +9. If more panels are desired, click `Add` and then `Visualization`. Redo step 7 and 8. | 
|  | 95 | + | 
|  | 96 | +10. After all panels are added, click `Exit edit` and then, `Export` followed by `Export as code`. | 
|  | 97 | + | 
|  | 98 | +11. Click `Download file`, then move the file to the folder `grafana/provisioning/dashboards/` inside the package for the SATP-Hermes project. | 
|  | 99 | + | 
|  | 100 | +12. On the file [grafana-dashboards.yaml](./provisioning/dashboards/grafana-dashboards.yaml), create a new entry by copying an existing example one and change the path to have the name of the new dashboard and change the property name of the dashboard itself. | 
|  | 101 | + | 
|  | 102 | +13. Kill the running docker image for the container regarding otel-lgtm, rerun the test from step 2 and check if the dashboard is automatically provisioned. | 
|  | 103 | + | 
|  | 104 | +14. Go to the [`test file`](../src/test/typescript/integration/monitoring/functionality.test.ts) for monitoring and uncomment the commented lines that call the function `stopDockerComposeService`. | 
|  | 105 | + | 
|  | 106 | +### Contact Point Creation | 
|  | 107 | + | 
|  | 108 | +*Note: This section appears before alert creation since alerts rely on the existence of established contact points.* | 
|  | 109 | + | 
|  | 110 | +1. Access the Grafana dashboard endpoint using the following [link](http://localhost:3000/alerting/notifications). | 
|  | 111 | + | 
|  | 112 | +*Note: You might require to change the address in case it is not running on localhost.* | 
|  | 113 | + | 
|  | 114 | +2. Click the `Create contact point` button. | 
|  | 115 | + | 
|  | 116 | +3. Browse the integration options, selecting the one that better suits the use case (eg. discord, email, etc.). | 
|  | 117 | + | 
|  | 118 | +4. Fill the name of the contact point and the specific details of the integration option. | 
|  | 119 | + | 
|  | 120 | +5. Click `Test` to assess the correct functioning of the contact point. | 
|  | 121 | + | 
|  | 122 | +6. Click `Save contact point`. | 
|  | 123 | + | 
|  | 124 | +7. Click `More` on the newly created contact point, followed by `Export`. | 
|  | 125 | + | 
|  | 126 | +8. Click `Download`, then move the file to the folder `grafana/provisioning/alerting/` inside the package for the SATP-Hermes project. | 
|  | 127 | + | 
|  | 128 | +### Alert Rule Creation | 
|  | 129 | + | 
|  | 130 | +1. Go to the [`test file`](../src/test/typescript/integration/monitoring/functionality.test.ts) for monitoring and comment the lines that call the function `stopDockerComposeService`. | 
|  | 131 | + | 
|  | 132 | +2. Run the test using `npx jest ./packages/cactus-plugin-satp-hermes/src/test/typescript/integration/monitoring/functionality.test.ts` from the project root. | 
|  | 133 | + | 
|  | 134 | +*Note: This is done to make the metrics appear in Grafana, facilitating the process of creation.* | 
|  | 135 | + | 
|  | 136 | +3. Access the Grafana dashboard endpoint using the following [link](http://localhost:3000/alerting/list). | 
|  | 137 | + | 
|  | 138 | +*Note: You might require to change the address in case it is not running on localhost.* | 
|  | 139 | + | 
|  | 140 | +4. Click the `New alert rule` button. | 
|  | 141 | + | 
|  | 142 | +5. Fill in the name and select the metric to track. | 
|  | 143 | + | 
|  | 144 | +6. Configure the threshold that should trigger the alarm. | 
|  | 145 | + | 
|  | 146 | +7. Select the folder for your rule or click `New folder` to create a new one, giving it a name and clicking `Create`. | 
|  | 147 | + | 
|  | 148 | +8. Select the evaluation group for your rule (periodicity of evaluation) or click `New evaluation group` to create a new one, giving it a name and an evaluation interval, and clicking `Create`. | 
|  | 149 | + | 
|  | 150 | +9. Select the contact point (if none is defined, check its corresponding [section](#contact-point-creation)). | 
|  | 151 | + | 
|  | 152 | +10. (Optional) Configure the notification message. | 
|  | 153 | + | 
|  | 154 | +11. Click `Save`. | 
|  | 155 | + | 
|  | 156 | +12. Click `More` on the newly created alert rule, followed by `Export` and `With modifications`. | 
|  | 157 | + | 
|  | 158 | +13. Scroll down and click `Export`. | 
|  | 159 | + | 
|  | 160 | +14. Click `Download`, then move the file to the folder `grafana/provisioning/alerting/` inside the package for the SATP-Hermes project. | 
|  | 161 | + | 
|  | 162 | +15. Kill the running docker image for the container regarding otel-lgtm, rerun the test from step 2 and check if the alert is automatically provisioned. | 
|  | 163 | + | 
|  | 164 | +16. Go to the [`test file`](../src/test/typescript/integration/monitoring/functionality.test.ts) for monitoring and uncomment the commented lines that call the function `stopDockerComposeService`. | 
0 commit comments