Difference between revisions of "Prometheus instance label control"
Jump to navigation
Jump to search
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | https://www.robustperception.io/controlling-the-instance-label/ | ||
+ | |||
+ | https://prometheus.io/docs/guides/multi-target-exporter/ | ||
+ | |||
+ | https://www.robustperception.io/checking-if-ssh-is-responding-with-prometheus/ | ||
+ | |||
+ | ``` | ||
+ | wget https://github.com/prometheus/prometheus/releases/download/v2.0.0/prometheus-2.0.0.linux-amd64.tar.gz | ||
+ | tar -xzf prometheus-*.tar.gz | ||
+ | cd prometheus-* | ||
+ | cat <<'EOF' > prometheus.yml | ||
+ | global: | ||
+ | scrape_interval: 10s | ||
+ | scrape_configs: | ||
+ | - job_name: 'blackbox' | ||
+ | metrics_path: /probe | ||
+ | params: | ||
+ | module: [ssh_banner] | ||
+ | static_configs: | ||
+ | - targets: | ||
+ | - 127.0.0.1 # Targets to probe | ||
+ | relabel_configs: | ||
+ | # Ensure port is 22, pass as URL parameter | ||
+ | - source_labels: [__address__] | ||
+ | regex: (.*?)(:.*)? | ||
+ | replacement: ${1}:22 | ||
+ | target_label: __param_target | ||
+ | # Make instance label the target | ||
+ | - source_labels: [__param_target] | ||
+ | target_label: instance | ||
+ | # Actually talk to the blackbox exporter though | ||
+ | - target_label: __address__ | ||
+ | replacement: 127.0.0.1:9115 | ||
+ | EOF | ||
+ | ./prometheus | ||
+ | ``` | ||
+ | https://valyala.medium.com/how-to-use-relabeling-in-prometheus-and-victoriametrics-8b90fc22c4b2 | ||
https://www.robustperception.io/controlling-the-instance-label/ | https://www.robustperception.io/controlling-the-instance-label/ | ||
Line 4: | Line 41: | ||
https://prometheus.io/docs/concepts/jobs_instances/#:~:text=In%20Prometheus%20terms%2C%20an%20endpoint,example%2C%20is%20called%20a%20job. | https://prometheus.io/docs/concepts/jobs_instances/#:~:text=In%20Prometheus%20terms%2C%20an%20endpoint,example%2C%20is%20called%20a%20job. | ||
+ | |||
+ | https://medium.com/geekculture/single-prometheus-job-for-dozens-of-blackbox-exporters-2a7ba492d6c8 | ||
+ | |||
+ | https://prometheus.io/blog/2015/06/01/advanced-service-discovery/ |
Latest revision as of 22:53, 24 February 2024
https://www.robustperception.io/controlling-the-instance-label/
https://prometheus.io/docs/guides/multi-target-exporter/
https://www.robustperception.io/checking-if-ssh-is-responding-with-prometheus/
wget https://github.com/prometheus/prometheus/releases/download/v2.0.0/prometheus-2.0.0.linux-amd64.tar.gz tar -xzf prometheus-*.tar.gz cd prometheus-* cat <<'EOF' > prometheus.yml global: scrape_interval: 10s scrape_configs: - job_name: 'blackbox' metrics_path: /probe params: module: [ssh_banner] static_configs: - targets: - 127.0.0.1 # Targets to probe relabel_configs: # Ensure port is 22, pass as URL parameter - source_labels: [__address__] regex: (.*?)(:.*)? replacement: ${1}:22 target_label: __param_target # Make instance label the target - source_labels: [__param_target] target_label: instance # Actually talk to the blackbox exporter though - target_label: __address__ replacement: 127.0.0.1:9115 EOF ./prometheus
https://valyala.medium.com/how-to-use-relabeling-in-prometheus-and-victoriametrics-8b90fc22c4b2 https://www.robustperception.io/controlling-the-instance-label/
https://grafana.com/blog/2022/03/21/how-relabeling-in-prometheus-works/
https://medium.com/geekculture/single-prometheus-job-for-dozens-of-blackbox-exporters-2a7ba492d6c8
https://prometheus.io/blog/2015/06/01/advanced-service-discovery/