What is Grafana

Grafana is a multi-platform open supply analytics and interactive visualization software package accessible since 2014. It provides charts, graphs, and alerts for the online once connected to supported information sources. It’s expandable through a plug-in system.

Setting up the Grafana

As the Prometheus server is installed and ready, we will now set-up Grafana. Grafana is a graphic interface with a dashboard which supports Prometheus as a back-end to query for the data to generate the graph.

Grafana stores the data in the form of SQL based databases, Grafana supports SQLite3, MySQL or PostgreSQL for this.

Launching Grafana as a Docker container

docker run -d -p 3000:3000 -v ~/grafana_db:/var/lib/grafana grafana/grafana

Accessing

By default, Grafana will be listening on http://localhost:3000. The default login is “admin” / “admin” for both username and password.

Launching Grafana

Creating a Prometheus data source

To create a Prometheus data source:

1. Click on the Grafana logo to open the sidebar or configuration menu.

2. Now click on “Data Sources”(DS) in the sidebar.

3. After clicking on “Add New”.

4. Now select “Prometheus” as the type.

5. After that Set the appropriate Prometheus server URL (for example, http://localhost:9090/).

6. Now adjust other data source settings as desired (for example, turning the proxy access off).

7.Finally click “Add” to save the new data source.

The below shows an example data source configuration:

data source configuration

Creating a Prometheus graph

Follow the below steps adding a new Grafana graph. Then:

  1. Simply click the graph title, then click “Edit”.
  2. Now go under the “Metrics” tab, select your Prometheus data source (bottom right).
  3. Enter any expression for Prometheus into “Query” field. Use “Metric” field to lookup metrics via auto completion.
  4. For formatting the legend names of time series, use the “Legend format” input. For example, to show only the method and status labels of a returned query result, separated by a dash, you could use the legend format string {{method}} – {{status}}.

The following shows an example Prometheus graph configuration:

Prometheus graph configuration

Subscribe Now