WIP: configure log2mail to catch errors in filebeat/metricbeat logs
continuous-integration/drone/push Build is passing Details

It doesn't work yet because of files permissions.
This commit is contained in:
Jérémy Lecour 2020-04-03 10:14:01 +02:00 committed by Jérémy Lecour
parent 35549d2dea
commit 264941e5a0
10 changed files with 74 additions and 2 deletions

View File

@ -1,5 +1,9 @@
---
elastic_stack_version: "6.x"
general_alert_email: "root@localhost"
log2mail_alert_email: Null
filebeat_log2mail_alert_email: Null
elastic_stack_version: "7.x"
filebeat_logstash_plugin: False

View File

@ -4,3 +4,8 @@
systemd:
name: filebeat
state: restarted
- name: restart log2mail
systemd:
name: log2mail
state: restarted

View File

@ -0,0 +1,21 @@
---
- name: Check if log2mail is installed
stat:
path: /etc/log2mail/config
register: _log2mail_config_dir
- name: "Add user 'log2mail' to 'filebeat' group"
user:
name: 'log2mail'
groups: 'filebeat'
append: yes
notify: restart log2mail
when: _log2mail_config_dir.stat.isdir
- name: Install filebeat log2mail configuration
template:
src: log2mail.j2
dest: /etc/log2mail/config/filebeat
notify: restart log2mail
when: _log2mail_config_dir.stat.isdir

View File

@ -81,3 +81,5 @@
insert_after: '^processors:'
notify: restart filebeat
when: filebeat_processors_cloud_metadata
- include: log2mail.yml

View File

@ -0,0 +1,4 @@
file = /var/log/filebeat/filebeat
pattern = "\bERROR\b"
mailto = {{ filebeat_log2mail_alert_email or log2mail_alert_email or general_alert_email | mandatory }}
template = /etc/log2mail/mail

View File

@ -1,5 +1,9 @@
---
elastic_stack_version: "6.x"
general_alert_email: "root@localhost"
log2mail_alert_email: Null
metricbeat_log2mail_alert_email: Null
elastic_stack_version: "7.x"
metricbeat_elasticsearch_protocol: ""
metricbeat_elasticsearch_hosts:

View File

@ -4,3 +4,8 @@
systemd:
name: metricbeat
state: restarted
- name: restart log2mail
systemd:
name: log2mail
state: restarted

View File

@ -0,0 +1,21 @@
---
- name: Check if log2mail is installed
stat:
path: /etc/log2mail/config
register: _log2mail_config_dir
- name: "Add user 'log2mail' to 'metricbeat' group"
user:
name: 'log2mail'
groups: 'metricbeat'
append: yes
notify: restart log2mail
when: _log2mail_config_dir.stat.isdir
- name: Install metricbeat log2mail configuration
template:
src: log2mail.j2
dest: /etc/log2mail/config/metricbeat
notify: restart log2mail
when: _log2mail_config_dir.stat.isdir

View File

@ -88,3 +88,5 @@
insert_after: '^processors:'
notify: restart metricbeat
when: metricbeat_processors_cloud_metadata
- include: log2mail.yml

View File

@ -0,0 +1,4 @@
file = /var/log/metricbeat/metricbeat
pattern = "\bERROR\b"
mailto = {{ metricbeat_log2mail_alert_email or log2mail_alert_email or general_alert_email | mandatory }}
template = /etc/log2mail/mail