Skip to main content

Overview

OpenSRE queries Grafana (Cloud or self-hosted) for logs, metrics, traces, alert rules, and annotations. For a local Minikube lab with Prometheus and a sample app, see Extras.

Prerequisites

  • Grafana instance URL (Cloud stack URL or self-hosted origin)
  • Service account token with read access — see Credentials

Setup

Option 1: Interactive CLI

Provide the instance URL and service account token when prompted.

Option 2: Environment variables

For prod/staging pairs, use GRAFANA_INSTANCES — see Multi-instance integrations.

Option 3: Persistent store

Option 4: Hosted web app (OpenSRE Cloud)

Hosted OpenSRE Cloud is coming soon. Until then, use the local CLI, environment variables, or persistent store above.
When available, organization-wide Grafana connectors will be configured in the hosted web app:
  1. In app.tracer.cloud, go to IntegrationsGrafana
  2. Enter a name, instance URL, and service account token
  3. Click Save
Connect Grafana

Self-signed or internal CA certificates

If Grafana uses a certificate signed by an internal CA, opensre integrations setup grafana prompts for: You can also set these in .env:

Credentials

Create a Grafana service account token with read access. See Grafana service account tokens.
  1. In Grafana, open AdministrationService accounts (or your stack’s equivalent).
  2. Create a service account with read access to the datasources you want OpenSRE to query.
  3. Add a token to that service account and copy it (shown once).
Use this value as GRAFANA_READ_TOKEN (CLI prompt: service account token).

Tools

Deployment and config-change markers are covered on Grafana Annotations. For standalone Tempo (no Grafana proxy), see Grafana Tempo.

Verify

Troubleshooting

Security

  • Prefer a dedicated service account token with read-only access.
  • Prefer GRAFANA_CA_BUNDLE over disabling TLS verification for real internal Grafana.
  • Set GRAFANA_VERIFY_SSL=false only for local/lab instances.
  • Store tokens in .env or your secret manager — not in source control.

Extras

Local Grafana setup (Minikube example)

Use this lab to run Grafana, Prometheus, and a sample app locally, then connect OpenSRE.

Steps

  1. Start Minikube:
  2. Add Helm repositories and update:
  3. Install the kube-prometheus stack:
  4. Install the podinfo sample app:
  5. (Optional) Check pods:
  6. Port-forward podinfo (separate terminal):
  7. Port-forward Prometheus (separate terminal):
  8. Port-forward Grafana on all interfaces (separate terminal):
  9. Allow Prometheus to scrape podinfo ServiceMonitors:
    A JSON merge patch (--type=merge) with {} for a nested object field is a no-op, not a replacement — RFC 7396 merge-patch semantics only remove keys set to null; an empty object leaves the existing matchLabels: {release: kube-stack} in place, so podinfo’s ServiceMonitor (which carries no such label) never gets scraped and this step silently does nothing. Confirmed live: kubectl patch --type=merge here reports "patched (no change)", and podinfo never appears in http://localhost:9090/api/v1/targets until switched to --type=json with an explicit replace operation.

Grafana credentials

Get the admin password:
Username is admin; password is the command output.

Access

Simulate load

Sample Grafana queries

Request rate by status:
p95 latency:
Spike in Error Rate in Grafana

Prometheus alert for high error rate

The alert fires after about 30 seconds of elevated errors. Check http://localhost:9090/alerts.
Prometheus Alert Firing

Connect OpenSRE to the lab Grafana

  1. Get your machine’s LAN IP:
  2. Create a Grafana service account token (Grafana docs).
  3. Run setup and enter:
    For local/lab TLS issues, set GRAFANA_VERIFY_SSL=false or answer the SSL prompts as described in Setup.
    Successful Grafana Integration with OpenSRE

Add Loki and Tempo for full tool coverage

The steps above give OpenSRE working metrics querying and (once a rule/annotation exists) alert-rule and annotation querying, but log search, service-name discovery, and trace querying need Loki and Tempo datasources, which this lab doesn’t install by default. Verified live: without them, those three capabilities return "Loki datasource not found" / "Tempo datasource not found", not real data.
  1. Add the Grafana chart repo and install Loki (bundled with Promtail) and Tempo:
  2. Register both as Grafana datasources (the chart doesn’t auto-provision them):
Promtail’s default relabeling produces job/namespace/pod/app labels on log streams, and the ServiceMonitor stack’s default metric labels are job/service — neither includes a service_name label. Log search and service-name discovery both query Loki’s service_name label specifically, and metrics querying filters on the same label when a service name is passed, so all three return empty against an unmodified stack even though the underlying log/metric data is present. Confirmed live: a Loki label query and a service_name="podinfo" Mimir query both returned nothing until the two relabelings below were added; a real user’s own services will hit the same gap unless they already emit or relabel a service_name label.
  1. Add a service_name relabel to Promtail (derived from the pod’s app.kubernetes.io/name label) by upgrading the release with an extra relabel config alongside Promtail’s defaults:
    Keep the heredoc terminator (EOF) flush against the left margin, not indented to match this list item — <<'EOF' requires an exact, unindented match to end the here-document. An indented closing line is swallowed as YAML content instead of ending the file, and the helm upgrade line after it gets swallowed too, silently turning into dead text inside the values file instead of running. Confirmed live by copy-pasting an indented version of this exact block.
  2. Enable request tracing on podinfo — it ships an OpenTelemetry exporter but keeps it disabled until both --otel-service-name and an OTLP endpoint are set (the chart’s extraEnvs alone is not enough; confirmed via podinfo --help, which states tracing is disabled unless --otel-service-name is set):
    The upgrade replaces the podinfo pod, so re-run the port-forward from Steps (step 6) if it’s still attached to the old pod.
  3. Add the same service_name relabel to the podinfo ServiceMonitor for metrics (kubectl patch here, since the podinfo chart doesn’t expose metricRelabelings as a values key):
    Do this after the tracing upgrade above, not before. helm upgrade re-applies the ServiceMonitor via server-side apply; if kubectl patch already owns .spec.endpoints from a prior patch, a later helm upgrade podinfo fails with Apply failed with 1 conflict: conflict with "kubectl-patch". Confirmed live by running these two steps in the opposite order.
  4. Generate some traffic so there’s real data for every tool, then confirm each datasource actually has it:

Ask the agent

Then start opensre and ask about the failing app from Steps, e.g. Why is podinfo’s error rate high? Check Grafana logs, metrics, and traces. All 6 registered tools return real data against this lab once the datasources and relabelings above are in place — confirmed by direct calls to each tool: metrics querying (real http_requests_total series, service_name="podinfo"), log search (real podinfo log lines), trace querying (real spans like GET /status/{code:[0-9]+} from the generated load), service-name discovery (["podinfo", ...]), alert-rule querying (the rule created via /api/v1/provisioning/alert-rules below), and annotation querying (an annotation created via /api/annotations).
Alert-rule and annotation querying use Grafana’s own alerting/annotation APIs, not the raw PrometheusRule CRD from Prometheus alert for high error rate — that CRD is evaluated by Prometheus itself and never becomes a Grafana-managed rule. To exercise these two tools with real data, create a rule and annotation through Grafana directly, for example:

Teardown

If you started separate port-forward terminals per Steps, Ctrl-C each one first (deleting the cluster also kills them, but not always cleanly on every platform).