← 返回命令列表

Linux command

gcx 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Authenticate

gcx auth login --server [https://myorg.grafana.net]

Run a PromQL

gcx metrics query '[rate(http_requests_total[5m])]' --since [1h]

Run a LogQL

gcx logs query '[{app="api"} |= "error"]' --since [30m]

List alert rules

gcx alert rules list --state [firing]

Export dashboards and folders

gcx resources pull -p [./resources] -o [yaml]

Validate and push

gcx resources push -p [./resources] --on-error [abort]

List Service Level

gcx slo definitions list

Ask the Grafana Assistant

gcx assistant prompt "[why is latency high on checkout?]"

Generate shell completions

gcx completion [bash]

说明

gcx is the official command-line interface for Grafana Cloud, with first-class support for querying signals (metrics, logs, traces, profiles), managing alert rules and SLOs, and performing observability-as-code workflows against dashboards and folders. It is designed to be usable both by humans and by agentic coding assistants that need structured access to production observability data. Each Grafana product has its own top-level command (metrics, logs, traces, profiles, alert, slo, synth, irm, k6, fleet, assistant, and so on), and resources can be exported to local YAML or JSON with gcx resources pull and pushed back with gcx resources push, enabling GitOps-style management of Grafana objects.

参数

auth login --server _URL_
Start browser-based OAuth login against a Grafana instance.
config set _key value_
Set a configuration value (e.g. contexts.my-grafana.grafana.token).
config use-context _name_
Switch the active configuration context.
config check
Verify the active authentication and connectivity.
metrics query _PROMQL_
Execute a PromQL query against Prometheus / Mimir.
logs query _LOGQL_
Execute a LogQL query against Loki.
traces query _QUERY_
Query trace data from Tempo.
profiles query _QUERY_
Query profiling data from Pyroscope.
alert rules list --state _STATE_
Display alert rules and their state, health, and pause status.
alert groups list
Show alert groups.
resources pull -p _DIR_ -o _FORMAT_
Export dashboards, folders, and other resources to local files.
resources push -p _DIR_ --dry-run --on-error _MODE_
Deploy local resources back to Grafana.
resources delete, edit, validate, get
Manage resources: remove, interactively modify, check, or list them.
slo definitions list, slo reports list
Manage Service Level Objectives.
synth checks list, synth probes list
Synthetic monitoring checks and probes.
irm oncall schedules list, irm incidents list
Incident response and on-call management.
k6 load-tests list, k6 runs list
Load testing with k6.
fleet pipelines list, fleet collectors list
Fleet management.
kg status, kg search, kg entities show
Grafana knowledge graph.
assistant investigations list, assistant prompt _TEXT_
Drive the Grafana Assistant AI.
frontend apps list
Frontend observability.
aio11y conversations list, aio11y agents list
AI observability.
dev scaffold, dev import, dev serve, dev lint
Observability-as-code workflow: scaffold, import, live-reload, and lint.
api _PATH_
Raw passthrough to the Grafana HTTP API.

FAQ

What is the gcx command used for?

gcx is the official command-line interface for Grafana Cloud, with first-class support for querying signals (metrics, logs, traces, profiles), managing alert rules and SLOs, and performing observability-as-code workflows against dashboards and folders. It is designed to be usable both by humans and by agentic coding assistants that need structured access to production observability data. Each Grafana product has its own top-level command (metrics, logs, traces, profiles, alert, slo, synth, irm, k6, fleet, assistant, and so on), and resources can be exported to local YAML or JSON with gcx resources pull and pushed back with gcx resources push, enabling GitOps-style management of Grafana objects.

How do I run a basic gcx example?

Run `gcx auth login --server [https://myorg.grafana.net]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does auth login --server _URL_ do in gcx?

Start browser-based OAuth login against a Grafana instance.