Difference between revisions of "Grafana"

From ArchWiki
Jump to navigation Jump to search
m (→‎Aggregate data: fixed style)
m (add ES interlanguage link)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Network monitoring]]
 
[[Category:Network monitoring]]
 
[[Category:Web applications]]
 
[[Category:Web applications]]
 +
[[es:Grafana]]
 
[[ja:Grafana]]
 
[[ja:Grafana]]
 +
[[pt:Grafana]]
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|Zabbix}}
 
{{Related|Zabbix}}
 
{{Related|Munin}}
 
{{Related|Munin}}
 
{{Related articles end}}
 
{{Related articles end}}
[https://grafana.com/ Grafana] is an open-source, general purpose dashboard and graph composer, which runs as a web application. It supports graphite, [[InfluxDB]] or opentsdb as backends.
+
[https://grafana.com/ Grafana] is an open-source, general purpose dashboard and graph composer, which runs as a web application. It supports {{pkg|graphite}}, [[InfluxDB]], [[Prometheus]] or opentsdb as backends.
  
 
== Installation ==
 
== Installation ==
Line 12: Line 14:
 
[[Install]] the {{pkg|grafana}} package.
 
[[Install]] the {{pkg|grafana}} package.
  
After that you can [[Enable]] and [[start]] the {{ic|grafana}} service and access the application on localhost, e.g.: http://127.0.0.1:3000 . The default username is {{ic|admin}} and password {{ic|admin}} to access the web frontend.
+
After that you can [[enable]] and [[start]] {{ic|grafana.service}} and access the application on localhost, e.g.: http://127.0.0.1:3000 . The default username is {{ic|admin}} and password {{ic|admin}} to access the web frontend.
  
 
{{Warning|The default configuration listens on {{ic|*:3000}} so make sure to change the configuration or enable the relevant firewall rules.}}
 
{{Warning|The default configuration listens on {{ic|*:3000}} so make sure to change the configuration or enable the relevant firewall rules.}}
Line 20: Line 22:
 
=== Influxdb installation ===
 
=== Influxdb installation ===
  
One often used backend is [[InfluxDB]].
+
One often used backend is [[InfluxDB]]. [[Enable]] and [[start]] {{ic|influxdb.service}}. The web interface is available at http://localhost:8086/
[[Enable]] and [[start]] the {{ic|influxdb}} service. The web interface is available at http://localhost:8086/
 
  
 
=== Aggregate data ===
 
=== Aggregate data ===
In case of scaleable server monitoring in combination with Grafana and InfluxDB, one could choose software like [[collectd]] or [[statsd]]. More generally any measurement data can be aggregated with InfluxDB and displayed with Grafana. There are modules and libraries for several programming languages to interact with InfluxDB and one could even store data with a simple http post command using the program [[curl]].
 
  
Herefore, create a database named {{ic|example}}:
+
In case of scaleable server monitoring in combination with Grafana and InfluxDB, one could choose software like {{pkg|collectd}} or {{aur|statsd}}. More generally any measurement data can be aggregated with InfluxDB and displayed with Grafana. There are modules and libraries for several programming languages to interact with InfluxDB and one could even store data with a simple http post command using the program {{pkg|curl}}.
  <nowiki>curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE example"</nowiki>
+
 
Post data into the example database:
+
Herefore, create a database named {{ic|''example''}}:
  <nowiki>curl -i -XPOST 'http://localhost:8086/write?db=example' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'</nowiki>
+
 
 +
  <nowiki>curl -G http://localhost:8086/query</nowiki> --data-urlencode "q=CREATE DATABASE ''example''"
 +
 
 +
Post data into the {{ic|''example''}} database:
 +
 
 +
  <nowiki>curl -i -XPOST 'http://localhost:8086/write?</nowiki>db=''example''' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
  
 
=== Creating Grafana dashboard ===
 
=== Creating Grafana dashboard ===
 +
 
* Before creating a dashboard, we have to add a data source. So first click on {{ic|Data sources}} in the left menu and then on {{ic|Add new}}.
 
* Before creating a dashboard, we have to add a data source. So first click on {{ic|Data sources}} in the left menu and then on {{ic|Add new}}.
* Name can be something like {{ic|influxdb}} and the type should be set to {{ic|InfluxDB 0.9}}. In this example, the url for the Http settings is {{ic|http://localhost:8086}}. Note that the port is not the same as the one of the web interface! Database name corresponds to the one earlier choosen, e.g. {{ic|example}}. If not changed, username and password are {{ic|root}}.
+
* Name can be something like {{ic|influxdb}} and the type should be set to {{ic|InfluxDB 0.9}}. In this example, the url for the Http settings is {{ic|http://localhost:8086}}. Note that the port is not the same as the one of the web interface! Database name corresponds to the one earlier chosen, e.g. {{ic|example}}. If not changed, username and password are {{ic|root}}.
 
* Click on {{ic|Test connection}} to see everything is working and then on {{ic|Save}}.
 
* Click on {{ic|Test connection}} to see everything is working and then on {{ic|Save}}.
 
* Next, back at the front page, click {{ic|Home}} in the left-upper corner and then on {{ic|New}}.
 
* Next, back at the front page, click {{ic|Home}} in the left-upper corner and then on {{ic|New}}.

Latest revision as of 15:35, 21 November 2019

Grafana is an open-source, general purpose dashboard and graph composer, which runs as a web application. It supports graphite, InfluxDB, Prometheus or opentsdb as backends.

Installation

Install the grafana package.

After that you can enable and start grafana.service and access the application on localhost, e.g.: http://127.0.0.1:3000 . The default username is admin and password admin to access the web frontend.

Warning: The default configuration listens on *:3000 so make sure to change the configuration or enable the relevant firewall rules.

Example usage

Influxdb installation

One often used backend is InfluxDB. Enable and start influxdb.service. The web interface is available at http://localhost:8086/

Aggregate data

In case of scaleable server monitoring in combination with Grafana and InfluxDB, one could choose software like collectd or statsdAUR. More generally any measurement data can be aggregated with InfluxDB and displayed with Grafana. There are modules and libraries for several programming languages to interact with InfluxDB and one could even store data with a simple http post command using the program curl.

Herefore, create a database named example:

curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE example"

Post data into the example database:

curl -i -XPOST 'http://localhost:8086/write?db=example' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'

Creating Grafana dashboard

  • Before creating a dashboard, we have to add a data source. So first click on Data sources in the left menu and then on Add new.
  • Name can be something like influxdb and the type should be set to InfluxDB 0.9. In this example, the url for the Http settings is http://localhost:8086. Note that the port is not the same as the one of the web interface! Database name corresponds to the one earlier chosen, e.g. example. If not changed, username and password are root.
  • Click on Test connection to see everything is working and then on Save.
  • Next, back at the front page, click Home in the left-upper corner and then on New.
  • Now this might be a bit counter-intuitive, but to add a new dashboard you have to hover and click over the little green box on the left side and then, for example, choose: Add panel and Graph.
  • Click on the title of the new graph and select Edit.
  • In the graph settings in Metrics choose influxdb as data source in the lower-right corner.
  • Create a query by selecting your aggregated data. Click on select measurement which is located beside FROM. In the dropdown menu should appear a list of "tables" in your database, e.g. the table named localhost. If no suggestions comes up, your connection to InfluxDB might be broken or no data has been aggregated yet.
  • Beside the bold text SELECT click on value and choose for example the measurement data uptime.
  • To save changes, click Back to dashboard, then the floppy disc icon.