KosmoKrator

analytics

Grafana CLI for AI Agents

Use the Grafana CLI from KosmoKrator to call Grafana tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

7 functions 6 read 1 write API token auth

Grafana CLI Setup

Grafana can be configured headlessly with `kosmokrator integrations:configure grafana`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure grafana --set api_token="$GRAFANA_API_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor grafana --json
kosmokrator integrations:status --json

Credentials

Authentication type: API token api_token. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_token GRAFANA_API_TOKEN Secret secret yes API Token

Call Grafana Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call grafana.grafana_list_dashboards '{
  "query": "example_query",
  "type": "example_type",
  "limit": 1
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:grafana grafana_list_dashboards '{
  "query": "example_query",
  "type": "example_type",
  "limit": 1
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs grafana --json
kosmo integrations:docs grafana.grafana_list_dashboards --json
kosmo integrations:schema grafana.grafana_list_dashboards --json
kosmo integrations:search "Grafana" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Grafana.

grafana.grafana_list_dashboards

Read read

Search and list Grafana dashboards. Returns dashboard UIDs, titles, and folder info. Use query to filter by title.

Parameters
query, type, limit

Generic CLI call

kosmo integrations:call grafana.grafana_list_dashboards '{"query":"example_query","type":"example_type","limit":1}' --json

Provider shortcut

kosmo integrations:grafana grafana_list_dashboards '{"query":"example_query","type":"example_type","limit":1}' --json

grafana.grafana_get_dashboard

Read read

Get a Grafana dashboard by its UID. Returns the full dashboard definition including panels, queries, and settings.

Parameters
uid

Generic CLI call

kosmo integrations:call grafana.grafana_get_dashboard '{"uid":"example_uid"}' --json

Provider shortcut

kosmo integrations:grafana grafana_get_dashboard '{"uid":"example_uid"}' --json

grafana.grafana_create_dashboard

Write write

Create or update a Grafana dashboard. Provide the full dashboard JSON with panels, queries, and settings. Set overwrite to true to update an existing dashboard.

Parameters
dashboard, folderUid, overwrite

Generic CLI call

kosmo integrations:call grafana.grafana_create_dashboard '{"dashboard":"example_dashboard","folderUid":"example_folderUid","overwrite":true}' --json

Provider shortcut

kosmo integrations:grafana grafana_create_dashboard '{"dashboard":"example_dashboard","folderUid":"example_folderUid","overwrite":true}' --json

grafana.grafana_list_datasources

Read read

List all configured datasources in Grafana. Returns datasource IDs, names, types (e.g., Prometheus, InfluxDB), and access info.

Parameters
none

Generic CLI call

kosmo integrations:call grafana.grafana_list_datasources '{}' --json

Provider shortcut

kosmo integrations:grafana grafana_list_datasources '{}' --json

grafana.grafana_list_alerts

Read read

List Grafana alerts. Optionally filter by dashboard ID or panel ID. Returns alert states, thresholds, and conditions.

Parameters
dashboardId, panelId

Generic CLI call

kosmo integrations:call grafana.grafana_list_alerts '{"dashboardId":1,"panelId":1}' --json

Provider shortcut

kosmo integrations:grafana grafana_list_alerts '{"dashboardId":1,"panelId":1}' --json

grafana.grafana_list_teams

Read read

List all Grafana teams. Returns team IDs, names, emails, and member counts with pagination support.

Parameters
page, perPage

Generic CLI call

kosmo integrations:call grafana.grafana_list_teams '{"page":1,"perPage":1}' --json

Provider shortcut

kosmo integrations:grafana grafana_list_teams '{"page":1,"perPage":1}' --json

grafana.grafana_get_current_user

Read read

Get the currently authenticated Grafana user. Useful for verifying credentials and identifying the connected account.

Parameters
none

Generic CLI call

kosmo integrations:call grafana.grafana_get_current_user '{}' --json

Provider shortcut

kosmo integrations:grafana grafana_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

grafana.grafana_list_dashboards

Search and list Grafana dashboards. Returns dashboard UIDs, titles, and folder info. Use query to filter by title.

Operation
Read read
Schema command
kosmo integrations:schema grafana.grafana_list_dashboards --json
ParameterTypeRequiredDescription
query string no Search query to filter dashboards by title.
type string no Dashboard type filter. Default: "dash-db" (saved dashboards).
limit integer no Maximum number of results to return (default: 100).

grafana.grafana_get_dashboard

Get a Grafana dashboard by its UID. Returns the full dashboard definition including panels, queries, and settings.

Operation
Read read
Schema command
kosmo integrations:schema grafana.grafana_get_dashboard --json
ParameterTypeRequiredDescription
uid string yes The unique identifier (UID) of the dashboard.

grafana.grafana_create_dashboard

Create or update a Grafana dashboard. Provide the full dashboard JSON with panels, queries, and settings. Set overwrite to true to update an existing dashboard.

Operation
Write write
Schema command
kosmo integrations:schema grafana.grafana_create_dashboard --json
ParameterTypeRequiredDescription
dashboard object yes The complete dashboard JSON object. Must include "title" at minimum.
folderUid string no UID of the folder to place the dashboard in.
overwrite boolean no Whether to overwrite an existing dashboard with the same slug (default: false).

grafana.grafana_list_datasources

List all configured datasources in Grafana. Returns datasource IDs, names, types (e.g., Prometheus, InfluxDB), and access info.

Operation
Read read
Schema command
kosmo integrations:schema grafana.grafana_list_datasources --json
ParameterTypeRequiredDescription
No parameters.

grafana.grafana_list_alerts

List Grafana alerts. Optionally filter by dashboard ID or panel ID. Returns alert states, thresholds, and conditions.

Operation
Read read
Schema command
kosmo integrations:schema grafana.grafana_list_alerts --json
ParameterTypeRequiredDescription
dashboardId integer no Filter alerts by dashboard ID.
panelId integer no Filter alerts by panel ID.

grafana.grafana_list_teams

List all Grafana teams. Returns team IDs, names, emails, and member counts with pagination support.

Operation
Read read
Schema command
kosmo integrations:schema grafana.grafana_list_teams --json
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
perPage integer no Number of teams per page (default: 50).

grafana.grafana_get_current_user

Get the currently authenticated Grafana user. Useful for verifying credentials and identifying the connected account.

Operation
Read read
Schema command
kosmo integrations:schema grafana.grafana_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.