From 5405ae535af1d193a5b8e37be5066884ea7b2d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Sat, 26 Aug 2023 08:39:35 +0000 Subject: [PATCH] Add logging configuration to systemd_exporter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow configuring the log verbosity of systemd_exporter via systemd_exporter_log_level, corresponding to the --log-level flag. Signed-off-by: HÃ¥vard Pettersson --- roles/systemd_exporter/defaults/main.yml | 2 ++ roles/systemd_exporter/meta/argument_specs.yml | 2 ++ roles/systemd_exporter/templates/systemd_exporter.service.j2 | 1 + 3 files changed, 5 insertions(+) diff --git a/roles/systemd_exporter/defaults/main.yml b/roles/systemd_exporter/defaults/main.yml index 444c4531..a4b4a46f 100644 --- a/roles/systemd_exporter/defaults/main.yml +++ b/roles/systemd_exporter/defaults/main.yml @@ -19,3 +19,5 @@ systemd_exporter_unit_exclude: "" systemd_exporter_binary_install_dir: "/usr/local/bin" systemd_exporter_system_group: "systemd-exporter" systemd_exporter_system_user: "{{ systemd_exporter_system_group }}" + +systemd_exporter_log_level: info diff --git a/roles/systemd_exporter/meta/argument_specs.yml b/roles/systemd_exporter/meta/argument_specs.yml index 834655b1..642ccd85 100644 --- a/roles/systemd_exporter/meta/argument_specs.yml +++ b/roles/systemd_exporter/meta/argument_specs.yml @@ -65,3 +65,5 @@ argument_specs: - "I(Advanced)" - "Systemd exporter user" default: "systemd-exporter" + systemd_exporter_log_level: + description: Only log messages with the given severity or above. diff --git a/roles/systemd_exporter/templates/systemd_exporter.service.j2 b/roles/systemd_exporter/templates/systemd_exporter.service.j2 index 6251002e..5d179362 100644 --- a/roles/systemd_exporter/templates/systemd_exporter.service.j2 +++ b/roles/systemd_exporter/templates/systemd_exporter.service.j2 @@ -39,6 +39,7 @@ ExecStart={{ systemd_exporter_binary_install_dir }}/systemd_exporter \ {% if systemd_exporter_tls_server_config | length > 0 %} --web.config.file=/etc/systemd_exporter/config.yaml \ {% endif %} + --log.level={{ systemd_exporter_log_level }} \ --web.listen-address={{ systemd_exporter_web_listen_address }} SyslogIdentifier=systemd_exporter