RousselTMLEARNING

Article · Alloy: From Discovery to Expertise

Scraping

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"
  }
}
ArgumentPurposeDefault
scrape_intervalScrape frequency60s
scrape_timeoutMaximum time10s
metrics_pathMetrics path/metrics
job_nameValue of the job labelComponent name
honor_labelsKeep target labels on conflictfalse
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 #

ComponentActs onWhenExample
discovery.relabelTargetsBefore scrapingIgnore dev pods
prometheus.relabelMetricsAfter scrapingRemove 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.

📄 Grafana Alloy: Metrics Collection (Prometheus & Ecosystem) →

My progress

  • ⏱ Estimated time : ≈ 6 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Recent discussions about this course

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...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!