smart-energy-monitor/software/dashboard/README.md

39 lines
1.4 KiB
Markdown
Raw Normal View History

2023-02-23 17:13:02 +01:00
# Grafana
2023-02-23 17:36:30 +01:00
Grafana is an open source analytics and interactive visualization tool. It provides charts, graphs, and alerts for the web when connected to supported data sources.
2023-02-23 17:17:18 +01:00
As a visualization tool, Grafana is a popular component in monitoring stacks, often used in combination with time series databases such as InfluxDB.
## Connection
2023-02-23 17:33:15 +01:00
To connect Grafana to our Influx-DB, you have to create a data source.
2023-02-24 15:50:24 +01:00
The `URL`of our InfluxDB is `http://influxdb:8086`.
In InfluxDB you have to create a `token` to connect: [Load Data -> API Tokens](http://localhost:8086/orgs/721027680173bf2f/load-data/tokens).
2023-02-23 17:33:15 +01:00
![Influx Create Token](../flow/docs/images/influx-create-token.png)
2023-02-23 17:17:18 +01:00
2023-02-23 17:37:48 +01:00
You can use this token to [create a connection from Grafana to Influx-DB](http://localhost:3000/datasources/).
2023-02-23 17:17:18 +01:00
![Connection](./docs/images/database-connection.png)
2023-02-23 17:28:54 +01:00
After having a connection to a database you can easily create an own dashboard in Grafana.
2023-02-23 17:27:22 +01:00
2023-02-23 17:38:28 +01:00
Here's the demo snippet (directly copyied from Influx Data Explorer) and the screen shot.
2023-02-23 17:27:22 +01:00
```
from(bucket: "test")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "msg")
|> filter(fn: (r) => r["_field"] == "value")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
```
![Example Dashboard](./docs/images/grafana-example-dashboard.png)
2023-02-24 15:50:24 +01:00
## CSV Import
2023-02-23 17:27:22 +01:00
2023-02-24 15:50:24 +01:00
See [CSV Import](./docs/csv-import.md).