grafana - ghdrako/doc_snipets GitHub Wiki
$ docker volume create grafana-storage
|$ docker run -d --name=grafana -p 3000:3000 \
-v grafana-storage:/var/lib/grafana grafana/Grafana
Core Grafana stack
The core Grafana stack consists of Mimir, Loki, Tempo, and Grafana; the acronym LGTM is often used to refer to this tech stack.
- Mimir is a Time Series Database (TSDB) for the storage of metric data. It uses low-cost object storage such as S3, GCS, or Azure Blob Storage. Mimir is a fully Prometheus-compatible solution thataddresses the common scalability problems encountered with storing and searching huge quantities of metric data.
- Loki is a set of components that offer a full feature logging stack. Loki uses lower-cost object storage such as S3 or GCS, and only indexes label metadata.
- Tempo is a storage backend for high-scale distributed trace telemetry, with the aim of sampling 100% of the read path. Tempo also offers the ability to generate metrics from spans as they are ingested; these metrics can be written to any backend that supports Prometheus remote write.
- Grafana Agent is a collection of tools for collecting logs, metrics, and traces.There are many other collection tools that Grafana integrates well with.
- Grafana Faro is a JavaScript agent that can be added to frontend web applications. The project allows for real user monitoring (RUM) by collecting telemetry from a browser.
- k6 is a load testing tool that provides both a packaged tool
Grafana actually requires a SQL database to store things like settings, user account information, dashboard layouts, and other configuration data. One way that Grafana stays self-contained is by shipping with a lightweight file-based database called SQLite.
Connecting Grafana to a Data Source
version: ‘3’
services:
grafana:
image: “grafana/grafana:${GRAF_TAG-latest}”
ports:
- “3000:3000”
volumes:
- “${PWD-.}/grafana:/var/lib/grafana”
prometheus:
image: “prom/prometheus:${PROM_TAG-latest}”
ports:
- “9090:9090”
volumes:
- “${PWD-.}/prometheus:/etc/prometheus”
Visualization
- https://grafana.com/docs/grafana/latest/panels-visualizations/visualizations/
- Grafana visualizes data but doesn’t actually store it – it relies on external data sources to provide the actual data and a way to retrieve it.
- Time series panel is the most frequently used visualization in most Grafana deployments
Data sources
A data source in Grafana is a plugin that provides a connection to the application or service that contains the data. It’s important to note that data sources must provide a query interface in order for Grafana to retrieve data. It has to provide some sort of API or interface that lets you ask for the specific data you want.
Data sources allow query data but also format the results of your query in a way that Grafana can understand. Grafana expects all data to be formatted in a single, specific way regardless of how the data is actually stored or formatted originally. So the data source plugin has to take the source data and manipulate it so that it matches the format that Grafana expects. The internal format Grafana uses to represent data is called a data frame, which is based on the Apache Arrow project.
Types of data sources: • Time series databases: InfluxDB, Prometheus, Graphite • Relational databases: MySQL, PostgreSQL • Logs: Loki, Elasticsearc
Prometheus - Prometheus exposes its metric query interface via HTTP, by default on port 9090.
Dashboards
- https://grafana.com/grafana/dashboards/
- https://play.grafana.org/ - przyklady dashbordow
Plugins
Monitoring Linux
- https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/
- https://medium.com/@mefengl/unknown-title-95cb5a15ce83
- https://github.com/mefengl/example-monitoring
Monitoring Postgres
- https://blog.devgenius.io/how-to-setup-grafana-with-postgresql-database-using-docker-compose-a-step-by-step-guide-e5a9cce90ba3
- https://github.com/guedim/grafana-postgres/blob/master/Readme.md
- https://www.linkedin.com/pulse/data-driven-database-management-monitoring-postgresql-pankaj-salunkhe
- https://fatdba.com/2021/03/24/how-to-monitor-your-postgresql-database-using-grafana-prometheus-postgres_exporter/
JVM monitoring
- https://stl.tech/blog/monitor-jvm-metrics-in-a-cloud-native-environment/
- https://betterprogramming.pub/how-to-monitor-a-spring-boot-app-with-prometheus-and-grafana-22e2338f97fc
- https://wkrzywiec.medium.com/how-to-set-up-monitoring-tools-for-java-application-322d14c191e4
- https://medium.com/@KisharaBuddika/monitoring-jvm-metrics-using-grafana-elasticsearch-telegraf-a543b0bbdb8