Skip to content

Commit

Permalink
enhancement(node_exporter): allows using multiple web listen addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Krause <christian.krause@idiv.de>
  • Loading branch information
wookietreiber committed Sep 4, 2023
1 parent 2aa6d3a commit 95c8bc2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion roles/node_exporter/molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ provisioner:
group_vars:
all:
node_exporter_binary_local_dir: "/tmp/node_exporter-linux-amd64"
node_exporter_web_listen_address: "127.0.0.1:8080"
node_exporter_web_listen_address:
- '127.0.0.1:8080'
- '127.0.1.1:8080'
node_exporter_textfile_dir: ""
node_exporter_enabled_collectors:
- entropy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def test_protecthome_property(host):

def test_socket(host):
sockets = [
"tcp://127.0.0.1:8080"
"tcp://127.0.0.1:8080",
"tcp://127.0.1.1:8080"
]
for socket in sockets:
s = host.socket(socket)
Expand Down
9 changes: 9 additions & 0 deletions roles/node_exporter/templates/node_exporter.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ ExecStart={{ node_exporter_binary_install_dir }}/node_exporter \
'--web.config=/etc/node_exporter/config.yaml' \
{% endif %}
{% endif %}
{% if node_exporter_version is version('1.5.0', '>=') and
node_exporter_web_listen_address is iterable and
node_exporter_web_listen_address is not mapping and
node_exporter_web_listen_address is not string %}
{% for address in node_exporter_web_listen_address %}
'--web.listen-address={{ address }}' \
{% endfor %}
{% else %}
'--web.listen-address={{ node_exporter_web_listen_address }}' \
{% endif %}
'--web.telemetry-path={{ node_exporter_web_telemetry_path }}'

SyslogIdentifier=node_exporter
Expand Down

0 comments on commit 95c8bc2

Please sign in to comment.