agentleFS
abdullahkhawerabdullahkhawer/devops-skills/skills/grafana-cli/SKILL.md

grafana-cli

Skill8 starsChanged 6 months agoApache-2.0View on GitHub

Perform Grafana operations using the Grafana HTTP API via curl. Use for querying dashboards, datasources, alerts, and annotations.

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 9 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the instance and rules below when constructing all Grafana API commands.

    line 8
  2. Distinctive:

    Update the table below with your Grafana instance URLs and corresponding token file paths:

    line 12
  3. Distinctive:

    If the target instance is unclear, ask the user before running any command.

    line 19
  4. Very specific:

    All API calls use curl with the token read from the instance's token file (see instance table above):

    line 37
  5. Distinctive:

    NEVER target any Grafana instance not listed in the instance table above.

    line 96
  6. Distinctive:

    Update the instance table with your actual Grafana URLs before using this skill.

    line 97
  7. Distinctive:

    NEVER print, display, log, or store the contents of any token file or credential value.

    line 98
  8. Very specific:

    Always read the token inline with $(cat <TOKEN_FILE>) — never hardcode a token value in a command.

    line 99
  9. Very specific:

    Always pass -s (silent) to curl to suppress progress output, and pipe through jq for readable output.

    line 100
  10. Distinctive:

    NEVER run DELETE or destructive PUT/POST operations without explicit user instruction.

    line 101
  11. Distinctive:

    If a dashboard UID, datasource ID, or folder UID is unfamiliar, look it up with a read-only call first.

    line 102
  12. Distinctive:

    If the required token file does not exist, inform the user and stop.

    line 103
  13. Very specific:

    All list endpoints may be paginated — check the response for page and perpage fields and iterate if needed.

    line 104

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Grafana CLI Skill

Use the instance and rules below when constructing all Grafana API commands.

Instances

Update the table below with your Grafana instance URLs and corresponding token file paths:

EnvironmentBase URLToken File
Productionhttps://<your-grafana-prod-url>~/.grafana/prod.token
Staginghttps://<your-grafana-staging-url>~/.grafana/staging.token

If the target instance is unclear, ask the user before running any command.

Prerequisites (one-time setup by user)

Generate a Grafana API token for each instance you intend to use and save it to the corresponding token file (see instance table above). Never print or display token values. Do not perform these steps yourself.

For each instance:

  1. Navigate to <BASE_URL> → Administration → Users and access → Service accounts → Add service account
  2. Enter a display name and role, then click Create
  3. On the service account page, click Add service account token and copy the generated token
  4. Save it:
mkdir -p ~/.grafana && echo "<your-api-token>" > <TOKEN_FILE> && chmod 600 <TOKEN_FILE>

Command Format

All API calls use curl with the token read from the instance's token file (see instance table above):

curl -s -H "Authorization: Bearer $(cat <TOKEN_FILE>)" \
  "<BASE_URL>/api/<endpoint>" | jq .

Example (production):

curl -s -H "Authorization: Bearer $(cat ~/.grafana/prod.token)" \
  "https://<your-grafana-prod-url>/api/health" | jq .

Available API Endpoints

Read-only (safe, no confirmation needed)

EndpointMethodDescription
/api/orgGETGet current organisation info
/api/userGETGet current authenticated user
/api/datasourcesGETList all datasources
/api/datasources/<id>GETGet datasource by ID
/api/dashboards/homeGETGet the home dashboard
/api/search?query=<term>GETSearch dashboards and folders
/api/dashboards/uid/<uid>GETGet dashboard by UID
/api/foldersGETList all folders
/api/folders/<uid>GETGet folder by UID
/api/alertsGETList legacy alerts
/api/v1/provisioning/alert-rulesGETList all alert rules
/api/v1/provisioning/alert-rules/<uid>GETGet alert rule by UID
/api/annotationsGETList annotations
/api/healthGETCheck Grafana health

Mutating operations (confirm with user before running)

EndpointMethodDescription
/api/dashboards/dbPOSTCreate or update a dashboard
/api/foldersPOSTCreate a folder
/api/folders/<uid>PUTUpdate a folder
/api/annotationsPOSTCreate an annotation
/api/annotations/<id>PUTUpdate an annotation
/api/v1/provisioning/alert-rulesPOSTCreate an alert rule
/api/v1/provisioning/alert-rules/<uid>PUTUpdate an alert rule

Never run — requires explicit human approval

EndpointMethodReason
/api/dashboards/uid/<uid>DELETEIrreversible dashboard deletion
/api/folders/<uid>DELETEDeletes folder and all its dashboards
/api/datasources/<id>DELETERemoves datasource used by dashboards
/api/annotations/<id>DELETEIrreversible annotation deletion
/api/v1/provisioning/alert-rules/<uid>DELETERemoves alert rule permanently
/api/admin/users/<id>DELETEDeactivates a user account

Rules

  • NEVER target any Grafana instance not listed in the instance table above. If a URL references a different host, stop and ask the user to confirm.
  • Update the instance table with your actual Grafana URLs before using this skill.
  • NEVER print, display, log, or store the contents of any token file or credential value.
  • Always read the token inline with $(cat <TOKEN_FILE>) — never hardcode a token value in a command.
  • Always pass -s (silent) to curl to suppress progress output, and pipe through jq for readable output.
  • NEVER run DELETE or destructive PUT/POST operations without explicit user instruction.
  • If a dashboard UID, datasource ID, or folder UID is unfamiliar, look it up with a read-only call first.
  • If the required token file does not exist, inform the user and stop. Do not attempt to find or guess the token.
  • All list endpoints may be paginated — check the response for page and perpage fields and iterate if needed.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.