Skip to content

Commit

Permalink
Merge branch 'cherry-pick-532adfe0' into 'master_6.rc.x'
Browse files Browse the repository at this point in the history
CP 6RC - Story #10943: node_exporter logs redirect

Story #10943: node_exporter logs redirect

Update role node_exporter
* Configure logs output under `/vitam/log/node_exporter/`
* Deploy custom systemd script
* Configure log_level with parameter `prometheus.node_exporter.log_level`
* Add logrotate function with parameters
  * `prometheus.node_exporter.logrotate`: default(enabled) or disabled
  * `prometheus.node_exporter.history_days`: default(30)

See merge request vitam/vitam!9444

(cherry picked from commit 532adfe)

a435472 Story #10943: node_exporter logs redirect

See merge request vitam/vitam!9448
  • Loading branch information
Saad Amrani committed Feb 1, 2023
2 parents 5754eb8 + 4a2d876 commit c89286d
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
until: result is succeeded
delay: "{{ packages_install_retries_delay | default(10) }}"

- name: Remove logrotate configuration for node-exporter
file:
path: /etc/logrotate.d/node-exporter
state: absent

- name: Remove consul agent service declaration for node-exporter
file:
path: "{{ consul_folder_conf }}/service-node-exporter.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@
tags:
- update_node_exporter_configuration

- name: Deploy systemd service file for node_exporter
template:
src: vitam-node-exporter.service.j2
dest: "{{ '/lib/systemd/system' if ansible_distribution == 'Debian' else '/usr/lib/systemd/system' }}/vitam-node-exporter.service"
owner: root
group: root
mode: "0644"
notify: "prometheus-node-exporter - restart service"

- name: Enable logrotate for node_exporter
template:
src: node-exporter.logrotate.j2
dest: /etc/logrotate.d/node-exporter
owner: root
group: root
mode: 0644
when: prometheus.node_exporter.logrotate | default('enabled') | lower == 'enabled'

- name: Disable logrotate for node_exporter
file:
path: /etc/logrotate.d/node-exporter
state: absent
when: prometheus.node_exporter.logrotate | default('enabled') | lower == 'disabled'

#### Consul configuration ####
- name: Ensure consul config dir is OK
file:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ ansible_managed | comment }}

{{ vitam_defaults.folder.root_path }}/log/node_exporter/node-exporter.log {
daily
rotate {{ prometheus.node_exporter.history_days | default(30) }}
copytruncate
dateext
dateformat -%Y-%m-%d
dateyesterday
extension .log
compress
delaycompress
notifempty
missingok
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NODE_EXPORTER_OPTS='--web.listen-address={{ ip_admin }}:{{ prometheus.node_exporter.port | default(9101) }} --web.telemetry-path={{ prometheus.node_exporter.metrics_path | default('/metrics') }} --collector.textfile.directory /vitam/data/node_exporter/textfile_collector'
NODE_EXPORTER_OPTS='--web.listen-address={{ ip_admin }}:{{ prometheus.node_exporter.port | default(9101) }} --web.telemetry-path={{ prometheus.node_exporter.metrics_path | default('/metrics') }} --collector.textfile.directory /vitam/data/node_exporter/textfile_collector --log.level={{ prometheus.node_exporter.log_level | default('warn') }}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- mode: conf -*-

[Unit]
Description=Prometheus Node Exporter.
Documentation=https://github.com/prometheus/node_exporter
After=network.target

[Service]
EnvironmentFile=-/vitam/conf/node_exporter/sysconfig/node_exporter
User=vitam
Group=vitam
ExecStart=/bin/bash -c 'exec /vitam/bin/node_exporter/node_exporter $NODE_EXPORTER_OPTS 2>> {{ vitam_defaults.folder.root_path | default('/vitam') }}/log/node_exporter/node-exporter.log'
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions deployment/environments/group_vars/all/advanced/cots_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ prometheus:
enabled: true
port: 9101
metrics_path: /metrics
log_level: "warn"
logrotate: enabled # or disabled
history_days: 30 # How many days to store logs if logrotate is set to 'enabled'
consul_exporter:
enabled: true
port: 9107
Expand Down

0 comments on commit c89286d

Please sign in to comment.