2023-03-03 09:53:02 +01:00
|
|
|
{{ ansible_managed | comment }}
|
|
|
|
|
|
|
|
[Unit]
|
|
|
|
Description=Grafana Agent
|
|
|
|
Documentation=https://grafana.com/docs/agent/latest/
|
|
|
|
After=network-online.target
|
|
|
|
Requires=local-fs.target
|
|
|
|
After=local-fs.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
|
|
|
User={{ grafana_agent_user }}
|
|
|
|
Group={{ grafana_agent_user_group }}
|
2023-03-10 06:41:05 +01:00
|
|
|
WorkingDirectory={{ grafana_agent_data_dir }}
|
2023-03-27 06:36:27 +02:00
|
|
|
{% for key, value in grafana_agent_env_vars.items() %}
|
|
|
|
Environment={{key}}={{value}}
|
|
|
|
{% endfor %}
|
2023-03-03 09:53:02 +01:00
|
|
|
EnvironmentFile={{ grafana_agent_config_dir }}/{{ grafana_agent_env_file}}
|
|
|
|
|
2023-05-17 07:16:39 +02:00
|
|
|
{% if grafana_agent_mode == 'flow' %}
|
|
|
|
ExecStart={{ grafana_agent_install_dir }}/{{ grafana_agent_binary }} run \
|
|
|
|
{% for flag, flag_value in grafana_agent_flags_extra.items() %}
|
|
|
|
{% if not flag_value %}
|
|
|
|
--{{ flag }} \
|
|
|
|
{% elif flag_value is string %}
|
|
|
|
--{{ flag }}={{ flag_value }} \
|
|
|
|
{% elif flag_value is sequence %}
|
|
|
|
{% for flag_value_item in flag_value %}
|
|
|
|
--{{ flag }}={{ flag_value_item }} \
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{{ grafana_agent_config_dir }}/{{ grafana_agent_config_filename }}
|
|
|
|
{% else %}
|
2023-03-03 09:53:02 +01:00
|
|
|
ExecStart={{ grafana_agent_install_dir }}/{{ grafana_agent_binary }} \
|
|
|
|
{% for flag, flag_value in grafana_agent_flags_extra.items() %}
|
|
|
|
{% if not flag_value %}
|
|
|
|
--{{ flag }} \
|
|
|
|
{% elif flag_value is string %}
|
|
|
|
--{{ flag }}={{ flag_value }} \
|
|
|
|
{% elif flag_value is sequence %}
|
|
|
|
{% for flag_value_item in flag_value %}
|
|
|
|
--{{ flag }}={{ flag_value_item }} \
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
--config.file={{ grafana_agent_config_dir }}/{{ grafana_agent_config_filename }}
|
2023-05-17 07:16:39 +02:00
|
|
|
{% endif %}
|
2023-03-03 09:53:02 +01:00
|
|
|
|
|
|
|
SyslogIdentifier=grafana-agent
|
|
|
|
Restart=always
|
|
|
|
|
|
|
|
{% if grafana_agent_systemd_version | int >= 232 %}
|
|
|
|
ProtectSystem=strict
|
|
|
|
ProtectControlGroups=true
|
|
|
|
ProtectKernelModules=true
|
|
|
|
ProtectKernelTunables=yes
|
|
|
|
{% else %}
|
|
|
|
ProtectSystem=full
|
|
|
|
{% endif %}
|
2023-03-10 06:41:05 +01:00
|
|
|
ReadWritePaths=/tmp {{ grafana_agent_data_dir }} {{ grafana_agent_positions_dir }} {{ grafana_agent_wal_dir }}
|
2023-03-03 09:53:02 +01:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|