add-datasource
Use for the implementation workflow that adds gcx CLI support for a datasource type not registered in internal/datasources/providers — query client, command…
Creates, updates, syncs, and deletes Grafana SLO definitions via gcx with dry-run validation and GitOps pull/push workflows. Use when the user wants to create, update, pull, push, or delete SLO definitions. Trigger on phrases like "create an SLO", "update SLO objective", "push
$ npx -y skills add grafana/gcx --skill slo-manage --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/slo-manageContext preview
The summary Claude sees to decide when to auto-load this skill.
Creates, updates, syncs, and deletes Grafana SLO definitions via gcx with dry-run validation and GitOps pull/push workflows. Use when the user wants to create, update, pull, push, or delete SLO definitions. Trigger on phrases like "create an SLO", "update SLO objective", "push
name: slo-manage description: Creates, updates, syncs, and deletes Grafana SLO definitions via gcx with dry-run validation and GitOps pull/push workflows. Use when the user wants to create, update, pull, push, or delete SLO definitions. Trigger on phrases like "create an SLO", "update SLO objective", "push SLO", "pull SLOs", "delete SLO", or "GitOps sync SLOs". For checking SLO health or status, use slo-check-status instead. For investigating a breaching SLO, use slo-investigate instead. allowed-tools: Bash, Read, Write, Edit
Create, update, sync, and delete SLO definitions using gcx.
1. Use gcx commands exclusively — do not call Grafana APIs directly 2. Always run `--dry-run` before any push operation; proceed only if dry-run succeeds 3. Trust the user's expertise — skip explanations of SLO concepts 4. Use `-o json` for agent processing; default table/yaml for user display 5. Auto-resolve datasource UIDs; only ask if auto-discovery fails
Select query type based on what the user describes:
| User describes | Query type | |----------------|------------| | "percentage of successful requests", "success rate", "error rate" | `ratio` | | "raw PromQL expression", "custom metric formula" | `freeform` | | "metric above/below threshold", "latency under X ms", "availability percentage" | `threshold` |
Use the metric name suffix to pick the query type when the user provides a metric name:
| Metric suffix / type | Query type | Rationale | |----------------------|------------|-----------| | `_total` counter | `ratio` | success_total / all_total | | `_bucket` histogram | `threshold` | use le-bound threshold on quantile | | `_gauge` or `up` metric | `threshold` | compare to fixed threshold | | None of the above | `freeform` | last resort only |
**Guardrail:** Freeform is a last resort. Before choosing freeform, verify the SLI cannot be expressed as ratio or threshold.
**Hard requirement:** Freeform queries MUST use `$__rate_interval` in all `rate()`/`increase()` calls. Literal ranges like `[5m]` are rejected by the SLO API.
gcx datasources list --type prometheus
Use the UID from the output. Some stacks do not populate `type` in the list response, so the filter can come back empty even though Prometheus datasources exist — in that case list everything and pick the canonical Grafana Cloud Prometheus entry (name like `grafanacloud-<stack>-prom`):
gcx datasources list
If that leaves zero or multiple plausible Prometheus candidates, ask the user which UID to use rather than guessing (the stack's `default: true` datasource is not necessarily Prometheus).
For complete ratio, freeform, and threshold templates (including alerting, labels, and folder fields), see [references/slo-templates.md](references/slo-templates.md). Key structure:
apiVersion: slo.ext.grafana.app/v1alpha1
kind: SLO
metadata:
name: "" # leave empty for new SLO (server assigns UUID on create)
spec:
name: "my-api-availability"
description: "API availability over 28 days"
query:
type: ratio # freeform | ratio | threshold
ratio: # field matches type
successMetric:
prometheusMetric: http_requests_total{status!~"5.."}
totalMetric:
prometheusMetric: http_requests_total
groupByLabels: [cluster, service]
objectives:
- value: 0.999 # 0.9 to 0.9999 typical range
window: 28d # 7d | 14d | 28d | 30d
destinationDatasource:
uid: <prometheus-uid>gcx slo definitions push slo.yaml --dry-run gcx slo definitions push slo.yaml
**Push semantics:**
After creation, server assigns UUID. Run `gcx slo definitions list` to confirm.
gcx slo definitions get <UUID> -o yaml > slo.yaml
Edit the relevant fields (objective value, query, alerting, etc.). Do not modify `metadata.name` (UUID) or `readOnly` fields.
gcx slo definitions push slo.yaml --dry-run gcx slo definitions push slo.yaml
gcx slo definitions pull -d ./slos # Writes to ./slos/SLO/<uuid>.yaml
gcx slo definitions push ./slos/SLO/*.yaml --dry-run gcx slo definitions push ./slos/SLO/*.yaml
gcx slo definitions list gcx slo definitions get <UUID>
Confirm the UUID and name with the user before deletion.
gcx slo definitions delete <UUID> --force
Use `--force` to skip the confirmation prompt when running in agent mode (there is no `-f` shorthand on delete).
**Objective values** (stored as 0–1, displayed as percentage):
**Window options:** `7d`, `14d`, `28d`, `30d`
**Alerting best practices:**
**Labels:** Use consistent label keys (team, service, environment, tier) for filtering and grouping.
**GroupByLabels** (ratio/threshold queries): Add labels like `cluster`, `ser
Grafana — in your terminal and your agentic coding environment. gcx works with Grafana Cloud, Enterprise, and OSS (Grafana 12+). See the compatibility matrix for details. Query production. Investigate alerts. Let the Assistant root-cause issues.
Repo: grafana/gcx
Use for the implementation workflow that adds gcx CLI support for a datasource type not registered in internal/datasources/providers — query client, command…
Use for the implementation workflow once a capability is already classified as a Grafana Cloud product provider (SLO, OnCall, Synthetic Monitoring, k6, ML,…
Regenerate the gcx marketing bento-box slide (slide.html) with verified commands from the current codebase. Builds a fresh binary and reflects against the…
Guides a contributor and their coding agent through adding or extending a capability in the grafana/gcx codebase: deciding whether a new command is needed and…
Reference for porting a Grafana Cloud product from the legacy grafana-cloud-cli into a gcx provider — adapter, schema/example registration, CRUD redirect…