Skip to main content

Dashboards

Build Grafana dashboards to explore logs, traces, and metrics stored in a VeloDB Cloud warehouse. Grafana uses a MySQL data source to query the telemetry tables. The data path is:

Applications / infrastructure -> OpenTelemetry Collector with Doris exporter
-> VeloDB Cloud warehouse <- Grafana MySQL data source

Prerequisites​

Before you start:

  • Deploy the Collector and Grafana and verify that telemetry reaches the warehouse. See Quick Start.
  • Configure the receivers for the data you want to visualize. The OTLP demo does not automatically populate host, JVM, Kubernetes, Nginx, or PostgreSQL monitoring data.
  • Have a warehouse SQL user with read access to the telemetry tables. Use a read-only account for Grafana.
  • Make sure Grafana can reach the warehouse MySQL endpoint and meet its TLS requirements. Copy the host and port from Connect in the VeloDB Cloud console. See Connection Methods.

If you have not configured a data source:

  1. In Grafana, click Connections > Data sources > Add data source.
  2. Select MySQL.
  3. Enter the warehouse MySQL host and port, the telemetry database (otel in this guide), and the read-only SQL credentials. Configure the TLS options required by the warehouse.
  4. Click Save & test to confirm the connection.

The demo names this data source Doris. That name identifies the integration, while the connection points to VeloDB Cloud. The examples below use the otel database and the exporter's default table names. Adjust them if your configuration uses different names.

Configure MySQL data source

Import prebuilt dashboards​

The AIObserve Stack dashboard directory provides dashboard JSON files for common observability scenarios. Check the directory in your repository revision for the available files:

DashboardFileWhat it monitors
Host Metricshost_metrics_dashboard.jsonCPU, memory, disk, network, system load
JVM Monitoringjvm_metrics_dashboard.jsonHeap memory, GC, threads, CPU utilization
K8s Observabilityk8s_kubelet_dashboard.jsonPod / Node / Namespace resource usage
Nginx Logsnginx_logs_dashboard.jsonRequests, status codes, top URLs, error logs
PostgreSQL Metricspostgresql-metrics-dashboard.jsonConnections, transactions, DB size, Checkpoint, BGWriter

To import a prebuilt dashboard:

  1. In Grafana's left-side menu, click Dashboards > New > Import.

  2. Click Upload dashboard JSON file and choose the JSON file under grafana-dashboard/.

  3. On the import page, select your warehouse MySQL data source.

  4. Click Import.

  5. Repeat these steps for other dashboards whose collectors you have configured.

Once imported, variable selectors such as service and namespace query their candidate values from the warehouse. Empty selectors usually mean that the required receiver has not populated the expected metrics, the schema differs, or the selected time range contains no data.

Per-dashboard panel details​

Host Metrics Dashboard

  • Overview: CPU usage, memory usage, 1-minute load, root disk usage
  • CPU: usage trend, usage by Mode
  • Memory: memory details (Total / Available / Free / Cached / Buffers), usage trend
  • System Load: 1 / 5 / 15-minute load, open file descriptors
  • Disk: disk space usage table, read/write throughput
  • Network: ingress/egress traffic, errors and packet drops

Host Metrics Dashboard

JVM Monitoring Dashboard

  • Overview: heap usage, Full GC count, CPU usage, thread count
  • Memory: heap and non-heap trends, with details for Old Gen, Eden, and Survivor pools
  • GC: time (Young / Old) and counts
  • Thread & CPU: thread count trend, CPU utilization

JVM Monitoring Dashboard

K8s Observability Dashboard

  • Pods: CPU (millicores), memory, Limit utilization, status table (with restart count and uptime)
  • Nodes: CPU / memory trends, status table
  • Namespaces: CPU / memory aggregates, status table

K8s Observability Dashboard

Nginx Logs Dashboard

  • Overview: requests, errors, 5xx / 4xx stats, status-code pie chart
  • Trends: request volume / error log trends
  • Analysis: Top URL, Top IP, HTTP method distribution, top error messages
  • Recent Logs: access / error log details

Nginx Logs Dashboard

PostgreSQL Metrics Dashboard

  • Connections: active connections (split by database), max connections
  • Transactions: commit rate, rollback count
  • Storage: database size (split by database), number of databases, number of tables
  • BGWriter: checkpoint count (scheduled / requested), buffer writes, BGWriter time

PostgreSQL Metrics Dashboard

Data model​

The Doris exporter stores each telemetry signal and metric type in a separate table. Query the table that contains the signal you need.

Tables​

A SQL metric query needs both a table and a metric-name predicate:

TableContentValue fieldQuery approach
otel_metrics_gaugeInstantaneous metricsvalueAggregate directly, e.g. AVG(value)
otel_metrics_sumSum metricsvalue, is_monotonic, aggregation_temporalityChoose rate or interval aggregation according to temporality
otel_metrics_histogramHistogramcount, sum, bucket_countsInterpret counts and sums according to temporality
otel_logsLogsbody, severity_textCOUNT aggregation or detail queries
otel_tracesTracesduration, span_nameSort or aggregate by duration

To determine which table holds a metric, replace <metric-name> with its name and run:

SELECT 'gauge' AS type, metric_name
FROM otel.otel_metrics_gauge
WHERE metric_name = '<metric-name>'
GROUP BY metric_name
UNION ALL
SELECT 'sum', metric_name
FROM otel.otel_metrics_sum
WHERE metric_name = '<metric-name>'
GROUP BY metric_name
UNION ALL
SELECT 'histogram', metric_name
FROM otel.otel_metrics_histogram
WHERE metric_name = '<metric-name>'
GROUP BY metric_name;

To browse all available metrics, run the following on each table:

SELECT DISTINCT metric_name FROM otel.otel_metrics_gauge ORDER BY metric_name;

Attribute fields​

OpenTelemetry attributes are stored in different VARIANT columns according to their scope. Use bracket syntax to extract a key:

TableFieldContentExample
metricsattributesMetric dimensions (Prometheus labels)attributes['mode']
metricsresource_attributesResource info (K8s pod/node, etc.)resource_attributes['k8s.pod.name']
logslog_attributesLog fieldslog_attributes['status']
tracesspan_attributesSpan fieldsspan_attributes['http.method']

service_name and service_instance_id are top-level columns in the metrics schema shown here. Use them directly, for example, WHERE service_name = 'checkout'. Inspect your schema before copying queries from a different exporter version.

Cast extracted attributes to the SQL type required by the expression, especially for grouping, window partitions, and string operations:

-- Extract a value in SELECT
CAST(attributes['device'] AS VARCHAR) AS device

-- Pattern match in WHERE
CAST(attributes['device'] AS VARCHAR) NOT LIKE 'veth%'

-- Numeric comparison in WHERE
CAST(log_attributes['status'] AS INT) >= 500

-- Use in GROUP BY
GROUP BY CAST(resource_attributes['k8s.pod.name'] AS VARCHAR)

For simple equality predicates, an attribute can also be compared directly:

WHERE attributes['mode'] = 'idle'

Note:

A missing key inside a VARIANT value returns NULL. An unknown top-level column, such as log_attributes in a metrics table without that column, causes a column-resolution error. Inspect both the table schema and attribute keys when troubleshooting.

Counter metrics and rate calculation​

Gauge values describe measurements at a point in time. Choose an aggregation that matches the measurement, such as AVG(value) for average utilization.

A sum metric can be cumulative or delta, and can be monotonic or non-monotonic. Do not assume that every row in otel_metrics_sum is a cumulative counter. Inspect the metric metadata first:

SELECT metric_name, aggregation_temporality, is_monotonic
FROM otel.otel_metrics_sum
WHERE metric_name = '<metric-name>'
GROUP BY metric_name, aggregation_temporality, is_monotonic;

Replace <metric-name> with your metric. Use the following rules:

Metric semanticsCalculation
Monotonic cumulative sumSubtract successive samples in the same series, then divide by elapsed time for a per-second rate. Handle resets and duplicate timestamps.
Delta sumEach sample already represents an interval. Aggregate intervals or divide by the corresponding interval length. Do not subtract successive delta values.
Non-monotonic sumValues may decrease. Choose an aggregation that matches the metric definition.
Cumulative histogramSubtract matching series' cumulative counts, sums, and buckets before calculating interval statistics.

For a cumulative counter, LAG() can calculate a rate from adjacent samples. This is a sample-to-sample calculation, without Prometheus rate() extrapolation. The first sample in a query window has no preceding sample, and the examples below return NULL across a counter reset.

A series must keep its source identity and every attribute that distinguishes it from another series. For example:

ScenarioSeries dimensions to preserve
CPU timeService, instance, CPU, and mode
Disk or network bytesService, instance, and device, plus any other labels emitted by the source
Garbage collection timeService, instance, and garbage collector name

Filtering to one host does not remove the need to separate devices, CPUs, or other dimensions on that host. The counter panel example shows this for a network metric.

Create a custom dashboard​

Add panels for gauge metrics, cumulative counters, single values, and log records, then use variables to filter the dashboard.

Add a gauge metric panel​

Create a time series panel for the k8s.pod.cpu.usage gauge. This metric requires a Kubernetes receiver configuration that collects pod CPU usage. Confirm that the metric and attributes exist in your tables first.

  1. In Grafana's left-side menu, click Dashboards > New > New dashboard.

  2. Click Add visualization.

  3. Choose your warehouse MySQL data source.

  4. Switch the query editor to Code mode.

Build the query in the following stages.

Write the base query. To monitor pod CPU, use the metric name k8s.pod.cpu.usage. It is a Gauge metric stored in otel_metrics_gauge, where value can be aggregated directly:

SELECT timestamp, value
FROM otel.otel_metrics_gauge
WHERE metric_name = 'k8s.pod.cpu.usage'

Add time filtering. Use either the time-filter macro or the dashboard time variables in SQL:

-- Option A: use the $__timeFilter macro (recommended)
WHERE metric_name = 'k8s.pod.cpu.usage'
AND $__timeFilter(timestamp)

-- Option B: use dashboard time variables
WHERE metric_name = 'k8s.pod.cpu.usage'
AND timestamp >= FROM_UNIXTIME($__from/1000)
AND timestamp < FROM_UNIXTIME($__to/1000)

$__from and $__to are millisecond timestamps. Divide by 1000 before using them in FROM_UNIXTIME().

Add time bucketing. To reduce the number of displayed points, aggregate them at a fixed interval. Use FLOOR(UNIX_TIMESTAMP(timestamp) / N) * N to round time to N-second buckets:

SELECT
FLOOR(UNIX_TIMESTAMP(timestamp) / 20) * 20 AS time,
AVG(value) AS value
FROM otel.otel_metrics_gauge
WHERE metric_name = 'k8s.pod.cpu.usage'
AND timestamp >= FROM_UNIXTIME($__from/1000)
AND timestamp < FROM_UNIXTIME($__to/1000)
GROUP BY time
ORDER BY time

Split into multiple series by dimension. The following examples use Grafana's three-column time series format:

ColumnPurpose
time or time_secX-axis time. Either a datetime value or a UNIX timestamp in seconds.
metricSeries name. Grafana splits into multiple lines by distinct values of this column.
valueY-axis value.

Combine namespace and pod name in metric to keep equally named pods in different namespaces separate. If you collect multiple Kubernetes clusters, also filter to one cluster or include cluster identity in the series:

SELECT
FLOOR(UNIX_TIMESTAMP(timestamp) / 20) * 20 AS time,
CONCAT(
CAST(resource_attributes['k8s.namespace.name'] AS VARCHAR), '/',
CAST(resource_attributes['k8s.pod.name'] AS VARCHAR)
) AS metric,
AVG(value) AS value
FROM otel.otel_metrics_gauge
WHERE metric_name = 'k8s.pod.cpu.usage'
AND timestamp >= FROM_UNIXTIME($__from/1000)
AND timestamp < FROM_UNIXTIME($__to/1000)
GROUP BY time, metric
ORDER BY time

To monitor a different Gauge metric, change:

  • metric_name: the target metric name.
  • The metric column: the dimension used to split series, chosen from attributes or resource_attributes.
  1. Paste the complete SQL into the query editor.

  2. Below the editor, set Format to Time series.

  3. Set a panel title.

  4. In Standard options > Unit, choose the unit reported by the metric.

  5. Apply or save the panel using the action in your Grafana version.

Add a counter metric panel​

For a monotonic cumulative counter, calculate a rate using the rules in Counter metrics and rate calculation. Confirm the metric temporality before using this query.

  1. On the dashboard, click Add > Visualization.
  2. Choose the data source and switch to Code mode.

The following example computes the receive byte rate for node_network_receive_bytes_total. It separates services, instances, and devices. It assumes these fields identify a series in your data. If the source emits other distinguishing attributes, include them in both window partitions and the displayed series name.

SELECT
t.timestamp AS time,
CONCAT(t.service_name, '/', t.service_instance_id, '/', t.device) AS metric,
CASE
WHEN UNIX_TIMESTAMP(t.timestamp) > UNIX_TIMESTAMP(t.prev_ts)
AND t.value >= t.prev_value
THEN (t.value - t.prev_value) / (UNIX_TIMESTAMP(t.timestamp) - UNIX_TIMESTAMP(t.prev_ts))
ELSE NULL
END AS value
FROM (
SELECT timestamp, service_name, service_instance_id,
CAST(attributes['device'] AS VARCHAR) AS device, value,
LAG(value) OVER (PARTITION BY service_name, service_instance_id,
CAST(attributes['device'] AS VARCHAR) ORDER BY timestamp) AS prev_value,
LAG(timestamp) OVER (PARTITION BY service_name, service_instance_id,
CAST(attributes['device'] AS VARCHAR) ORDER BY timestamp) AS prev_ts
FROM otel.otel_metrics_sum
WHERE metric_name = 'node_network_receive_bytes_total'
AND $__timeFilter(timestamp)
) t
WHERE t.prev_ts IS NOT NULL
ORDER BY time

To adapt the query:

  • Change metric_name to the target metric name.
  • Keep the complete series identity in PARTITION BY and the displayed series name.
  • Verify that is_monotonic is true and the source exports cumulative values.

Paste the query, select Time series as the format, choose the metric unit, and save the panel.

Add a Stat panel​

A Stat panel can show a single value such as available memory for one host. The query below selects the latest sample for a specific service instance. Replace <service-instance-id> with the target instance.

  1. Click Add > Visualization and switch to Code mode.

The following query gets the latest metric value within the time range:

SELECT value
FROM otel.otel_metrics_gauge
WHERE metric_name = 'node_memory_MemAvailable_bytes'
AND service_instance_id = '<service-instance-id>'
AND $__timeFilter(timestamp)
ORDER BY timestamp DESC
LIMIT 1

To combine multiple metrics, see Optimization tips.

  1. Paste the SQL and set Format to Table (Stat panels use Table format).
  2. In the right-side panel settings, change the panel type to Stat.
  3. In Standard options > Unit, choose an appropriate unit.
  4. Click Apply.

Add a Table panel​

A table panel displays multiple rows and columns. SQL column aliases become the column headers.

  1. Click Add > Visualization and switch to Code mode.

The following query shows recent log details:

SELECT
timestamp,
service_name,
severity_text,
body,
CAST(log_attributes['your_key'] AS VARCHAR) AS your_key
FROM otel.otel_logs
WHERE $__timeFilter(timestamp)
ORDER BY timestamp DESC
LIMIT 100

Replace your_key with the actual log attribute field name. To see the available attributes, run:

SELECT log_attributes FROM otel.otel_logs LIMIT 1;
  1. Paste the SQL and set Format to Table.
  2. Click Apply.

Add template variables​

Template variables add interactive dropdown filters to a dashboard, letting users filter data without modifying the SQL.

Create a single-select variable

  1. Open the dashboard settings, then select Variables > New variable.

  2. Set Name to service_name, Type to Query, and Data source to your warehouse data source.

  3. Enter the following query and save the variable:

    SELECT DISTINCT service_name
    FROM otel.otel_metrics_gauge
    WHERE service_name != ''
    AND service_name IS NOT NULL
    AND $__timeFilter(timestamp)
    ORDER BY service_name;

In a panel's SQL, use Grafana's sqlstring formatter to quote the selected value:

AND service_name = ${service_name:sqlstring}

Create a multi-select variable

  1. Create a query variable named namespace.

  2. Enable Multi-value and Include All option. Leave the custom all value empty so Grafana expands the list of available values.

  3. Enter this query and save the variable:

    SELECT DISTINCT
    CAST(resource_attributes['k8s.namespace.name'] AS VARCHAR) AS __text
    FROM otel.otel_metrics_gauge
    WHERE metric_name = 'k8s.pod.phase'
    AND $__timeFilter(timestamp)
    ORDER BY 1;

The __text alias controls the displayed dropdown text. Use IN with the sqlstring formatter in panel queries:

AND CAST(resource_attributes['k8s.namespace.name'] AS VARCHAR)
IN (${namespace:sqlstring})

Do not add another pair of quotes around ${namespace:sqlstring}. It expands to a comma-separated list of quoted values.

Create a cascading variable

To make pod choices depend on the selected namespace, create a pod query variable using:

SELECT DISTINCT
CAST(resource_attributes['k8s.pod.name'] AS VARCHAR) AS __text
FROM otel.otel_metrics_gauge
WHERE metric_name = 'k8s.pod.phase'
AND $__timeFilter(timestamp)
AND CAST(resource_attributes['k8s.namespace.name'] AS VARCHAR)
IN (${namespace:sqlstring})
ORDER BY 1;

Set time-dependent variables to refresh when the time range changes. If a dropdown is empty, check the metric name, resource attribute keys, and dashboard time range.

Optimization tips​

The following are common optimization techniques used in the prebuilt dashboards.

Adjust the time-bucket interval. Choose a bucket size that matches the time range. Modify N in FLOOR(UNIX_TIMESTAMP(timestamp) / N) * N:

  • 20 seconds: suited to short-window real-time monitoring.
  • 60 seconds: suited to hour-level overviews.
  • 300 seconds: suited to day-level trends.

Set meaningful series names. Use CONCAT() to combine multiple fields:

CONCAT(device, ' read') AS metric

Use CASE WHEN to map numeric values to readable text:

CASE WHEN value = 2 THEN 'Running'
WHEN value = 1 THEN 'Pending'
WHEN value = 3 THEN 'Succeeded'
WHEN value = 4 THEN 'Failed'
ELSE 'Unknown'
END AS status

Handle divide-by-zero and NULLs. Use NULLIF to guard against divide-by-zero and COALESCE to provide default values:

/ NULLIF(SUM(...), 0)
COALESCE(restarts, 0)

Query multiple metrics in one SQL. For metrics sampled at matching timestamps, conditional aggregation can combine values without a join. The following query assumes service_instance_id identifies each host. Filter or include additional identity columns if needed:

SELECT timestamp AS time, service_instance_id,
SUM(CASE WHEN metric_name = 'node_memory_MemAvailable_bytes' THEN value END) AS available,
SUM(CASE WHEN metric_name = 'node_memory_MemTotal_bytes' THEN value END) AS total
FROM otel.otel_metrics_gauge
WHERE metric_name IN ('node_memory_MemTotal_bytes', 'node_memory_MemAvailable_bytes')
AND $__timeFilter(timestamp)
GROUP BY timestamp, service_instance_id
ORDER BY time;

Filter out noise data. Exclude virtual network interfaces:

AND CAST(attributes['device'] AS VARCHAR) NOT LIKE 'veth%'
AND CAST(attributes['device'] AS VARCHAR) NOT LIKE 'br-%'
AND CAST(attributes['device'] AS VARCHAR) != 'lo'

Keep only real filesystems:

AND CAST(attributes['fstype'] AS VARCHAR) IN ('ext4', 'xfs', 'btrfs')

Reference​

OTel table schema​

The fields below describe the schema used by the examples. Exporter versions and custom table definitions can differ. Run DESCRIBE otel.otel_metrics_sum, DESCRIBE otel.otel_logs, or DESCRIBE otel.otel_traces in the warehouse to inspect the actual schema.

Metrics tables (gauge, sum, and histogram shared fields)

FieldTypeDescription
service_namevarchar(200)Service name
timestampdatetime(6)Data timestamp
service_instance_idvarchar(200)Service instance ID
metric_namevarchar(200)Metric name
metric_descriptionstringMetric description
metric_unittextMetric unit
attributesvariant (JSON)Metric dimensions
resource_attributesvariant (JSON)Resource attributes
scope_nametextInstrumentation scope name

gauge-only field: value (double)

sum extra fields: value (double), aggregation_temporality (text), is_monotonic (boolean)

histogram extra fields: count (bigint), sum (double), bucket_counts (array<bigint>), explicit_bounds (array<double>), min (double), max (double)

Logs table

FieldTypeDescription
timestampdatetime(6)Log timestamp
service_namevarchar(200)Service name
service_instance_idvarchar(200)Service instance ID
trace_idvarchar(200)Associated trace ID
span_idtextAssociated span ID
severity_numberintSeverity number
severity_texttextSeverity text (INFO / WARN / ERROR)
bodytextLog body
resource_attributesvariant (JSON)Resource attributes
log_attributesvariant (JSON)Log attributes

Traces table

FieldTypeDescription
timestampdatetime(6)Span start time
service_namevarchar(200)Service name
trace_idvarchar(200)Trace ID
span_idtextSpan ID
parent_span_idtextParent span ID
span_nametextSpan name
span_kindtextSpan kind (CLIENT / SERVER / INTERNAL)
end_timedatetime(6)Span end time
durationbigintDuration (nanoseconds)
span_attributesvariant (JSON)Span attributes
eventsarraySpan events
linksarraySpan links
status_codetextStatus code (OK / ERROR / UNSET)
status_messagetextStatus message
resource_attributesvariant (JSON)Resource attributes

Syntax cheat sheet​

PurposeSyntax
Time filter (macro)$__timeFilter(timestamp)
Time filter (manual)timestamp >= FROM_UNIXTIME($__from/1000)
Time bucket (20 seconds)FLOOR(UNIX_TIMESTAMP(timestamp) / 20) * 20 AS time
Time bucket (1 minute)FLOOR(UNIX_TIMESTAMP(timestamp) / 60) * 60 AS time
Attribute accessattributes['key']
Attribute CASTCAST(attributes['key'] AS VARCHAR)
Single-select variableservice_name = ${service_name:sqlstring}
Multi-select variableIN (${namespace:sqlstring})
Divide-by-zero guard/ NULLIF(..., 0)
Default valueCOALESCE(..., 0)
Series namingCONCAT(device, ' read') AS metric
Status mappingCASE WHEN value = 2 THEN 'Running' ... END
URL stripping query stringSUBSTRING_INDEX(url, '?', 1)
Filter out virtual network cardsNOT LIKE 'veth%' + NOT LIKE 'br-%' + != 'lo'

Common errors​

SymptomCheck and resolution
Data source connection failsVerify the warehouse endpoint, network path, read privileges, and required TLS settings from the Grafana host.
A panel is emptyWiden the time range and inspect the expected table, metric name, and attribute keys. Importing a dashboard does not configure its collectors.
Counter rates spike or become negativeConfirm cumulative temporality and monotonicity, preserve full series identity, and handle resets and duplicate timestamps.
Time series appears in the wrong periodGrafana's Unix time column uses seconds. Keep milliseconds only for $__from and $__to before conversion, and align Collector, database session, and Grafana timezone settings.
Multi-select filters cause SQL errorsUse ${variable:sqlstring} with IN (...) and inspect the expanded SQL in Grafana.

Query cost and cleanup​

Short refresh intervals, long time ranges, and many panels increase warehouse query load. Start with a narrow time range and adjust refresh intervals to your monitoring needs. See Billing.

Remove test dashboards and variables when you finish. Stop demo data producers separately. Deleting a dashboard does not remove the warehouse tables or stop ingestion.

See also​

Enter to send · Shift+Enter for a new line