aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/README.md
diff options
context:
space:
mode:
authorColin Wilk <colin.wilk@tum.de>2023-06-11 18:53:04 +0200
committerColin Wilk <colin.wilk@tum.de>2023-06-11 18:53:04 +0200
commit232bdca2add4253981b0873188663069f74a0610 (patch)
treef455d26babf600baad72e5e68d02a7f2730e548c /README.md
parent7623b7302f445798fb9d6fe31c1c1eb7085173a4 (diff)
downloadansible-role-prometheus-target-232bdca2add4253981b0873188663069f74a0610.tar.gz
ansible-role-prometheus-target-232bdca2add4253981b0873188663069f74a0610.zip
Add ability to specify target path prefix
This will decrease the amount of redundant configuration for users by allowing them to specify a general prefix on global / exporter / play level Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Diffstat (limited to 'README.md')
-rw-r--r--README.md49
1 files changed, 48 insertions, 1 deletions
diff --git a/README.md b/README.md
index dfc3939..f3d285c 100644
--- a/README.md
+++ b/README.md
@@ -56,8 +56,9 @@ prometheus_target_exporter_defaults: {}
# path: /opt/prometheus/targets.yml
# host: '{{ inventory_hostname }}:9100'
# blackbox_exporter:
- # path: /opt/prometheus/blackbox.yml
+ # path: /opt/targets/blackbox.yml
# host: 'https://{{ hostvars[inventory_hostname].ansible_host }}'
+ # path_prefix: ''
prometheus_target_exporter: []
```
@@ -71,6 +72,26 @@ prometheus_target_default_exporters: []
prometheus_target_skip_default_exporters: false
```
+As you usually have most target files in one directory you can specify a target
+prefix for your target files:
+
+```yaml
+prometheus_target_exporter_target_prefix: ''
+```
+
+This way you only need to pass `target.yml` instead of `/path/to/target.yml` as
+your exporter path. You can additionally define this at the
+`prometheus_target_exporter_defaults` and the `prometheus_target_exporter` level
+using the `path_prefix` variable:
+
+```yaml
+prometheus_target_exporter_defaults:
+ blackbox_exporter:
+ path: /opt/targets/blackbox.yml
+ host: 'https://{{ hostvars[inventory_hostname].ansible_host }}'
+ path_prefix: '' # Disables configured prefix
+```
+
This role offers a few strategies that you can use to deploy your targets.
The strategy decides how exactly targets are added to the targets file and more
importantly how to handle existing configuration.
@@ -164,6 +185,32 @@ Simple example
- id: node_exporter
```
+Using Target prefix
+
+```yaml
+- name: Deploy node exporter with target prefix
+ hosts: myhost
+
+ vars: # General configuration. Can be set in group_vars
+ prometheus_target_host: prometheus
+ prometheus_target_exporter_target_prefix: /opt/prometheus/targets/
+ prometheus_target_exporter_defaults:
+ node_exporter:
+ path: node.yml
+ host: '{{ inventory_hostname }}:9100'
+ blackbox_exporter: # Another exporter with different prefix
+ path: target.yml
+ host: '{{ inventory_hostname }}'
+ path_prefix: /opt/prefix/
+
+ roles:
+ - role: kliwniloc.prometheus_target
+ prometheus_target_exporter:
+ - id: node_exporter # -> /opt/prometheus/targets/node.yml
+ - { id: node_exporter, path: /target.yml, path_prefix: '' } # -> /target.yml
+ - { id: blackbox_exporter, path: blackbox.yml } # -> /opt/prefix/blackbox.yml
+```
+
Using Handlers
```yaml