Skip to main content
Version: Nightly

Grafana

GreptimeDB can be configured as a Grafana data source. You have the option to connect GreptimeDB with Grafana using one of three data sources: GreptimeDB, Prometheus, or MySQL.

GreptimeDB data source plugin

The GreptimeDB data source plugin (v2.0) is based on the ClickHouse data source and adds GreptimeDB-specific features. The plugin adapts perfectly to the GreptimeDB data model, thus providing a better user experience. In addition, it also solves some compatibility issues compared to using the Prometheus data source directly.

Installation

The GreptimeDB Data source plugin can currently only be installed on a local Grafana instance. Make sure Grafana is installed and running before installing the plugin.

You can choose one of the following installation methods:

  • Download the installation package and unzip it to the relevant directory: Grab the latest release from release page, Unzip the file to your grafana plugin directory.
  • Use grafana cli to download and install:
    grafana cli --pluginUrl https://github.com/GreptimeTeam/greptimedb-grafana-datasource/releases/latest/download/info8fcc-greptimedb-datasource.zip plugins install info8fcc
  • Use our prebuilt Grafana docker image, which ships the plugin by default: docker run -p 3000:3000 greptime/grafana-greptimedb:latest

Note that you may need to restart your grafana server after installing the plugin.

Connection settings

Click the Add data source button and select GreptimeDB as the type.

grafana-add-greptimedb-data-source

Fill in the following URL in the GreptimeDB server URL:

http://<host>:4000

In the Auth section, click basic auth, and fill in the username and password for GreptimeDB in the Basic Auth Details section (not set by default, no need to fill in).

  • User: <username>
  • Password: <password>

Then click the Save & Test button to test the connection.

General Query Settings

Before selecting any query type, you first need to configure the Database and Table to query from.

SettingDescription
DatabaseSelect the database you want to query.
TableSelect the table you want to query from.

DB Table Config


Table Query

Choose the Table query type when your query results do not include a time column. This is suitable for displaying tabular data.

SettingDescription
ColumnsSelect the columns you want to retrieve. Multiple selections are allowed.
FiltersSet conditions to filter your data.

Table Query


Metrics Query

Select the Time Series query type when your query results include both a time column and a numerical value column. This is ideal for visualizing metrics over time.

Main SettingDescription
TimeSelect the time column.
ColumnsSelect the numerical value column(s).

Time Series


Logs Query

Choose the Logs query type when you want to query log data. You'll need to specify a Time column and a Message column.

Main SettingDescription
TimeSelect the timestamp column for your logs.
MessageSelect the column containing the log content.
Log Level(Optional) Select the column representing the log level.

Logs


Traces Query

Select the Traces query type when you want to query distributed tracing data.

Main SettingDescription
Trace ModelSelect Trace Search to query a list of traces.
Trace Id ColumnDefault value: trace_id
Span Id ColumnDefault value: span_id
Parent Span ID ColumnDefault value: parent_span_id
Service Name ColumnDefault value: service_name
Operation Name ColumnDefault value: span_name
Start Time ColumnDefault value: timestamp
Duration Time ColumnDefault value: duration_nano
Duration UnitDefault value: nano_seconds
Tags ColumnMultiple selections allowed. Corresponds to columns starting with span_attributes (e.g., span_attributes.http.method).
Service Tags ColumnMultiple selections allowed. Corresponds to columns starting with resource_attributes (e.g., resource_attributes.host.name).

Traces

Prometheus data source

Click the "Add data source" button and select Prometheus as the type.

Fill in Prometheus server URL in HTTP:

http://<host>:4000/v1/prometheus

Click basic auth in the Auth section and fill in your GreptimeDB username and password in Basic Auth Details:

  • User: <username>
  • Password: <password>

Click Custom HTTP Headers and add one header:

  • Header: x-greptime-db-name
  • Value: <dbname>

Then click "Save & Test" button to test the connection.

For how to query data with PromQL, please refer to the Prometheus Query Language document.

MySQL data source

Click the "Add data source" button and select MySQL as the type. Fill in the following information in MySQL Connection:

  • Host: <host>:4002
  • Database: <dbname>
  • User: <username>
  • Password: <password>
  • Session timezone: UTC

Then click "Save & Test" button to test the connection.

Note that you need to use raw SQL editor for panel creation. SQL Builder is not supported due to timestamp data type difference between GreptimeDB and vanilla MySQL.

For how to query data with SQL, please refer to the Query Data with SQL document.