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
- Pick components for data types.
- Define pipeline.
- Verify references.
- 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
-
Loki Log Aggregation Design Prompt
Design Loki log aggregation — single-binary vs distributed, retention, label strategy, LogQL queries, multi-tenancy.
-
OpenTelemetry on Kubernetes Collector Design Prompt
Design and debug the OpenTelemetry Collector on Kubernetes — agent vs gateway, receivers/processors/exporters, sidecar vs DaemonSet, traces/metrics/logs pipelines.
-
Prometheus Remote Write & Long-term Storage Prompt
Configure remote write to long-term storage — Thanos Receive, Cortex/Mimir, VictoriaMetrics, troubleshoot queue/backlog/back-pressure.