| name | grafana-assistant-cli |
| description | Use the grafana-assistant CLI to interact with Grafana Assistant via A2A API. Covers installation, configuration, prompting, keeping conversation context, and practical patterns for ops investigations. Use when the user mentions grafana-assistant, Grafana Assistant CLI, assistant tunnel, or wants to query a Grafana instance via the assistant. |
grafana-assistant CLI
CLI tool for interacting with Grafana Assistant via the A2A API.
Prerequisites
The grafana-assistant binary must already be installed and available on $PATH. Do not attempt to install it automatically. If the command is not found, stop and tell the user to install it first.
Installation instructions and pre-built binaries: github.com/grafana/assistant-cli
A Docker image is also available: github.com/grafana/assistant-cli/pkgs
Configuration
Config file locations (first found wins)
GRAFANA_ASSISTANT_CONFIG env var (if set)
./grafana-assistant.yaml (current directory, use --local flag)
~/.config/grafana-assistant/config.yaml
Config file format
current-instance: prod
instances:
localhost:
url: http://localhost:3000
token: glsa_abcd1234
prod:
url: https://mystack.grafana.net
token: ${GRAFANA_PROD_TOKEN}
projects:
- name: my-app
path: ~/projects/my-app
tunnel:
tools:
filesystem:
allowed_paths: [/var/log/myapp]
deny_paths: ["**/*.key", "**/secrets.yaml"]
terminal:
allowed_commands: [git, kubectl, docker]
deny_commands: ["rm -rf"]
passthrough_env: [AWS_PROFILE, KUBECONFIG]
Environment variables
| Variable | Description |
|---|
GRAFANA_URL | Grafana instance URL (overrides config) |
GRAFANA_SA_TOKEN | Service account token (overrides config) |
GRAFANA_ASSISTANT_CONFIG | Override config file path |
Credential resolution priority
--url and --token flags
GRAFANA_URL and GRAFANA_SA_TOKEN env vars
--instance <name> flag
current-instance from config file
Quick setup
grafana-assistant config set-instance mystack --url https://mystack.grafana.net
grafana-assistant config use-instance mystack
grafana-assistant auth
grafana-assistant chat
The Assistant CLI User role is required for browser auth. Users with Editor role or above get this automatically. For custom roles, include the grafana-assistant-app.tokens:access permission.
Managing instances
grafana-assistant config set-instance <name> -u <url> -t <token>
grafana-assistant config use-instance <name>
grafana-assistant config current
grafana-assistant config list
grafana-assistant config delete-instance <name>
grafana-assistant config path
Token supports env var references: -t '${MY_TOKEN_VAR}'
Managing projects
Projects are named directories the assistant can access via the tunnel.
grafana-assistant config add-project <name> <path>
grafana-assistant config list-projects
grafana-assistant config remove-project <name>
Prompting (non-interactive, primary mode for agent use)
grafana-assistant prompt sends a single message and returns the response. This is the primary command to use from Cursor.
grafana-assistant prompt "your message here"
grafana-assistant prompt "your message" --json
grafana-assistant prompt "your message" -c <context-id>
grafana-assistant prompt "your message" -a <agent-id>
grafana-assistant prompt "your message" --wait=false
Keeping conversation context
Each prompt starts a new, independent conversation by default. To thread follow-up messages into the same conversation (so the assistant remembers prior context), you must:
- Use
--json on the first prompt to capture the contextId
- Pass
-c <contextId> on all subsequent prompts
grafana-assistant prompt "Show me metrics for the assistant service in ops-eu-south-0" --json
grafana-assistant prompt "Now break those down by handler label" -c 62a8823a-... --json
Caveats:
- Without
-c, every prompt is a brand new conversation with no memory.
- If context threading fails (e.g. "context was not created by CLI"), include relevant prior findings directly in the prompt text instead.
- For long multi-step investigations, including key findings inline is often more reliable than depending on context threading.
JSON output format
{
"taskId": "a2a-xxx",
"contextId": "uuid",
"agentId": "grafana_assistant_cli",
"status": "completed",
"response": "The assistant's full text response..."
}
Possible status values: completed, failed, timeout, canceled, unknown.
Chatting (interactive)
Opens a full-screen TUI. Context is maintained automatically within the session.
grafana-assistant chat
grafana-assistant chat -i <instance>
grafana-assistant chat -a <agent-id>
grafana-assistant chat --continue
grafana-assistant chat -c <context-id>
grafana-assistant chat --timeout 600
In-chat commands: /clear or /new (new conversation), /exit or /quit or Ctrl+C (quit), /help.
Listing agents
grafana-assistant agents
grafana-assistant agents --json
grafana-assistant agents -i <instance>
Generating AGENTS.md
Generate an AGENTS.md file for AI coding agents:
grafana-assistant agents-md <target-directory>
grafana-assistant agents-md <target-directory> --dry-run
grafana-assistant agents-md <target-directory> -o AGENTS.md
grafana-assistant agents-md <target-directory> --force
grafana-assistant agents-md <target-directory> --non-interactive
Assistant Tunnel
The tunnel allows Grafana Assistant to execute tools on your local machine.
grafana-assistant tunnel auth
grafana-assistant tunnel connect
grafana-assistant tunnel connect --all
grafana-assistant tunnel connect --terminal
Daemon management
grafana-assistant tunnel daemon install
grafana-assistant tunnel daemon install --all
grafana-assistant tunnel daemon install --start-on-login=false
grafana-assistant tunnel daemon start|stop|restart|status
grafana-assistant tunnel daemon logs [--follow]
grafana-assistant tunnel daemon uninstall
Default security
Filesystem: read-only, project-scoped, blocks ~/.ssh, ~/.gnupg, ~/.aws/credentials, **/.env, **/secrets.yaml, **/*.pem, **/*.key. File size limit: 1MB.
Terminal: blocks dangerous commands (rm -rf /, mkfs, dd, fork bombs), minimal environment by default. Configurable via allow/deny lists in config.
Practical patterns for agent use
Shell permissions
The CLI makes HTTPS requests to Grafana. Always use required_permissions: ["all"] in Shell tool calls — this avoids TLS certificate verification failures from sandbox restrictions.
Timeout handling
Prompts can take 30s–300s depending on how many tools the assistant invokes. Set block_until_ms to at least 300000 (5 min) for complex queries.
What the CLI agent can do
The CLI agent is a read-only Grafana Assistant. It queries and analyzes data but cannot modify anything in Grafana.
Capabilities:
- Query metrics (PromQL, Graphite), logs (LogQL), traces (TraceQL), profiles, SQL, and more across all configured datasources
- Discover datasources, metric names, label values, and log streams
- Search dashboards and read panel definitions
- Search Grafana docs and blog posts
- Query alert history, on-call schedules, and incidents
- Query Asserts entity health, graph, and RCA patterns
- Query infrastructure memory service
Workflows it follows:
- Quick data query: discovers datasources → discovers metric/log names → executes query → presents findings
- Investigation: follows signals across metrics → logs → traces to find probable cause
- Q&A / doc search: answers Grafana/observability questions using docs
Not available in CLI (web/Slack only):
- Dashboard creation/modification
- Alert rule and silence management
- Navigation to Grafana pages