ansible-collection-prometheus/roles/systemd_exporter/templates/systemd_exporter.service.j2
Håvard Pettersson 5405ae535a Add logging configuration to systemd_exporter
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 <haavard.pettersson@gmail.com>
2023-08-29 15:14:13 +00:00

63 lines
1.9 KiB
Django/Jinja

{{ ansible_managed | comment }}
[Unit]
Description=Prometheus SystemD Exporter
After=network-online.target
[Service]
Type=simple
User={{ systemd_exporter_system_user }}
Group={{ systemd_exporter_system_group }}
ExecStart={{ systemd_exporter_binary_install_dir }}/systemd_exporter \
{% if systemd_exporter_enable_restart_count %}
{% if systemd_exporter_version is version('0.5.0', '>=') %}
--systemd.collector.enable-restart-count \
{% else %}
--collector.enable-restart-count \
{% endif %}
{% endif %}
{% if systemd_exporter_enable_file_descriptor_size %}
{% if systemd_exporter_version is version('0.5.0', '>=') %}
--systemd.collector.enable-file-descriptor-size \
{% else %}
--collector.enable-file-descriptor-size \
{% endif %}
{% endif %}
{% if systemd_exporter_enable_ip_accounting %}
{% if systemd_exporter_version is version('0.5.0', '>=') %}
--systemd.collector.enable-ip-accounting \
{% else %}
--collector.enable-ip-accounting \
{% endif %}
{% endif %}
{% if systemd_exporter_unit_include != ""%}
--systemd.collector.unit-include={{ systemd_exporter_unit_include }} \
{% endif %}
{% if systemd_exporter_unit_exclude != "" %}
--systemd.collector.unit-exclude={{ systemd_exporter_unit_exclude }} \
{% endif %}
{% 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
Restart=always
RestartSec=1
StartLimitInterval=0
ProtectHome=yes
NoNewPrivileges=yes
{% if (ansible_facts.packages.systemd | first).version is version('232', '>=') %}
ProtectSystem=strict
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=yes
{% else %}
ProtectSystem=full
{% endif %}
[Install]
WantedBy=multi-user.target