From gcx
Discovers datasources, metrics, labels, log streams, and targets in Grafana via gcx CLI. Use when identifying available monitoring data or datasource UIDs.
npx claudepluginhub grafana/gcx --plugin gcxThis skill uses the workspace's default tool permissions.
> If gcx is not configured, see the setup-gcx skill first.
Query and manage Grafana dashboards, alert rules, and data sources via HTTP API. Useful for viewing dashboards, troubleshooting alerts, checking metrics, or on mentions of Grafana, monitoring, observability.
Guides Grafana OSS features: building dashboards, configuring panels and data sources, provisioning YAML, template variables, alerting, RBAC, users, and PromQL/LogQL/TraceQL queries.
Share bugs, ideas, or general feedback.
If gcx is not configured, see the setup-gcx skill first.
Start by identifying all datasources in the Grafana instance.
# List all datasources
gcx datasources list
# Filter by type if you know what you need
gcx datasources list --type prometheus
gcx datasources list --type loki
Expected output: Table showing UID, NAME, TYPE, URL, and DEFAULT columns.
Important: Always use the UID (not the name) in subsequent commands.
Choose the appropriate exploration path based on datasource type.
# List all available labels
gcx metrics labels -d <datasource-uid>
# Get values for a specific label to understand what's being monitored
gcx metrics labels -d <datasource-uid> --label job
# List all available metrics with descriptions
gcx metrics metadata -d <datasource-uid>
# Check what systems are being scraped
gcx metrics targets -d <datasource-uid>
Expected output: Tables showing labels, metrics, or targets depending on command.
# List all available labels
gcx logs labels -d <datasource-uid>
# Get values for a specific label
gcx logs labels -d <datasource-uid> --label job
# List log streams matching a selector (required)
gcx logs series -d <datasource-uid> -M '{job="varlogs"}'
Expected output: Tables showing labels or log stream series.
Note: The series command requires at least one -M (match) selector using LogQL syntax.
Once you've identified available data, verify with a test query.
# For Prometheus - instant query
gcx metrics query <datasource-uid> 'up'
# For Prometheus - range query
gcx metrics query <datasource-uid> 'rate(http_requests_total[5m])' --from now-1h --to now
Expected output: Table showing metric values with labels and timestamps.
To avoid passing -d <uid> repeatedly, configure defaults:
# Set default Prometheus datasource
gcx config set contexts.<context-name>.default-prometheus-datasource <uid>
# Set default Loki datasource
gcx config set contexts.<context-name>.default-loki-datasource <uid>
After setting defaults, you can omit the -d flag in datasource commands.
User says: "What HTTP metrics are available?"
Actions:
gcx datasources list --type prometheusgcx metrics metadata -d <uid> -o json | jq '.data | to_entries[] | select(.key | contains("http"))'gcx metrics metadata -d <uid> --metric http_requests_totalResult: Metric name, type (counter/gauge), and help text showing what the metric measures.
User says: "What applications are sending logs to Loki?"
Actions:
gcx datasources list --type lokigcx logs labels -d <uid>gcx logs labels -d <uid> --label jobgcx logs series -d <uid> -M '{job="varlogs"}'Result: List of job names and their associated log streams.
User says: "My dashboard shows no data for service X"
Actions:
gcx datasources get <uid>gcx metrics targets -d <uid>gcx metrics labels -d <uid> --label jobgcx metrics query <uid> 'up{job="service-x"}'Result: Identifies whether datasource is misconfigured, service isn't being scraped, or label selectors are wrong.
User says: "Show me all log streams from the production namespace"
Actions:
gcx datasources list --type lokigcx logs labels -d <uid> --label namespacegcx logs series -d <uid> -M '{namespace="production"}'Result: Table showing all label combinations for log streams in the production namespace.
Cause: The -d flag was omitted and no default datasource is configured.
Solution:
# Option 1: Pass the UID explicitly
gcx metrics labels -d <datasource-uid>
# Option 2: Set a default datasource
gcx config set contexts.<context-name>.default-prometheus-datasource <uid>
Cause: The loki series command was called without a -M flag.
Solution: Loki series requires at least one LogQL selector:
# Correct
gcx logs series -d <uid> -M '{job="varlogs"}'
# Wrong - will fail
gcx logs series -d <uid>
Cause: Shell is interpreting quotes in the LogQL selector incorrectly.
Solution: Use single quotes around the entire selector:
# Correct - single quotes outside
gcx logs series -d <uid> -M '{name="value", cluster="prod"}'
# Wrong - shell interprets quotes incorrectly
gcx logs series -d <uid> -M {name="value"}
Cause: The datasource UID doesn't exist or you don't have access to it.
Solution:
gcx datasources listgcx config current-contextgcx datasources get <uid>Cause: Datasource has no data or hasn't scraped/ingested anything yet.
Solution:
gcx metrics targets -d <uid>gcx logs labels -d <uid>gcx datasources get <uid>For detailed patterns, LogQL syntax guide, and advanced discovery workflows, see:
references/discovery-patterns.md - Common discovery patterns and workflowsreferences/logql-syntax.md - LogQL selector syntax guideAll commands support -o json or -o yaml for programmatic use:
# Get JSON output for piping to jq
gcx metrics labels -d <uid> -o json
# Example: Count total metrics
gcx metrics metadata -d <uid> -o json | jq '.data | length'
Default output is table format for human readability.