$ grafana

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.

MIT License macOS · Linux · Windows Go 1.21+

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 sources
grafana folderOrganize dashboards into folders
grafana alertView alert rules, instances, and silences
grafana annotationAdd deploy markers and event annotations
grafana orgManage organizations
grafana teamManage teams and team members
grafana userManage users and current user
grafana service-accountManage service accounts and tokens
grafana configView/set configuration, manage profiles
grafana loginInteractive authentication setup
grafana versionPrint CLI version
grafana updateSelf-update to the latest release
Output 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
Full reference on github.com/piyush-gambhir/grafana-cli ↗