grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1.38k stars 201 forks source link

Сonfiguration prometheus.exporter.process #1935

Open orlovds opened 6 days ago

orlovds commented 6 days ago

What's wrong?

Good afternoon, please tell me how to force prometheus.exporter.process collect data about all processes on VM? An analog of the setting in process_exporter:

cat > /etc/process-exporter.yml << EOF
process_names:
 - name: "{{.Comm}}"
 cmdline:
 - '.+'
EOF

Steps to reproduce

Run alloy and request data Image

System information

ALT SP Server 11100-01

Software version

alloy, version v1.4.2

Configuration

// Process metrics prometheus.exporter.process "local" { track_children = true }

// Configure a prometheus.scrape component to collect process_exporter metrics. prometheus.scrape "process" { targets = prometheus.exporter.process.local.targets forward_to = [prometheus.remote_write.mimir.receiver] }

Logs

No response

Nachtfalkeaw commented 4 days ago
//=======================================================================================
// BEGINN: PROCESS EXPORTER
//=======================================================================================
// Scrape für Process Exporter
prometheus.scrape "process_exporter" {
  job_name = "process_exporter"    // sonst heißt der job "prometheus.scrape.process_exporter"
  scrape_interval = "15s"
  scrape_timeout = "14s"
  extra_metrics = true

  targets    = prometheus.exporter.process.all.targets
  forward_to = [prometheus.relabel.node_exporter.receiver]  //andere .alloy fiel
}

//=======================================================================================
// Systemprozesse / Process Exporter

prometheus.exporter.process "all" {
  procfs_path = "/proc"
  track_children = true
  track_threads = true
  gather_smaps = true
  recheck_on_scrape = true

  matcher {
    name = "{{.Comm}}"
    cmdline = [".+"]
  }
}

//=======================================================================================
// Setzt als "job" den Name "process_exporter" weil es oben mit "job_name" in "prometheus.scrape.process_exporter" nicht funktioniert.
// ersetzt den Wert des labels "job" mit "node_exporter"

//prometheus.relabel "process_exporter" {

  // relabel Funktion
//  rule {
//    action        = "replace"
//    replacement   = "process_exporter"
//    target_label  = "job"
//  }

  // Anschließend die Metriken an die remote_write config senden
//  forward_to = [prometheus.relabel.localhost.receiver]
//}
//=======================================================================================
// ENDE: PROCESS EXPORTER
//=======================================================================================
orlovds commented 4 days ago

@Nachtfalkeaw Friend, thank you so much!!! It's a pity that all this is not in documentation...

Nachtfalkeaw commented 3 days ago

Many of these components are based on standalone exporters and there is a chance to get some more information.

https://github.com/ncabatoff/process-exporter

orlovds commented 3 days ago

@Nachtfalkeaw Of course, but if there https://grafana.com/docs/alloy/latest/reference/components/prometheus/prometheus.exporter.process/#example was your example from this issues, it would be much clearer....