Monitoring
Grafana CLI
Grafana CLI commands for dashboard and plugin management.
27 commands
Windows
MacOS
Linux
#dashboards
#visualization
Plugin Management
grafana-cli plugins install grafana-clock-panel # Install a plugin
List all available plugins
grafana-cli plugins list-remote
List installed plugins
grafana-cli plugins ls
Update all installed plugins
grafana-cli plugins update-all
grafana-cli plugins remove grafana-clock-panel # Remove a plugin
grafana-cli plugins install grafana-piechart-panel --pluginsDir /custom/path # Install to custom directory
Admin Commands
grafana-cli admin reset-admin-password newpassword # Reset admin password
Run database migrations
grafana-cli admin data-migration
Generate secret key for encryption
grafana-cli admin generate-secret-key
grafana server -config /etc/grafana/grafana.ini # Start Grafana with config file
Configuration
Show current server settings
grafana-cli admin settings
grafana server -homepath /usr/share/grafana # Start with custom home path
grafana-cli --config /etc/grafana/grafana.ini admin reset-admin-password newpass # Reset password with custom config
grafana-cli plugins install --pluginUrl https://example.com/plugin.zip custom-plugin # Install plugin from URL
API Usage
curl -H "Authorization: Bearer API_KEY" http://localhost:3000/api/dashboards/home # Get home dashboard
curl -H "Authorization: Bearer API_KEY" http://localhost:3000/api/search?query=test # Search dashboards
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer API_KEY" -d @dashboard.json http://localhost:3000/api/dashboards/db # Create dashboard via API
curl -H "Authorization: Bearer API_KEY" http://localhost:3000/api/datasources # List all data sources
curl -H "Authorization: Bearer API_KEY" http://localhost:3000/api/org # Get current organization
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer API_KEY" -d '{"name":"Prometheus","type":"prometheus","url":"http://localhost:9090","access":"proxy"}' http://localhost:3000/api/datasources # Add data source
Backup
curl -H "Authorization: Bearer API_KEY" http://localhost:3000/api/dashboards/uid/DASHBOARD_UID > backup.json # Export dashboard as JSON
grafana-cli admin export-data --directory /backup # Export Grafana data
sqlite3 /var/lib/grafana/grafana.db .dump > grafana-backup.sql # Backup SQLite database
curl -H "Authorization: Bearer API_KEY" http://localhost:3000/api/snapshots # List dashboard snapshots
Quick Commands
Install a Grafana plugin
grafana-cli plugins install grafana-clock-panel
Reset the Grafana admin password
grafana-cli admin reset-admin-password newpassword
Get home dashboard via Grafana API
curl -H "Authorization: Bearer API_KEY" http://localhost:3000/api/dashboards/home