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 is tailored for GreptimeDB: it provides better GreptimeDB SQL query support, plus Logs and Traces query types with OpenTelemetry presets and configurable column mappings. It is modified from the ClickHouse data source plugin.

Installation

The plugin is not published in the Grafana plugin catalog, so install the unsigned archive and allow it explicitly in grafana.ini:

[plugins]
allow_loading_unsigned_plugins = info8fcc-greptimedb-datasource

GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS is the equivalent environment variable. Grafana Cloud does not accept unsigned plugins, so use a self-hosted Grafana. If you need a signed build bound to your own Grafana root_url, contact us.

Make sure Grafana is installed and running before installing the plugin.

You can choose one of the following installation methods:

  • Download info8fcc-greptimedb-datasource-unsigned.zip from the release page and unzip it 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-unsigned.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

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 Settings

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

SettingDescription
DatabaseSelect the database.
TableSet the table.

Every Builder panel automatically includes a Within Dashboard Time Range filter. This generates $__timeFilter("col") in the SQL, which the plugin expands to the dashboard's current time range.

DB Table Config


Table Query

Choose the Table query type when your query results do not include a time column. 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


Time Series Query

Select the Time Series query type when your query includes a time column and numerical values. Ideal for visualizing metrics over time.

Time bucketing with date_bin

For aggregating metrics over a time range, use date_bin to downsample time series data: it calculates time intervals and returns the start of the interval nearest to each timestamp, so rows are grouped into time-based bins (windows). Apply an aggregate or selector function to each window.

Example (or raw SQL):

SELECT date_bin('$__interval', timestamp) AS time,
SUM(`span_attributes.gen_ai.usage.input_tokens`) AS input_tokens
FROM opentelemetry_traces
WHERE $__timeFilter(timestamp)
GROUP BY time
ORDER BY time;

$__interval follows the Grafana panel interval; $__timeFilter limits the dashboard time range. See SQL Macros for more macros.

SettingDescription
TimeSelect the time column.
ColumnsSelect label columns (e.g. host, region).
Aggregate functionsAVG / MAX / MIN / SUM / COUNT on value columns.
Group BySelect columns to group by.
FiltersOptional conditions: =, !=, >, <, LIKE, IN, IS NULL, AND/OR.

Time Series

Multi-Frame Splitting

When the query result contains time + string + number fields, the plugin automatically splits the long table into multiple frames — one per unique label combination. Grafana renders each frame as a separate series in the chart.

For example, GROUP BY host with three hosts produces three frames (host-a, host-b, host-c), each with its own label and color.

To avoid splitting, use the Table query type instead.


Logs Query

Choose the Logs query type for log data.

SettingDescription
TimeSelect the timestamp column.
MessageSelect the column containing the log content.
Log Level(Optional) Select the column for log severity.
Context ColumnsExtra columns shown when you expand a log line (from data source config).

Logs

Full-text search: use matches_term(body, 'keyword') for exact term/phrase matching.

Logs Context Query

Performs an approximate time range query based on the value of context columns in a log row.

  • First, set the context column in Connection Page. Context Config
  • Then, when making a query, include the context column in the query. Query Config

Traces Query

Select the Traces query type for 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: nanoseconds
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

Attribute Auto-Discovery

When the Trace ID query uses SELECT *, the plugin automatically discovers all columns starting with span_attributes. and resource_attributes. and includes them as expandable tags in the waterfall view. No need to manually enumerate every attribute column.

SQL Macros

Use these macros in raw SQL mode. The plugin expands them to GreptimeDB-compatible SQL.

Time Range

MacroExpands To
$__timeFilter(col)"col" >= 'ISO' AND "col" <= 'ISO'
$__timeFilter_ms(col)Same (ms precision)
$__fromTimeStart time as ISO string
$__toTimeEnd time as ISO string
$fromTime_msStart time as ms ISO string
$toTime_msEnd time as ms ISO string

Time Interval

MacroExpands To
$__timeInterval(col)date_bin('<interval>', "col")
$__timeInterval_ms(col)date_bin('<interval>', "col") (ms)
$__intervalPanel interval literal (e.g. 15s)
$interval_sPanel interval in seconds (e.g. 15)

Date Filters

MacroExpands To
$__dateFilter(col)"col" >= 'YYYY-MM-DD' AND "col" <= 'YYYY-MM-DD'
$__dateTimeFilter(dc, tc)Date + time combined filter
$__dt(dc, tc)Alias for $__dateTimeFilter

Special

MacroExpands To
$__conditionalAll(col)All selected → 1=1; otherwise → col IN (values)

Identifier Quoting

The plugin automatically adds double quotes around column names in macros. $__timeFilter(timestamp) and $__timeFilter("timestamp") both expand to "timestamp" >= 'ISO1' AND "timestamp" <= 'ISO2'. The date_bin function does NOT quote its column argument: date_bin('15s', ts).

Native Grafana alerting

The plugin evaluates queries on the backend, so the same panel SQL—including time macros such as $__timeFilter—can be used directly in a Grafana alert rule.

Configuring Column Mappings

Before using the Logs or Traces query types, configure the default column names in the data source settings so the Query Builder can automatically map them. The examples below follow OpenTelemetry conventions; if your schema differs, map the fields to your own column names.

Logs Config

FieldPurposeExample (OTel)
Default TableDefault log tablegenai_conversations
Time ColumnTimestamp columntimestamp
Message ColumnLog body columnbody
Level ColumnLog severity/level columnseverity_text
Trace ID ColumnTrace ID for linkingtrace_id
Context ColumnsExtra columns shown on log line expandscope_name, trace_id

Enable Select context columns to automatically include them in log queries.

Traces Config

FieldPurposeExample (OTel)
Default TableDefault trace tableopentelemetry_traces
Trace ID ColumnTrace IDtrace_id
Span ID ColumnSpan IDspan_id
Parent Span ID ColumnParent Span IDparent_span_id
Service Name ColumnService nameservice_name
Operation Name ColumnSpan/operation namespan_name
Duration ColumnDuration valueduration_nano
Duration UnitUnit of duration columnnanoseconds
Start Time ColumnSpan start timetimestamp
Tags ColumnSpan attributes prefixspan_attributes
Service Tags ColumnResource attributes prefixresource_attributes

OTel Preset

If your table follows OpenTelemetry conventions, enable Use OTel and select a version. All column fields above are filled automatically. You can toggle OTel on/off in both the data source config and the Query Builder panel editor.

When OTel is enabled, the OTel preset uses GreptimeDB-style lowercase underscore column names (e.g. trace_id not TraceId), since GreptimeDB does not preserve case.

Full OTel 1.29.0 column map:

HintColumn
Timetimestamp
LogLevelseverity_text
LogMessagebody
TraceIdtrace_id
TraceSpanIdspan_id
TraceParentSpanIdparent_span_id
TraceServiceNameservice_name
TraceOperationNamespan_name
TraceDurationTimeduration_nano
TraceTagsspan_attributes
TraceServiceTagsresource_attributes
TraceStatusCodespan_status_code
TraceEventsPrefixspan_events

Included Dashboards

The plugin ships with two dashboards. After you configure a GreptimeDB data source:

  1. Open Connections → Data sources → your GreptimeDB instance
  2. Open the Dashboards tab
  3. Click Import next to a dashboard

Included dashboards:

  • GreptimeDB - OTel Min Demo
  • GenAI Observability

GenAI Observability

Sample data for these dashboards can be written into GreptimeDB via the genai-observability demo in demo-scene.

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.