Manage Grafana
from the command line.
Full coverage of dashboards, datasources, folders, alerts, annotations, orgs, teams, users, and service accounts. Designed for both humans and AI coding agents.
Install
Pick whichever fits — the install script handles platform detection and PATH setup.
Recommended — install script
curl -sSfL https://raw.githubusercontent.com/piyush-gambhir/grafana-cli/main/install.sh | sh
Via Go
go install github.com/piyush-gambhir/grafana-cli@latest
Build from source
git clone https://github.com/piyush-gambhir/grafana-cli.git cd grafana-cli make install
From releases
Download a prebuilt binary for your platform from the
releases page
and place it on your PATH.
Quick start
Authenticate once, then operate.
# 1. Authenticate (saves a profile to ~/.config/grafana-cli/) grafana login # 2. List dashboards grafana dashboard list # 3. Search dashboards by title or tag grafana dashboard list -q "production" --tag monitoring # 4. Get a dashboard as JSON grafana dashboard get <uid> -o json # 5. List datasources grafana datasource list # 6. List firing alerts grafana alert list --state firing # 7. Add a deploy annotation grafana annotation create --text "Deployed v1.2.3" --tags deploy # 8. Pipe JSON output to jq grafana dashboard list -o json | jq '.[].title'
Authentication
Token, basic auth, or saved profile. CLI flags > environment variables > saved profile.
Interactive login
grafana login
Service account token
export GRAFANA_URL=https://grafana.example.com export GRAFANA_TOKEN=glsa_xxxxxxxxxxxx
Basic auth
export GRAFANA_URL=https://grafana.example.com export GRAFANA_USERNAME=admin export GRAFANA_PASSWORD=your-password export GRAFANA_ORG_ID=1
Multiple profiles
grafana login # saves as default grafana config use-profile prod # switch active profile grafana dashboard list --profile staging # one-off override
Commands
Each group has its own --help for full flag and example documentation.
Top-level groups
grafana dashboardList, get, create, delete dashboards (alias: dash, db)grafana datasourceInspect and manage data sourcesgrafana folderOrganize dashboards into foldersgrafana alertView alert rules, instances, and silencesgrafana annotationAdd deploy markers and event annotationsgrafana orgManage organizationsgrafana teamManage teams and team membersgrafana userManage users and current usergrafana service-accountManage service accounts and tokensgrafana configView/set configuration, manage profilesgrafana loginInteractive authentication setupgrafana versionPrint CLI versiongrafana updateSelf-update to the latest releaseOutput formats
grafana dashboard list # table (default) grafana dashboard list -o json # JSON grafana dashboard list -o yaml # YAML
Global flags
-o, --outputOutput format: table, json, yaml--profileConfiguration profile to use--urlGrafana server URL--tokenAPI token or service account token--usernameUsername for basic auth--passwordPassword for basic auth--org-idOrganization ID