Skip to content

Grafana

Grafana dashboards, panels, data sources, users, alerting and annotations as SQL, plus any data source query

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/grafana/index.md to help me query Grafana with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Count dashboards by folder

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT folder_path, count(*) AS dashboards
FROM grafana.main.dashboards
GROUP BY folder_path
ORDER BY dashboards DESC, folder_path

Quick start

Choose where to run Grafana, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'grafana' AS grafana (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-grafana'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

grafana credentials

Connection to a Grafana HTTP API (Grafana OSS, Enterprise or Grafana Cloud): base URL plus a service account token, API key or basic-auth login.

Get these credentials →
secret.sql
CREATE SECRET grafana (
    TYPE grafana,
    base_url  '<base_url>',
    token     '<GRAFANA_TOKEN>',  -- secret
    username  '<username>',
    password  '<GRAFANA_PASSWORD>',  -- secret
    org_id    '<org_id>',
    page_size '<page_size>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT folder_path, count(*) AS dashboards
FROM grafana.main.dashboards
GROUP BY folder_path
ORDER BY dashboards DESC, folder_path
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'grafana' AS grafana (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Grafana dashboards, panels and their queries, folders, data sources, users, teams, alerting and annotations as read-only SQL tables, plus ds_query to run any Grafana data source query from DuckDB.

ATTACH options

secret_name
Name of the grafana secret every table and function of this catalog reads (default: the session's grafana secret). Attach the worker once per Grafana instance, each with its own secret_name.VARCHAR

Catalog

Everything grafana exposes once attached — read straight from the worker's released build.

grafana 1 schema
main 24 tables · 4 functions

One Grafana organization as read-only SQL: content inventory, access, alerting, annotations and data source queries.

Schema examples (28)
Examples (28)

How many dashboards each folder holds

SELECT folder_path, count(*) AS dashboards
FROM grafana.main.dashboards
GROUP BY folder_path
ORDER BY dashboards DESC, folder_path;

The folder tree as paths

SELECT folder_path, depth FROM grafana.main.folders ORDER BY folder_path;

Which visualizations are used most

SELECT type, count(*) AS panels
FROM grafana.main.panels
WHERE type <> 'row'
GROUP BY type
ORDER BY panels DESC, type;

Every PromQL expression on any dashboard

SELECT dashboard_title, panel_title, expr
FROM grafana.main.panel_queries
WHERE datasource_type = 'prometheus' AND expr IS NOT NULL
ORDER BY dashboard_title, panel_title;
24 more examples

Who saves dashboards most

SELECT created_by, count(*) AS saves
FROM grafana.main.dashboard_versions
GROUP BY created_by
ORDER BY saves DESC, created_by;

Most reused library panels

SELECT name, type, folder_path, connected_dashboards
FROM grafana.main.library_panels
ORDER BY connected_dashboards DESC, name;

Data sources per plugin type

SELECT type, count(*) AS sources
FROM grafana.main.connections
GROUP BY type
ORDER BY sources DESC, type;

Everything whose title contains 'web'

SELECT kind, title, folder_path
FROM grafana.main.search(query := 'web')
ORDER BY kind, title;

Users per org role

SELECT role, count(*) AS users
FROM grafana.main.users
GROUP BY role
ORDER BY users DESC, role;

Largest teams

SELECT name, member_count
FROM grafana.main.teams
ORDER BY member_count DESC, name;

Who is in which team

SELECT team_name, login, is_admin
FROM grafana.main.team_members
ORDER BY team_name, login;

Enabled service accounts by token count

SELECT name, role, token_count
FROM grafana.main.service_accounts
WHERE NOT is_disabled
ORDER BY token_count DESC, name;

List organizations

SELECT org_id, name FROM grafana.main.orgs ORDER BY org_id;

Which Grafana version is running, and is its database up

SELECT grafana_version, database FROM grafana.main.health;

Active rules with their severity label

SELECT folder_path, rule_group, title, labels['severity'] AS severity
FROM grafana.main.alert_rules
WHERE NOT is_paused
ORDER BY folder_path, rule_group, title;

Which data sources alerting depends on

SELECT datasource_uid, count(DISTINCT rule_uid) AS rules
FROM grafana.main.alert_rule_queries
WHERE NOT is_expression
GROUP BY datasource_uid
ORDER BY rules DESC, datasource_uid;

Groups by evaluation frequency

SELECT folder_path, name, interval_seconds, rule_count
FROM grafana.main.rule_groups
ORDER BY interval_seconds, name;

Rules firing or pending now

SELECT rule_name, state, active_at
FROM grafana.main.alert_rule_states
WHERE state IN ('firing', 'pending')
ORDER BY active_at;

Integrations per type

SELECT type, count(*) AS integrations
FROM grafana.main.contact_points
GROUP BY type
ORDER BY integrations DESC, type;

The routing tree

SELECT path, depth, receiver, matchers
FROM grafana.main.notification_policies
ORDER BY path;

Mute timings and their weekdays

SELECT name, weekdays, interval_count
FROM grafana.main.mute_timings
ORDER BY name;

Active alerts, oldest first

SELECT alertname, labels['severity'] AS severity, starts_at
FROM grafana.main.alerts
WHERE state = 'active'
ORDER BY starts_at;

Active silences by expiry

SELECT created_by, comment, ends_at
FROM grafana.main.silences
WHERE state = 'active'
ORDER BY ends_at;

Which rules fired most often

SELECT rule_uid, count(*) AS transitions
FROM grafana.main.alert_state_transitions
WHERE current_state LIKE 'Alerting%'
GROUP BY rule_uid
ORDER BY transitions DESC, rule_uid;

Deploy annotations since a date (tag and window pushed to Grafana)

SELECT time, text, tags
FROM grafana.main.annotations
WHERE list_contains(tags, 'deploy') AND time >= TIMESTAMPTZ '2026-01-01 00:00:00+00'
ORDER BY time;

A TestData series: three values spread over the hour

SELECT ts, value
FROM grafana.main.ds_query('testdata', '{"scenarioId": "csv_metric_values", "stringInput": "1,20,90", "alias": "cpu"}', TIMESTAMPTZ '2026-01-01 00:00:00+00', TIMESTAMPTZ '2026-01-01 01:00:00+00')
ORDER BY ts;

Dashboards that auto-refresh most often

SELECT title, grafana.main.duration_seconds(refresh) AS refresh_seconds
FROM grafana.main.dashboards
WHERE refresh IS NOT NULL
ORDER BY refresh_seconds;

Panel links with any embedded credentials removed

SELECT title, grafana.main.redact_url(panel_json->>'$.links[0].url') AS link
FROM grafana.main.panels
WHERE panel_json->>'$.links[0].url' IS NOT NULL
ORDER BY title;
Tables
alert_rule_queries 2 examples14 cols

The queries and server-side expressions of every alert rule, one row each

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
rule_uidnot null VARCHAR
Rule UID (joins alert_rules.uid).
rule_title VARCHAR
Title of the alert rule the query belongs to.
ref_idnot null VARCHAR
Query or expression reference letter within the rule (A, B, ...).
datasource_uid VARCHAR
Data source UID ('__expr__' for an expression).
is_expression BOOLEAN
A server-side expression rather than a data source query.
expression_type VARCHAR
Expression type: reduce, math, threshold, resample, classic_conditions, sql; NULL for queries.
is_condition BOOLEAN
This refId is the rule's condition.
query_type VARCHAR
Query type, when the data source uses one.
expr VARCHAR
PromQL / LogQL expression, or an expression's expression field.
query_text VARCHAR
The query string, whichever field holds it (expr, rawSql, query, expression, ...).
relative_from_seconds DOUBLE
Query window start, in seconds before evaluation time.
relative_to_seconds DOUBLE
Query window end, in seconds before evaluation time.
model JSON
The query or expression model as JSON.
ConstraintsPRIMARY KEY (rule_uid, ref_id) · FOREIGN KEY (rule_uid) REFERENCES alert_rules(uid)
Examples (2)

Which data sources alerting depends on

SELECT datasource_uid, count(DISTINCT rule_uid) AS rules
FROM grafana.main.alert_rule_queries
WHERE NOT is_expression
GROUP BY datasource_uid
ORDER BY rules DESC, datasource_uid;

Each rule's query and expression chain

SELECT rule_title, ref_id, expression_type, query_text
FROM grafana.main.alert_rule_queries
ORDER BY rule_title, ref_id;
Link
alert_rule_states 2 examples16 cols

Evaluation state of every alert rule: firing, pending, recovering or inactive, health, last error and timings

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
rule_uidnot null VARCHAR
Rule UID (joins alert_rules.uid).
rule_name VARCHAR
Rule title.
rule_group VARCHAR
Group name.
folder_uid VARCHAR
UID of the rule's folder.
state VARCHAR
firing, pending, recovering or inactive.
health VARCHAR
ok, nodata or error.
last_error VARCHAR
Last evaluation error.
active_at TIMESTAMP WITH TIME ZONE
When the current alert became active.
last_evaluation TIMESTAMP WITH TIME ZONE
Last evaluation time.
evaluation_seconds DOUBLE
Duration of the last evaluation in seconds.
is_paused BOOLEAN
Evaluation is paused.
instance_count BIGINT
Number of alert instances.
queried_datasource_uids VARCHAR[]
Data sources the rule queried.
labels MAP(VARCHAR, VARCHAR)
Rule labels.
type VARCHAR
'alerting' or 'recording'.
ConstraintsPRIMARY KEY (rule_uid) · FOREIGN KEY (rule_uid) REFERENCES alert_rules(uid)
Examples (2)

Rules firing or pending now

SELECT rule_name, state, active_at
FROM grafana.main.alert_rule_states
WHERE state IN ('firing', 'pending')
ORDER BY active_at;

Rules that fail to evaluate

SELECT rule_name, last_error
FROM grafana.main.alert_rule_states
WHERE health = 'error'
ORDER BY rule_name;
Link
alert_rules 2 examples22 cols

Grafana-managed alert rules with folder, rule group, condition, pending period, no-data and error handling, labels, annotations and queries

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
uidnot null VARCHAR
Rule UID.
title VARCHAR
Rule title (the alertname label).
folder_uid VARCHAR
UID of the rule's folder.
folder_path VARCHAR
Folder chain of the rule, e.g. '/Alerts'.
rule_group VARCHAR
Evaluation group name.
condition VARCHAR
refId of the query or expression whose result fires the rule.
for_seconds DOUBLE
Pending period in seconds (the 'for' duration).
keep_firing_for_seconds DOUBLE
Seconds the alert keeps firing after the condition clears.
no_data_state VARCHAR
State on no data: NoData, Alerting, OK or KeepLast.
exec_err_state VARCHAR
State on evaluation error: Error, Alerting, OK or KeepLast.
is_paused BOOLEAN
Evaluation is paused.
labels MAP(VARCHAR, VARCHAR)
Rule labels, e.g. labels['severity'].
annotations MAP(VARCHAR, VARCHAR)
Rule annotations, e.g. annotations['summary'], annotations['runbook_url'].
datasource_uids VARCHAR[]
Data sources the rule queries (server-side expressions excluded).
queries JSON
The rule's queries and expressions (data) as JSON.
notification_settings JSON
Simplified routing settings (receiver, group_by, ...) when set, as JSON.
is_recording BOOLEAN
A recording rule (writes a metric instead of alerting).
provenance VARCHAR
Where the rule is managed: 'file', 'api' or NULL (UI).
updated_at TIMESTAMP WITH TIME ZONE
Last update time.
org_id BIGINT
Numeric organization identifier (joins orgs.org_id).
url VARCHAR
Link to the rule in the Grafana UI.
ConstraintsPRIMARY KEY (uid) · FOREIGN KEY (org_id) REFERENCES orgs(org_id)
Examples (2)

Active rules with their severity label

SELECT folder_path, rule_group, title, labels['severity'] AS severity
FROM grafana.main.alert_rules
WHERE NOT is_paused
ORDER BY folder_path, rule_group, title;

Rules without a runbook link

SELECT title
FROM grafana.main.alert_rules
WHERE annotations['runbook_url'] IS NULL
ORDER BY title;
Link
alert_state_transitions 2 examples7 cols

State transitions of alert rules (Normal -> Pending -> Alerting, ...) from Grafana's state history

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
rule_uidnot null VARCHAR
Rule UID (joins alert_rules.uid).
time TIMESTAMP WITH TIME ZONE
Time of the transition.
previous_state VARCHAR
State before the transition.
current_state VARCHAR
State after the transition.
text VARCHAR
Transition summary with the alert's labels and values.
values JSON
Evaluation values as JSON, e.g. {"B": 270, "C": 1}.
ConstraintsFOREIGN KEY (rule_uid) REFERENCES alert_rules(uid)
Examples (2)

Which rules fired most often

SELECT rule_uid, count(*) AS transitions
FROM grafana.main.alert_state_transitions
WHERE current_state LIKE 'Alerting%'
GROUP BY rule_uid
ORDER BY transitions DESC, rule_uid;

One rule's timeline (only that rule is read)

SELECT time, previous_state, current_state
FROM grafana.main.alert_state_transitions
WHERE rule_uid = 'rule-high-latency'
ORDER BY time;
Link
alerts 2 examples14 cols

Alert instances in Grafana's Alertmanager: labels, annotations, state, silences, receivers and timing

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
fingerprintnot null VARCHAR
Alert fingerprint (unique per label set).
alertname VARCHAR
The alertname label.
rule_uid VARCHAR
Rule UID from the __alert_rule_uid__ label (joins alert_rules.uid).
state VARCHAR
active, suppressed or unprocessed.
silenced_by VARCHAR[]
Ids of the silences muting it (joins silences.id).
inhibited_by VARCHAR[]
Fingerprints of the alerts inhibiting it.
labels MAP(VARCHAR, VARCHAR)
Alert labels.
annotations MAP(VARCHAR, VARCHAR)
Alert annotations (summary, runbook_url, and Grafana's __values__ / __value_string__).
receivers VARCHAR[]
Contact points the alert is routed to.
starts_at TIMESTAMP WITH TIME ZONE
When the alert started firing.
ends_at TIMESTAMP WITH TIME ZONE
When it resolves (or the expected end if it keeps firing).
updated_at TIMESTAMP WITH TIME ZONE
Last update.
generator_url VARCHAR
Link to the rule that generated it.
ConstraintsPRIMARY KEY (fingerprint)
Examples (2)

Active alerts, oldest first

SELECT alertname, labels['severity'] AS severity, starts_at
FROM grafana.main.alerts
WHERE state = 'active'
ORDER BY starts_at;

Firing alerts with their rule's folder

SELECT a.alertname, r.folder_path
FROM grafana.main.alerts a
JOIN grafana.main.alert_rules r ON r.uid = a.rule_uid
ORDER BY a.alertname;
Link
annotations 2 examples18 cols

Annotations (events and time regions on dashboards or the whole org, plus alert state annotations) with time-range, dashboard, panel, tag and type pushdown

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
annotation_idnot null BIGINT
Numeric annotation identifier (assigned by Grafana, unique per instance).
type VARCHAR
'alert' for alert state annotations, 'annotation' otherwise.
time TIMESTAMP WITH TIME ZONE
Start time.
time_end TIMESTAMP WITH TIME ZONE
End time (equal to time for a point event).
is_region BOOLEAN
A time region (end after start) rather than a point event.
text VARCHAR
Annotation text.
tags VARCHAR[]
Free-form labels attached to the annotation, e.g. [deploy, web].
dashboard_uid VARCHAR
UID of the dashboard it belongs to; NULL for an org-wide annotation.
panel_id BIGINT
Numeric identifier of the panel it belongs to (unique within dashboard_uid); NULL when not panel-specific.
login VARCHAR
Login of the author (NULL for alert annotations).
rule_internal_id BIGINT
Numeric alert rule identifier local to this instance (alert annotations only).
alert_name VARCHAR
Alert rule name for alert annotations.
prev_state VARCHAR
Previous alert state (alert annotations).
new_state VARCHAR
New alert state (alert annotations).
created_at TIMESTAMP WITH TIME ZONE
When the annotation was created.
updated_at TIMESTAMP WITH TIME ZONE
When it was last updated.
data JSON
Extra data (alert evaluation values) as JSON.
ConstraintsPRIMARY KEY (annotation_id)
Examples (2)

Deploy annotations since a date (tag and window pushed to Grafana)

SELECT time, text, tags
FROM grafana.main.annotations
WHERE list_contains(tags, 'deploy') AND time >= TIMESTAMPTZ '2026-01-01 00:00:00+00'
ORDER BY time;

Annotations per dashboard

SELECT d.title, count(*) AS annotations
FROM grafana.main.annotations a
JOIN grafana.main.dashboards d ON d.id = a.dashboard_uid
WHERE a.type = 'annotation'
GROUP BY d.title
ORDER BY annotations DESC, d.title;
Link
connections 2 examples17 cols

Configured data sources (the BI 'connections'): type, endpoint, database and access mode; credentials, secure fields and URL user info are never returned

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
idnot null VARCHAR
Data source UID (use in ds_query; joins panels.datasource_uid).
title VARCHAR
Data source name.
created_at TIMESTAMP WITH TIME ZONE
Creation time: NULL, Grafana does not expose it.
url VARCHAR
Link to the data source settings in the Grafana UI.
internal_id BIGINT
Numeric data source identifier local to this Grafana instance (prefer id, the UID).
type VARCHAR
Plugin id, e.g. 'prometheus', 'loki', 'grafana-postgresql-datasource'.
type_name VARCHAR
Plugin display name, e.g. 'PostgreSQL'.
access VARCHAR
Access mode: 'proxy' (server) or 'direct' (browser).
endpoint VARCHAR
Configured URL with user info, query string and fragment removed.
database VARCHAR
Database name (database field or jsonData.database).
user VARCHAR
Database / service user name configured on the data source (not a secret; passwords are never returned).
basic_auth BOOLEAN
Basic authentication is enabled (the password is never returned).
is_default BOOLEAN
The organization's default data source.
read_only BOOLEAN
Provisioned and not editable in the UI.
json_data JSON
Plugin settings (jsonData) with secret-looking keys masked as [REDACTED].
org_id BIGINT
Numeric organization identifier (joins orgs.org_id).
ConstraintsPRIMARY KEY (id) · FOREIGN KEY (org_id) REFERENCES orgs(org_id)
Examples (2)

Data sources per plugin type

SELECT type, count(*) AS sources
FROM grafana.main.connections
GROUP BY type
ORDER BY sources DESC, type;

Panels per data source, unused data sources first

SELECT c.title, count(p.panel_id) AS panels
FROM grafana.main.connections c
LEFT JOIN grafana.main.panels p ON p.datasource_uid = c.id
GROUP BY c.title
ORDER BY panels, c.title;
Link
contact_points 2 examples9 cols

Notification contact points: name, integration type and target host only; settings, secrets and full URLs are never returned

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
uid VARCHAR
Integration UID.
namenot null VARCHAR
Contact point (receiver) name.
type VARCHAR
Integration type: email, slack, webhook, pagerduty, teams, ...
target_host VARCHAR
Host of the integration's target URL; the path and query string are withheld.
address_count BIGINT
Number of email addresses (email integrations).
setting_keys VARCHAR[]
Names of the configured settings (values withheld).
disable_resolve_message BOOLEAN
Resolved notifications are not sent.
provenance VARCHAR
Where it is managed: 'file', 'api' or NULL (UI).
Examples (2)

Integrations per type

SELECT type, count(*) AS integrations
FROM grafana.main.contact_points
GROUP BY type
ORDER BY integrations DESC, type;

Contact points no notification policy routes to

SELECT c.name, c.type
FROM grafana.main.contact_points c ANTI
JOIN grafana.main.notification_policies p ON p.receiver = c.name
ORDER BY c.name;
Link
dashboard_versions 2 examples9 cols

The saved version history of every dashboard: version number, author, time and save message

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
dashboard_uidnot null VARCHAR
Dashboard UID (joins dashboards.id).
versionnot null BIGINT
Version number (1 for the first save, +1 per save).
parent_version BIGINT
Version number this one was saved over (0 for the first save).
restored_from BIGINT
Version this one restored (0 when not a restore).
created_at TIMESTAMP WITH TIME ZONE
When the version was saved.
created_by VARCHAR
Login of the user who saved it.
message VARCHAR
Save message.
version_id BIGINT
Numeric identifier of the version record (instance-local).
ConstraintsPRIMARY KEY (dashboard_uid, version) · FOREIGN KEY (dashboard_uid) REFERENCES dashboards(id)
Examples (2)

Who saves dashboards most

SELECT created_by, count(*) AS saves
FROM grafana.main.dashboard_versions
GROUP BY created_by
ORDER BY saves DESC, created_by;

One dashboard's history

SELECT version, created_by, message
FROM grafana.main.dashboard_versions
WHERE dashboard_uid = 'web-overview'
ORDER BY version;
Link
dashboards 2 examples25 cols

Every dashboard the credential can see, in the shared BI inventory shape (tool, id, title, folder_path, owner, created_at, updated_at, last_viewed_at, view_count, url) plus Grafana's tags, version and panel count

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
idnot null VARCHAR
Dashboard UID (stable across instances; the key for panels, versions and annotations).
title VARCHAR
Dashboard title.
folder_uid VARCHAR
UID of the containing folder; NULL in the General (root) folder.
folder_title VARCHAR
Title of the containing folder ('General' at the root).
folder_path VARCHAR
Folder chain from the root, e.g. '/Operations/Web'; '/' for the General folder.
tags VARCHAR[]
Dashboard tags.
is_starred BOOLEAN
Starred by the credential's user.
owner VARCHAR
Login of the user who created the dashboard (detail column).
updated_by VARCHAR
Login of the last user to save it (detail column).
created_at TIMESTAMP WITH TIME ZONE
Creation time (detail column).
updated_at TIMESTAMP WITH TIME ZONE
Last save time (detail column).
last_viewed_at TIMESTAMP WITH TIME ZONE
Last view time: NULL, Grafana OSS has no view statistics API.
view_count BIGINT
Count of lifetime views: NULL, Grafana OSS has no view statistics API.
url VARCHAR
Link to the dashboard in the Grafana UI.
internal_id BIGINT
Numeric dashboard identifier local to this Grafana instance (prefer id, the UID).
version BIGINT
Saved version number (detail column).
schema_version BIGINT
Dashboard JSON schema version (detail column).
panel_count BIGINT
Number of panels, rows and panels inside collapsed rows included (detail column).
refresh VARCHAR
Auto-refresh interval, e.g. '30s'; NULL when off (detail column).
time_from VARCHAR
Default time range start, e.g. 'now-6h' (detail column).
time_to VARCHAR
Default time range end, e.g. 'now' (detail column).
description VARCHAR
Dashboard description (detail column).
provisioned BOOLEAN
Provisioned from a file or Git rather than saved in the UI (detail column).
dashboard_json JSON
The full dashboard model (detail column).
ConstraintsPRIMARY KEY (id)
Examples (2)

How many dashboards each folder holds

SELECT folder_path, count(*) AS dashboards
FROM grafana.main.dashboards
GROUP BY folder_path
ORDER BY dashboards DESC, folder_path;

Dashboards tagged 'ops' (the tag filter is sent to the search API) with owner and size

SELECT title, owner, updated_at, panel_count
FROM grafana.main.dashboards
WHERE list_contains(tags, 'ops')
ORDER BY updated_at DESC;
Link
folders 2 examples13 cols

Every folder (nested folders included) with its parent, depth and full folder_path, in the shared BI inventory shape

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
idnot null VARCHAR
Folder UID.
title VARCHAR
Folder title.
parent_uid VARCHAR
UID of the parent folder; NULL for a top-level folder.
folder_path VARCHAR
Folder chain from the root including this folder, e.g. '/Operations/Web'.
depth BIGINT
Nesting depth in levels below the root: 1 for a top-level folder.
owner VARCHAR
Login of the user who created the folder (detail column).
updated_by VARCHAR
Login of the last user to change it (detail column).
created_at TIMESTAMP WITH TIME ZONE
Creation time (detail column).
updated_at TIMESTAMP WITH TIME ZONE
Last change time (detail column).
version BIGINT
Folder version (detail column).
url VARCHAR
Link to the folder in the Grafana UI.
internal_id BIGINT
Numeric folder identifier local to this Grafana instance (prefer id, the UID).
ConstraintsPRIMARY KEY (id)
Examples (2)

The folder tree as paths

SELECT folder_path, depth FROM grafana.main.folders ORDER BY folder_path;

Folders with their dashboard counts, empty folders included

SELECT f.folder_path, count(d.id) AS dashboards
FROM grafana.main.folders f
LEFT JOIN grafana.main.dashboards d ON d.folder_uid = f.id
GROUP BY f.folder_path
ORDER BY dashboards DESC, f.folder_path;
Link
health 1 example4 cols

Grafana's health endpoint: version, commit and database status

Columns
grafana_version VARCHAR
Grafana version, e.g. '12.1.1'.
commit VARCHAR
Build commit.
database VARCHAR
'ok' when the backing database answers.
enterprise_commit_present BOOLEAN
Built with Grafana Enterprise code.
Example

Which Grafana version is running, and is its database up

SELECT grafana_version, database FROM grafana.main.health;
Link
library_panels 2 examples14 cols

Reusable library panels: name, type, folder, how many dashboards use them and their model

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
uidnot null VARCHAR
Library panel UID.
name VARCHAR
Library panel name.
type VARCHAR
Visualization plugin id.
description VARCHAR
What the library panel shows, as written by its author.
folder_uid VARCHAR
UID of the folder it is stored in; NULL in General.
folder_path VARCHAR
Folder chain, e.g. '/Operations'.
version BIGINT
Version number (1 for the first save, +1 per save).
connected_dashboards BIGINT
Count of dashboards that embed it.
created_at TIMESTAMP WITH TIME ZONE
Creation time.
updated_at TIMESTAMP WITH TIME ZONE
Last update time.
created_by VARCHAR
Name of the user who created it.
updated_by VARCHAR
Name of the user who last updated it.
model JSON
The panel model as JSON.
ConstraintsPRIMARY KEY (uid)
Examples (2)

Most reused library panels

SELECT name, type, folder_path, connected_dashboards
FROM grafana.main.library_panels
ORDER BY connected_dashboards DESC, name;

Where each library panel is used

SELECT l.name, p.dashboard_title
FROM grafana.main.library_panels l
JOIN grafana.main.panels p ON p.library_panel_uid = l.uid
ORDER BY l.name, p.dashboard_title;
Link
mute_timings 1 example7 cols

Mute timings (named time intervals during which notifications are muted)

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
namenot null VARCHAR
Mute timing name.
interval_count BIGINT
Count of time intervals.
weekdays VARCHAR[]
Weekdays of all intervals, e.g. ['saturday', 'sunday'].
time_intervals JSON
The intervals as JSON (times, weekdays, days_of_month, months, years, location).
etag VARCHAR
Version tag of the mute timing (changes on every edit).
provenance VARCHAR
Where it is managed: 'file', 'api' or NULL (UI).
ConstraintsPRIMARY KEY (name)
Example

Mute timings and their weekdays

SELECT name, weekdays, interval_count
FROM grafana.main.mute_timings
ORDER BY name;
Link
notification_policies 2 examples15 cols

The notification policy tree flattened: one row per route with its matchers, receiver and timings (inherited values resolved)

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
pathnot null VARCHAR
Position in the tree: '0' = root, '0.1' = the root's second child.
parent_path VARCHAR
Path of the parent route; NULL for the root.
depth BIGINT
Depth in levels below the root: 0 for the root (default policy).
is_default BOOLEAN
The root (default) policy.
receiver VARCHAR
Effective contact point name (joins contact_points.name).
matchers STRUCT("name" VARCHAR, op VARCHAR, "value" VARCHAR)[]
Label matchers: list of STRUCT(name, op, value), op one of =, !=, =~, !~.
group_by VARCHAR[]
Effective group-by labels.
group_wait_seconds DOUBLE
Effective group wait in seconds.
group_interval_seconds DOUBLE
Effective group interval in seconds.
repeat_interval_seconds DOUBLE
Effective repeat interval in seconds.
continue_matching BOOLEAN
Keep matching sibling routes after this one matches.
mute_timings VARCHAR[]
Mute timings applied (mute_timings.name).
active_timings VARCHAR[]
Active time intervals applied.
provenance VARCHAR
Where the tree is managed: 'file', 'api' or NULL (UI); set on the root only.
ConstraintsPRIMARY KEY (path) · FOREIGN KEY (parent_path) REFERENCES notification_policies(path)
Examples (2)

The routing tree

SELECT path, depth, receiver, matchers
FROM grafana.main.notification_policies
ORDER BY path;

How many routes end at each contact point

SELECT receiver, count(*) AS routes
FROM grafana.main.notification_policies
GROUP BY receiver
ORDER BY routes DESC, receiver;
Link
orgs 1 example4 cols

Grafana organizations: every org for a server admin, else the credential's current org

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
org_idnot null BIGINT
Numeric organization identifier (the secret's ORG_ID).
name VARCHAR
Organization name.
is_current BOOLEAN
Listed through /api/org because the credential cannot list every org.
ConstraintsPRIMARY KEY (org_id)
Example

List organizations

SELECT org_id, name FROM grafana.main.orgs ORDER BY org_id;
Link
panel_queries 2 examples17 cols

Every query (target) of every panel, with its effective data source and the query text extracted (PromQL/LogQL expr, SQL rawSql, InfluxQL/Flux query)

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
dashboard_uidnot null VARCHAR
UID of the dashboard holding the panel (joins dashboards.id).
dashboard_title VARCHAR
Title of the dashboard holding the panel.
folder_uid VARCHAR
UID of the dashboard's folder; NULL in General.
folder_path VARCHAR
Folder chain of the dashboard, e.g. '/Operations/Web'.
panel_idnot null BIGINT
Numeric identifier of the panel within its dashboard (joins panels.panel_id).
panel_title VARCHAR
Title of the panel the query belongs to.
panel_type VARCHAR
Visualization plugin id of the panel.
ref_idnot null VARCHAR
Query reference letter within the panel (A, B, ...).
datasource_uid VARCHAR
Effective data source UID: the target's own, else the panel's.
datasource_type VARCHAR
Effective data source plugin id.
hidden BOOLEAN
The query is hidden (hide: true) and does not draw.
expr VARCHAR
PromQL / LogQL expression (Prometheus, Loki, Mimir targets).
raw_sql VARCHAR
SQL text (PostgreSQL, MySQL, MSSQL and other SQL targets).
query_text VARCHAR
The target's query string, whichever field holds it (expr, rawSql, query, expression, rawQuery, ...).
legend_format VARCHAR
Legend template, e.g. '{{service}}'.
target_json JSON
The full target (query model) as JSON.
ConstraintsFOREIGN KEY (dashboard_uid) REFERENCES dashboards(id)
Examples (2)

Every PromQL expression on any dashboard

SELECT dashboard_title, panel_title, expr
FROM grafana.main.panel_queries
WHERE datasource_type = 'prometheus' AND expr IS NOT NULL
ORDER BY dashboard_title, panel_title;

Data source usage across dashboards

SELECT datasource_uid, count(DISTINCT dashboard_uid) AS dashboards,
  count(*) AS queries
FROM grafana.main.panel_queries
GROUP BY datasource_uid
ORDER BY queries DESC, datasource_uid;
Link
panels 2 examples23 cols

Every panel of every dashboard, flattened (panels inside collapsed rows included), with its type, data source, grid position and queries as JSON

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
dashboard_uidnot null VARCHAR
UID of the dashboard holding the panel (joins dashboards.id).
dashboard_title VARCHAR
Title of the dashboard holding the panel.
folder_uid VARCHAR
UID of the dashboard's folder; NULL in General.
folder_path VARCHAR
Folder chain of the dashboard, e.g. '/Operations/Web'.
panel_idnot null BIGINT
Numeric panel identifier (unique within its dashboard).
title VARCHAR
Panel title.
type VARCHAR
Visualization plugin id, e.g. 'timeseries', 'stat', 'table', 'row'; NULL for a library panel instance.
description VARCHAR
Panel description.
row_id BIGINT
Numeric panel identifier (panel_id) of the collapsed row that contains this panel; NULL otherwise.
row_title VARCHAR
Title of the collapsed row that contains this panel.
datasource_uid VARCHAR
UID of the panel's data source ('-- Mixed --' for mixed; a legacy name for old dashboards).
datasource_type VARCHAR
Plugin id of the panel's data source.
library_panel_uid VARCHAR
UID of the library panel this instance shows (joins library_panels.uid).
library_panel_name VARCHAR
Name of the library panel.
grid_x BIGINT
Left offset in grid columns (0-23, 24 columns wide).
grid_y BIGINT
Top offset in grid rows from the top of the dashboard.
grid_w BIGINT
Width in grid columns (out of 24).
grid_h BIGINT
Height in grid rows (about 30 px each).
target_count BIGINT
Number of queries (targets).
targets JSON
The panel's queries (targets) as JSON.
panel_json JSON
The full panel model as JSON.
url VARCHAR
Link to the panel (viewPanel) in the Grafana UI.
ConstraintsFOREIGN KEY (dashboard_uid) REFERENCES dashboards(id)
Examples (2)

Which visualizations are used most

SELECT type, count(*) AS panels
FROM grafana.main.panels
WHERE type <> 'row'
GROUP BY type
ORDER BY panels DESC, type;

The panels of one dashboard (only that dashboard is read)

SELECT dashboard_title, title, datasource_type
FROM grafana.main.panels
WHERE dashboard_uid = 'web-overview'
ORDER BY panel_id;
Link
rule_groups 1 example11 cols

Alert rule evaluation groups with their folder, interval, rule count and last evaluation

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
namenot null VARCHAR
Group name.
folder_uidnot null VARCHAR
UID of the group's folder.
folder_path VARCHAR
Folder chain of the group.
folder_title VARCHAR
Folder title (the 'file' field).
interval_seconds DOUBLE
Evaluation interval in seconds.
rule_count BIGINT
Number of rules in the group.
firing BIGINT
Count of rules currently firing.
pending BIGINT
Count of rules currently pending.
last_evaluation TIMESTAMP WITH TIME ZONE
Last evaluation time of the group.
evaluation_seconds DOUBLE
Duration of the last evaluation in seconds.
ConstraintsPRIMARY KEY (folder_uid, name)
Example

Groups by evaluation frequency

SELECT folder_path, name, interval_seconds, rule_count
FROM grafana.main.rule_groups
ORDER BY interval_seconds, name;
Link
service_accounts 1 example9 cols

Service accounts with their role, disabled flag and token count (tokens themselves are never returned)

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
service_account_idnot null BIGINT
Numeric service account identifier (instance-local).
uid VARCHAR
Service account UID.
name VARCHAR
Service account display name.
login VARCHAR
Login (sa-<org>-<name>).
role VARCHAR
Org role: Admin, Editor, Viewer or None.
is_disabled BOOLEAN
Disabled.
token_count BIGINT
Count of tokens (their values are never returned).
org_id BIGINT
Numeric organization identifier (joins orgs.org_id).
ConstraintsPRIMARY KEY (service_account_id) · FOREIGN KEY (org_id) REFERENCES orgs(org_id)
Example

Enabled service accounts by token count

SELECT name, role, token_count
FROM grafana.main.service_accounts
WHERE NOT is_disabled
ORDER BY token_count DESC, name;
Link
silences 1 example9 cols

Alertmanager silences: matchers, author, comment, time window and state

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
idnot null VARCHAR
Silence id.
state VARCHAR
active, pending or expired.
matchers STRUCT of 4 fields[]
Label matchers: STRUCT(name, value, is_regex, is_equal).
STRUCT[] 4 fields
  • nameVARCHAR
  • valueVARCHAR
  • is_regexBOOLEAN
  • is_equalBOOLEAN
created_by VARCHAR
Author.
comment VARCHAR
Why the silence was created, as written by its author.
starts_at TIMESTAMP WITH TIME ZONE
Start of the silence.
ends_at TIMESTAMP WITH TIME ZONE
End of the silence.
updated_at TIMESTAMP WITH TIME ZONE
Last update.
ConstraintsPRIMARY KEY (id)
Example

Active silences by expiry

SELECT created_by, comment, ends_at
FROM grafana.main.silences
WHERE state = 'active'
ORDER BY ends_at;
Link
team_members 2 examples12 cols

Members of every team, with their login, email and team permission

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
team_idnot null BIGINT
Numeric team identifier (joins teams.team_id).
team_name VARCHAR
Name of the team the user belongs to.
team_uid VARCHAR
Stable UID of the team (teams.uid).
user_idnot null BIGINT
Numeric user identifier (joins users.user_id).
user_uid VARCHAR
Stable UID of the member (users.uid).
login VARCHAR
Member login.
email VARCHAR
Member email.
display_name VARCHAR
Member display name.
permission BIGINT
Team permission level (4 = team admin, 0 = member).
is_admin BOOLEAN
Team admin (permission 4).
auth_module VARCHAR
Auth module that synced the membership, e.g. 'oauth_github'; NULL for manual membership.
ConstraintsPRIMARY KEY (team_id, user_id) · FOREIGN KEY (team_id) REFERENCES teams(team_id) · FOREIGN KEY (user_id) REFERENCES users(user_id)
Examples (2)

Who is in which team

SELECT team_name, login, is_admin
FROM grafana.main.team_members
ORDER BY team_name, login;

Users in no team

SELECT u.login
FROM grafana.main.users u ANTI
JOIN grafana.main.team_members m ON m.user_id = u.user_id
ORDER BY u.login;
Link
teams 1 example9 cols

Teams of the current organization with their member counts

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
team_idnot null BIGINT
Numeric team identifier (joins team_members.team_id).
uid VARCHAR
Team UID.
name VARCHAR
Team name.
email VARCHAR
Team email.
member_count BIGINT
Count of team members.
is_provisioned BOOLEAN
Provisioned (synced) rather than managed in the UI.
org_id BIGINT
Numeric organization identifier (joins orgs.org_id).
url VARCHAR
Link to the team in the Grafana UI.
ConstraintsPRIMARY KEY (team_id) · FOREIGN KEY (org_id) REFERENCES orgs(org_id)
Example

Largest teams

SELECT name, member_count
FROM grafana.main.teams
ORDER BY member_count DESC, name;
Link
users 2 examples14 cols

Users of the current organization with their org role, last-seen time and disabled flag

Columns
toolnot null VARCHAR
Always 'grafana': the BI tool, for UNION ALL BY NAME with vgi-looker, vgi-tableau and vgi-metabase tables.
idnot null VARCHAR
Numeric user id, as text (shared BI shape).
user_idnot null BIGINT
Numeric user identifier (joins team_members.user_id).
uid VARCHAR
User UID.
login VARCHAR
Login name.
display_name VARCHAR
Full name shown in the Grafana UI; NULL when unset.
email VARCHAR
Email address.
role VARCHAR
Org role: Admin, Editor, Viewer or None.
last_seen_at TIMESTAMP WITH TIME ZONE
Last activity time; NULL when the user never signed in (Grafana reports those as 10 years ago).
is_disabled BOOLEAN
The account is disabled.
auth_labels VARCHAR[]
External auth providers the user signed in with (e.g. 'OAuth', 'LDAP').
is_externally_synced BOOLEAN
Role managed by an external identity provider.
org_id BIGINT
Numeric organization identifier (joins orgs.org_id).
url VARCHAR
Link to the user's admin page in the Grafana UI.
ConstraintsPRIMARY KEY (user_id) · FOREIGN KEY (org_id) REFERENCES orgs(org_id)
Examples (2)

Users per org role

SELECT role, count(*) AS users
FROM grafana.main.users
GROUP BY role
ORDER BY users DESC, role;

Least recently active enabled users (access review)

SELECT login, display_name, last_seen_at
FROM grafana.main.users
WHERE NOT is_disabled
ORDER BY last_seen_at NULLS FIRST
LIMIT 20;
Link
Scalar functions
duration_seconds (text VARCHAR) 2 examples

Seconds in a Grafana / Prometheus duration string such as '5m', '1h30m' or '7d' (NULL when invalid)

Arguments
text VARCHAR
The text to convert. NULL gives NULL.
ReturnsDOUBLE
Examples (2)

Dashboards that auto-refresh most often

SELECT title, grafana.main.duration_seconds(refresh) AS refresh_seconds
FROM grafana.main.dashboards
WHERE refresh IS NOT NULL
ORDER BY refresh_seconds;
SELECT d, grafana.main.duration_seconds(d) AS seconds
FROM (VALUES ('1h30m'), ('5m'), ('250ms'), ('7d'), ('soon')) t(d)
ORDER BY d;
Link
redact_url (text VARCHAR) 2 examples

A URL with its user:password@, query string and fragment removed, the way the worker shows data source endpoints

Arguments
text VARCHAR
The text to convert. NULL gives NULL.
ReturnsVARCHAR
Examples (2)

Panel links with any embedded credentials removed

SELECT title, grafana.main.redact_url(panel_json->>'$.links[0].url') AS link
FROM grafana.main.panels
WHERE panel_json->>'$.links[0].url' IS NOT NULL
ORDER BY title;
SELECT grafana.main.redact_url(u) AS redacted
FROM (VALUES ('https://bot:[email protected]/services/T0?token=abc'), ('http://prometheus:9090/api#x')) t(u)
ORDER BY redacted;
Link
Table functions
ds_query (datasource_uid VARCHAR, query_json VARCHAR, start_time TIMESTAMP WITH TIME ZONE, end_time TIMESTAMP WITH TIME ZONE, max_data_points := BIGINT, interval_ms := BIGINT, secret_name := VARCHAR) 2 examples

Run a read-only query against any Grafana data source through Grafana's query API and get the data frames back as long rows (labels, ts, value)

Positional arguments
datasource_uid VARCHAR
UID of the data source to query (grafana.main.connections.id).
query_json VARCHAR
The data source query model as JSON: one object or an array of objects (each becomes one refId; refId defaults to A, B, ...).
start_time TIMESTAMP WITH TIME ZONE
Start of the query time range.
end_time TIMESTAMP WITH TIME ZONE
End of the query time range.
Named arguments
max_data_points := BIGINT
maxDataPoints sent with each query (default: the data source's own default).
interval_ms := BIGINT
intervalMs sent with each query: the step data sources use for time bucketing.
secret_name := VARCHAR
Name of the grafana secret to use when several exist.
Returns columns
ref_id VARCHAR
Query reference id (A, B, ...).
frame_index BIGINT
Index of the frame within the query's result.
frame_name VARCHAR
Frame name (often the series name); NULL when unnamed.
frame_type VARCHAR
Dataplane frame type, e.g. 'timeseries-multi', 'numeric-long', 'table'; NULL when the data source does not say.
field VARCHAR
Field (column) name, or its display name from the data source.
labels MAP(VARCHAR, VARCHAR)
The field's labels (e.g. Prometheus series labels); empty when none.
row_index BIGINT
Row number within the frame (0-based).
ts TIMESTAMP WITH TIME ZONE
Value of the frame's first time field at this row; NULL for frames without one.
value DOUBLE
Numeric value (NaN and Inf kept; booleans as 1/0); NULL for strings and nulls.
string_value VARCHAR
String value for string, boolean, enum and extra time fields; NULL for numbers.
unit VARCHAR
The field's unit from its config, e.g. 'ms', 'percent'.
Examples (2)

A TestData series: three values spread over the hour

SELECT ts, value
FROM grafana.main.ds_query('testdata', '{"scenarioId": "csv_metric_values", "stringInput": "1,20,90", "alias": "cpu"}', TIMESTAMPTZ '2026-01-01 00:00:00+00', TIMESTAMPTZ '2026-01-01 01:00:00+00')
ORDER BY ts;

PromQL through Grafana's Prometheus data source: peak request rate per job

SELECT labels['job'] AS job, max(value) AS peak
FROM grafana.main.ds_query('prom-prod', '{"expr": "sum by (job) (rate(http_requests_total[5m]))"}', TIMESTAMPTZ '2026-01-01 00:00:00+00', TIMESTAMPTZ '2026-01-01 06:00:00+00', interval_ms := 60000)
GROUP BY job
ORDER BY peak DESC;
Link

Credentials

The secret type grafana declares, as reported by the worker itself.

grafana

How to get these credentials

Connection to a Grafana HTTP API (Grafana OSS, Enterprise or Grafana Cloud): base URL plus a service account token, API key or basic-auth login.

secret.sql
CREATE SECRET grafana (
    TYPE grafana,
    base_url  '<base_url>',
    token     '<GRAFANA_TOKEN>',  -- secret
    username  '<username>',
    password  '<GRAFANA_PASSWORD>',  -- secret
    org_id    '<org_id>',
    page_size '<page_size>'
);
Key Type Required Description
base_url VARCHAR — Grafana root URL, e.g. 'https://grafana.example.com' or 'https://acme.grafana.net'. Include the sub-path when Grafana is served from one.
token secret VARCHAR — Service account token or API key, sent as 'Authorization: Bearer <token>'.
username VARCHAR — Basic-auth login (used when no TOKEN is set).
password secret VARCHAR — Basic-auth password.
org_id VARCHAR — Organization id sent as the X-Grafana-Org-Id header; default: the credential's current organization.
page_size VARCHAR — Page size for paged list endpoints (search, users, teams, library panels, annotations); default 1000.

The worker doesn't mark which keys are required.

Needed by ds_querysearch

Create the secret in the same session, after attaching grafana — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

The folder tree as paths

SELECT folder_path, depth FROM grafana.main.folders ORDER BY folder_path

Uses folders

Which visualizations are used most

SELECT type, count(*) AS panels
FROM grafana.main.panels
WHERE type <> 'row'
GROUP BY type
ORDER BY panels DESC, type

Uses panels

Every PromQL expression on any dashboard

SELECT dashboard_title, panel_title, expr
FROM grafana.main.panel_queries
WHERE datasource_type = 'prometheus' AND expr IS NOT NULL
ORDER BY dashboard_title, panel_title

Uses panel_queries

Who saves dashboards most

SELECT created_by, count(*) AS saves
FROM grafana.main.dashboard_versions
GROUP BY created_by
ORDER BY saves DESC, created_by

Uses dashboard_versions

Most reused library panels

SELECT name, type, folder_path, connected_dashboards
FROM grafana.main.library_panels
ORDER BY connected_dashboards DESC, name

Uses library_panels

Data sources per plugin type

SELECT type, count(*) AS sources
FROM grafana.main.connections
GROUP BY type
ORDER BY sources DESC, type

Uses connections

42 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Using the grafana worker, how many dashboards are in each folder path?
  • Which Grafana dashboards are starred?
  • List every Grafana folder with its full folder path, deepest first.
  • How many panels of each visualization type are on the Grafana dashboards, rows excluded?
  • Which PromQL expressions are used on Grafana dashboards, and on which dashboard?
  • Which Grafana data sources are not used by any dashboard panel?

Grafana is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.