2. Scraping #
Configuration of the prometheus.scrape component.
The prometheus.scrape component #
prometheus.scrape regularly queries each target and passes metrics to the rest of the pipeline. It works like Prometheus, but stores nothing.
prometheus.scrape "applis" {
targets = discovery.relabel.applis.output
scrape_interval = "30s"
scrape_timeout = "10s"
metrics_path = "/metrics"
forward_to = [prometheus.relabel.filtre.receiver]
}
discovery.relabel "applis" {
targets = []
}
prometheus.relabel "filtre" {
rule {
source_labels = ["__name__"]
regex = "go_gc_.*"
action = "drop"
}
forward_to = [prometheus.remote_write.mimir.receiver]
}
prometheus.remote_write "mimir" {
endpoint {
url = "http://mimir:9009/api/v1/push"
}
}| Argument | Purpose | Default |
|---|---|---|
scrape_interval | Scrape frequency | 60s |
scrape_timeout | Maximum time | 10s |
metrics_path | Metrics path | /metrics |
job_name | Value of the job label | Component name |
honor_labels | Keep target labels on conflict | false |
Mind the default: 60 seconds, against 15 in many Prometheus configurations. If your charts look less precise after a migration, check this setting first.
Two filtering levels #
| Component | Acts on | When | Example |
|---|---|---|---|
discovery.relabel | Targets | Before scraping | Ignore dev pods |
prometheus.relabel | Metrics | After scraping | Remove go_gc_.* |
Not scraping a target saves far more than filtering its metrics afterwards: filter as early as possible.
Collecting the system without node_exporter #
Alloy embeds exporters. prometheus.exporter.unix replaces node_exporter, and publishes its targets like any discovery component:
prometheus.exporter.unix "hote" {
enable_collectors = ["cpu", "meminfo", "diskstats", "filesystem", "netdev"]
}
prometheus.scrape "hote" {
targets = prometheus.exporter.unix.hote.targets
forward_to = [prometheus.remote_write.mimir.receiver]
}
prometheus.remote_write "mimir" {
endpoint {
url = "http://mimir:9009/api/v1/push"
}
}Checking collection #
In the UI, the prometheus.scrape page shows each target's URL, state (up or down) and last error. The prometheus_scrape_targets_gauge metric counts targets. A down target does not stop the component from being healthy: also watch the up series.
My progress
Sign in to track your progress and take notes. Sign in
💬 Recent discussions about this course
- Alloy : recevoir de l'OTLP et l'envoyer vers Tempo et Mimir✓ solved · 1 reply(ies)
Ask a question about this lesson →See all discussions about this course
Course Glossary
Grafana Alloy
An open-source, vendor-neutral telemetry collector designed to replace Grafana Agent, fully compatible with OpenTelemetry (OTel).
Recommended Articles
Ingesting metrics into VictoriaMetrics: scraping, vmagent and remote write
All the ways to feed VictoriaMetrics: remote write from Prometheus, built-in scraping, vmagent an...
Grafana Alloy: The importance of Self-Monitoring
Discover why and how to configure Grafana Alloy so that it monitors itself, collecting its own lo...
Grafana Alloy: collecting system metrics and local logs
Learn how to configure Grafana Alloy to monitor the server it runs on, with a focus on configurat...
Grafana Alloy: collecting and transforming telemetry
Learn how to use Grafana Alloy to collect, transform and route logs, metrics and traces. Discover...
Grafana Alloy: Syntax and Configuration (Alloy Language: River)
As part of a Grafana training or observability training, master the declarative syntax of Grafana...
Collecting logs into Loki: Alloy, Promtail, Docker and OpenTelemetry
Send logs to Loki: Grafana Alloy, Promtail, the Docker driver, OTLP, good labels, parsing and enr...
Grafana Alloy vs OpenTelemetry Collector: Which One Should You Choose?
A detailed comparison between Grafana Alloy and the OpenTelemetry Collector. Discover the strengt...
Grafana Alloy best practices: optimizing your telemetry collection
Discover the golden rules for configuring Grafana Alloy robustly: modularity, secrets management,...
Alloy and the Grafana Labs ecosystem: which component for which tool?
The map of Alloy integrations with Faro, Beyla, k6, Loki, Mimir, Tempo, Pyroscope, Database Obser...