Skip to content
CloudOps
Newsletter
All prompts
AI for Prometheus & Monitoring Difficulty: Intermediate ClaudeChatGPT

Grafana Alloy Agent Configuration Prompt

Configure Grafana Alloy (formerly Grafana Agent) — unified collector for metrics, logs, traces; River configuration; component pipeline.

Target user
SREs deploying Grafana's collector
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior platform engineer who has deployed Grafana Alloy — the unified collector that replaces Grafana Agent, Promtail, OTel Collector.

I will provide:
- The data being collected
- Use case
- Current config

Your job:

1. **Alloy basics**:
   - Successor to Grafana Agent
   - Uses River syntax (similar to HCL)
   - Component-based pipeline
   - Supports Prometheus scrape, Loki, Tempo, OTel
2. **For Prometheus scrape**:
   - `prometheus.scrape` component
   - `prometheus.remote_write` to Mimir/Prom
3. **For Loki / logs**:
   - `loki.source.file` or `loki.source.kubernetes`
   - `loki.write` to Loki
4. **For Tempo / traces**:
   - `otelcol.receiver.otlp`
   - `otelcol.exporter.otlp` to Tempo
5. **For Kubernetes discovery**:
   - `discovery.kubernetes`
   - Filter by role
6. **For component pipeline**:
   - Components reference each other by name
   - Forward data via expressions
7. **For migration from older**:
   - Convert config from Grafana Agent
   - `alloy convert` tool
8. **For multi-tenant**:
   - Tenant headers per remote_write

Mark DESTRUCTIVE: removing Alloy with no replacement (data gap), version downgrade losing config, sending to wrong endpoint.

---

Data collected: [DESCRIBE]
Use case: [DESCRIBE]
Current config: [DESCRIBE]

Why this prompt works

Alloy is the modern unified collector. This prompt walks it.

How to use it

  1. Pick components for data types.
  2. Define pipeline.
  3. Verify references.
  4. Tune buffers.

Useful commands

# Validate config
alloy fmt config.river
alloy run --config.file=config.river --dry-run

# Convert from Grafana Agent
alloy convert --source-format=static --target-format=alloy agent-config.yaml -o config.river

# Run
alloy run config.river

# UI
# http://localhost:12345

Example config (River)

// Discovery: Kubernetes pods
discovery.kubernetes "pods" {
  role = "pod"
}

// Scrape metrics
prometheus.scrape "k8s" {
  targets    = discovery.kubernetes.pods.targets
  forward_to = [prometheus.remote_write.mimir.receiver]

  scrape_interval = "30s"
}

// Remote write to Mimir
prometheus.remote_write "mimir" {
  endpoint {
    url = "https://mimir.example.com/api/v1/push"

    basic_auth {
      username = "tenant1"
      password = env("MIMIR_PASSWORD")
    }
  }
}

// Loki log scraping
loki.source.kubernetes "pods" {
  targets    = discovery.kubernetes.pods.targets
  forward_to = [loki.process.parse.receiver]
}

loki.process "parse" {
  forward_to = [loki.write.loki.receiver]

  stage.json {
    expressions = {
      level   = "level",
      message = "msg",
    }
  }

  stage.labels {
    values = { level = "" }
  }
}

loki.write "loki" {
  endpoint {
    url = "https://loki.example.com/loki/api/v1/push"
  }
}

// OTel traces
otelcol.receiver.otlp "default" {
  grpc { endpoint = "0.0.0.0:4317" }
  http { endpoint = "0.0.0.0:4318" }

  output {
    traces = [otelcol.processor.batch.default.input]
  }
}

otelcol.processor.batch "default" {
  output {
    traces = [otelcol.exporter.otlp.tempo.input]
  }
}

otelcol.exporter.otlp "tempo" {
  client {
    endpoint = "tempo.example.com:4317"
  }
}

Kubernetes deployment

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: alloy
spec:
  template:
    spec:
      containers:
      - name: alloy
        image: grafana/alloy:latest
        args:
        - run
        - --server.http.listen-addr=0.0.0.0:12345
        - --storage.path=/var/lib/alloy
        - /etc/alloy/config.river
        volumeMounts:
        - name: config
          mountPath: /etc/alloy
        - name: data
          mountPath: /var/lib/alloy
        ports:
        - { name: http, containerPort: 12345 }
        - { name: otlp-grpc, containerPort: 4317 }
        - { name: otlp-http, containerPort: 4318 }
      volumes:
      - name: config
        configMap: { name: alloy-config }
      - name: data
        emptyDir: {}

Common findings this catches

  • Component reference error → name typo.
  • No data at backend → output not connected.
  • Migration issues → use convert tool.
  • Memory growth → buffer tuning.
  • High cardinality dropped → relabel.
  • Tenant header missing → multi-tenant.
  • eBPF needs privileged → container caps.

When to escalate

  • Mass migration from Grafana Agent — staged.
  • Complex pipeline design — engineering.
  • Performance at scale — capacity.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week