Grafana
Setting Up Grafana on Docker Compose
Introduction To Grafana
Grafana is an open-source platform that is used for monitoring and observibility. It allows you to query, visualise, alert on, and understand the metrics no matter where they are stored.
Why Choose Grafana?
Grafana is a popular choice, and there are several reasons for this:
-
Open-Source and Flexibility - Grafana is an open-source platfrom, which means it’s free to use and highly customisable. With a variety of custom plugins that can be used to connect to virtually any data source.
-
Wide Range of Data Sources - Grafana supports a variety of data sources, including Prometheus, InfluxDB, Elasticsearch, MySQL, and PostgreSQL, making Grafana versatile for different types fo data and use cases.
-
Powerful Visualisation - Grafana offers a wide range of visualisation options such as graphs, heat maps, and histograms. This helps in creating detailed and informative dashboards.
-
Alerting & Notifications - Grafana includes integrated alerting capabilities, providing the ability to setup notifications for various conditions. Alerts can be sent to multiple channels like email, Slack, and webhooks.
-
Scalability - Grafana can be deployed on-premises or used as a managed service through Grafana Cloud, making it scalable for both small and large organisations
-
Community & Support - Being Open-Source, Grafana has a large community of users and contributors. This means that there are plenty of resources, plugins, and community support to help get the most out of Grafana.
Overall, Grafana is a robust tool for monitoring and analysing data, making it a go-to choice for many organisations looking to gain insights from their data.
Docker Compose, Prometheus and Env Examples
The Docker Compose example below, shows OAuth
integration which is provided by Authentik but can be doing using other OAuth providers following Grafana’s documentation.
There is also the Grafana-DB, Prometheus and Node-Exporter referenced within the below configuration although these can be run as separate configurations; However, these are also services and integrations that Grafana is able to use and consume so these have been included into the configuration below:
Grafana
Prometheus
File is mapped as part of the above Docker Compose example, as prometheus.yml
. The configuration itself contains period scrapers for Traefik.
Env Example
Below is a sample Env file that is used by some of the applications in the Docker Compose example configuration above.
Start Grafana
Start Grafana by running the following command from within the folder / location where the docker compose file for Grafana has been stored.
Key Components of Docker Compose Configuration Explained
- Image - Specifies the Grafana server image and tag
- Ports - Exposes Grafana on specified port
- Volumes - For media files and custom templates
- Environment - Specific environment variables, that need to be passed into the Grafana container in order for it to function.
- Labels - Used by Traefik to provide external access to the service, once the service all its dependancies have been started are
"healthy" and Accessible
, Public Service Name and what provider to use to check and obtain for an SSL Certificate
Volumes
- Persistent Storage - The configuration above for Grafana is using a separate disk on the host specifically for the Logs and data that Grafana uses, creates and keeps for an historical overview. This is also done so space that Grafana requires does not affect other services that the host is currently running.