From c267536ecfbcf37e68226ade2ed29c3b1f356a98 Mon Sep 17 00:00:00 2001 From: Colin Wilk Date: Tue, 11 Aug 2026 00:54:41 +0200 Subject: Add `state` option for removing exporters --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 32d85c8..5e5ce86 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ prometheus_target_exporter_defaults: {} # node_exporter: # path: /opt/prometheus/targets.yml # host: '{{ inventory_hostname }}:9100' + # state: present # labels: # Labels to match when using yaml strategy # severity: warning # job: external @@ -65,6 +66,17 @@ prometheus_target_exporter_defaults: {} prometheus_target_exporter: [] ``` +Each exporter accepts `state: present` or `state: absent`, defaulting to +`present`. Set `state: absent` to remove the rendered target from its target +file. The setting can be defined in `prometheus_target_exporter_defaults` and +overridden by an entry in `prometheus_target_exporter`. + +With the `yaml` strategy, removal searches every group in the configured file, +regardless of the exporter's labels, and removes groups left without targets. +With the `lineinfile` strategy, removal deletes the exact line produced by the +configured prefix, host, and suffix. Removing a target from a missing file is a +no-op for both strategies. + You can also add exporter that you want to have deployed without needing to specify them in the `prometheus_target_exporter` variable by adding them to the `prometheus_target_default_exporters` variable. -- cgit v1.2.3