enhancement(node_exporter): use systemd to create node_exporter_textfile_dir if it doesn't exist#323
enhancement(node_exporter): use systemd to create node_exporter_textfile_dir if it doesn't exist#323ym wants to merge 1 commit into
Conversation
…ile_dir if it doesn't exist Signed-off-by: Siyuan Miao <i@xswan.net>
| {% if node_exporter_textfile_dir | length > 0 %} | ||
| {% if (ansible_facts.packages.systemd | first).version is version('235', '>=') %} | ||
| ExecStartPre=+/bin/mkdir -p {{ node_exporter_textfile_dir }} | ||
| ExecStartPre=+/bin/chown -R {{ node_exporter_system_user }}:{{ node_exporter_system_group }} {{ node_exporter_textfile_dir }} |
There was a problem hiding this comment.
Hmm, I wonder if this should be -R. I'm not sure we want all of the prom files changed, just the dir.
There was a problem hiding this comment.
In our environment, the text file exporters are started after node_exporter.service and the directory is used exclusively for text file exporters, so it doesn't really matter, but I think we can remove the -R, or should we go further and only change the owner if the directory is empty?
gardar
left a comment
There was a problem hiding this comment.
I wonder if using systemd tmpfiles in this scenario would be a better solution? https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html
ping @ym |
External scripts will also need to write to |
|
The path is not dynamic like what you get with |
| Type=simple | ||
| User={{ node_exporter_system_user }} | ||
| Group={{ node_exporter_system_group }} | ||
| {% if node_exporter_textfile_dir | length > 0 %} |
There was a problem hiding this comment.
It would affect the common user who does not use tmpfs.
We're currently using a directory inside tmpfs for textfile collectors to reduce possible unnecessary IO usage, and the directory will be removed after a reboot. This PR is to ensure that
node_exporter_textfile_direxists when node-exporter is started.