WIP: configure log2mail to catch errors in filebeat/metricbeat logs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
It doesn't work yet because of files permissions.
This commit is contained in:
parent
35549d2dea
commit
264941e5a0
|
@ -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
|
filebeat_logstash_plugin: False
|
||||||
|
|
||||||
|
|
|
@ -4,3 +4,8 @@
|
||||||
systemd:
|
systemd:
|
||||||
name: filebeat
|
name: filebeat
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: restart log2mail
|
||||||
|
systemd:
|
||||||
|
name: log2mail
|
||||||
|
state: restarted
|
||||||
|
|
21
filebeat/tasks/log2mail.yml
Normal file
21
filebeat/tasks/log2mail.yml
Normal 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
|
|
@ -81,3 +81,5 @@
|
||||||
insert_after: '^processors:'
|
insert_after: '^processors:'
|
||||||
notify: restart filebeat
|
notify: restart filebeat
|
||||||
when: filebeat_processors_cloud_metadata
|
when: filebeat_processors_cloud_metadata
|
||||||
|
|
||||||
|
- include: log2mail.yml
|
||||||
|
|
4
filebeat/templates/log2mail.j2
Normal file
4
filebeat/templates/log2mail.j2
Normal 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
|
|
@ -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_protocol: ""
|
||||||
metricbeat_elasticsearch_hosts:
|
metricbeat_elasticsearch_hosts:
|
||||||
|
|
|
@ -4,3 +4,8 @@
|
||||||
systemd:
|
systemd:
|
||||||
name: metricbeat
|
name: metricbeat
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: restart log2mail
|
||||||
|
systemd:
|
||||||
|
name: log2mail
|
||||||
|
state: restarted
|
||||||
|
|
21
metricbeat/tasks/log2mail.yml
Normal file
21
metricbeat/tasks/log2mail.yml
Normal 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
|
|
@ -88,3 +88,5 @@
|
||||||
insert_after: '^processors:'
|
insert_after: '^processors:'
|
||||||
notify: restart metricbeat
|
notify: restart metricbeat
|
||||||
when: metricbeat_processors_cloud_metadata
|
when: metricbeat_processors_cloud_metadata
|
||||||
|
|
||||||
|
- include: log2mail.yml
|
||||||
|
|
4
metricbeat/templates/log2mail.j2
Normal file
4
metricbeat/templates/log2mail.j2
Normal 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
|
Loading…
Reference in a new issue