Skip to content

Commit

Permalink
Add env var file for node exporter
Browse files Browse the repository at this point in the history
enable a file that can set a var for command line args to node exporter
to be able to add textfile collectors or otherwise configure node
exporter on a machine
  • Loading branch information
danivovich committed Jun 8, 2023
1 parent ab46f64 commit 3448a2b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Set up common prometheus exporter configurations
```
- src: [email protected]:smartlogic/ansible-role-prometheus-exporters
name: prometheus-exporters
version: 1.0.0
version: 1.1.0
```

## Requirements
Expand Down Expand Up @@ -58,6 +58,7 @@ These ports should be opened to the prometheus server based on the enabled expor

- `node_exporter_version` - Which version of node exporter to download
- `node_exporter_checksum` - The checksum for the version of node exporter
- `node_exporter_env_file` - A file, default to empty, can be in your playbook directory, that is the env file for the exporter, used to set `NODE_EXPORTER_ARGS` for command line args or other env vars for node exporter
- `redis_exporter_version` - Which version of redis_exporter to download
- `redis_exporter_checksum` - The checksum for the version of redis_exporter
- `redis_addr` - The address of the redis instance to monitor
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
node_exporter_version: 1.5.0
node_exporter_checksum: af999fd31ab54ed3a34b9f0b10c28e9acee9ef5ac5a5d5edfdde85437db7acbb
node_exporter_env_file: "node_exporter.env"

redis_exporter_version: 0.15.0
redis_exporter_checksum: 170458f8c9e1588861b1584451cfc636b1339b4cf495f82396f03e474d6e626f
Expand Down
Empty file added files/node_exporter.env
Empty file.
9 changes: 9 additions & 0 deletions tasks/node_exporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
become: yes
become_user: prometheus

- name: Template out the env file
template:
src: {{ node_exporter_env_file }}
dest: /etc/prometheus-node-exporter
mode: 0644
become: yes
notify:
- restart node_exporter

- name: Template out the service file
template:
src: node_exporter.service.j2
Expand Down
2 changes: 2 additions & 0 deletions tasks/statsd_exporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
dest: /home/prometheus/statsd_exporter/mapping.yml
become: yes
become_user: prometheus
notify:
- restart statsd_exporter

- name: Template out the service file
template:
Expand Down
4 changes: 3 additions & 1 deletion templates/node_exporter.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ After=network-online.target
User=prometheus
Restart=on-failure
WorkingDirectory=/home/prometheus/node_exporter/{{ node_exporter_version }}/node_exporter
ExecStart=/home/prometheus/node_exporter/{{ node_exporter_version }}/node_exporter/node_exporter
EnvironmentFile=-/etc/prometheus-node-exporter
ExecStart=/home/prometheus/node_exporter/{{ node_exporter_version }}/node_exporter/node_exporter $NODE_EXPORTER_ARGS
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

0 comments on commit 3448a2b

Please sign in to comment.