Merge "Parse MariaDB log messages in different formats into Fluentd"
This commit is contained in:
commit
c641096ea6
@ -235,6 +235,8 @@
|
||||
dest: 00-record_transformer
|
||||
- src: "{{ '01-rewrite-0.14' if fluentd_version == '0.14' else '01-rewrite-0.12' }}"
|
||||
dest: 01-rewrite
|
||||
- src: 02-parser
|
||||
dest: 02-parser
|
||||
when:
|
||||
- enable_fluentd | bool
|
||||
- item.src ~ '.conf' not in customised_filter_files
|
||||
|
@ -37,3 +37,10 @@
|
||||
rewriterule34 programname ^(monasca-api|monasca-notification|monasca-persister|agent-collector|agent-forwarder|agent-statsd)$ openstack_python
|
||||
rewriterule35 programname .+ unmatched
|
||||
</match>
|
||||
|
||||
# Retag log messages from MariaDB according to log format
|
||||
<match infra.mariadb>
|
||||
@type rewrite_tag_filter
|
||||
rewriterule1 Payload ^\d{6} infra.mariadb.mysqld_safe
|
||||
rewriterule2 Payload ^\d{4}-\d{2}-\d{2} infra.mariadb.mysqld
|
||||
</match>
|
||||
|
@ -187,3 +187,18 @@
|
||||
tag unmatched
|
||||
</rule>
|
||||
</match>
|
||||
|
||||
# Retag log messages from MariaDB according to log format
|
||||
<match infra.mariadb>
|
||||
@type rewrite_tag_filter
|
||||
<rule>
|
||||
key Payload
|
||||
pattern /^\d{6}/
|
||||
tag infra.mariadb.mysqld_safe
|
||||
</rule>
|
||||
<rule>
|
||||
key Payload
|
||||
pattern /^\d{4}-\d{2}-\d{2}/
|
||||
tag infra.mariadb.mysqld
|
||||
</rule>
|
||||
</match>
|
||||
|
27
ansible/roles/common/templates/conf/filter/02-parser.conf.j2
Normal file
27
ansible/roles/common/templates/conf/filter/02-parser.conf.j2
Normal file
@ -0,0 +1,27 @@
|
||||
# Parse MariaDB logs with 6 digit date format (mysqld_safe)
|
||||
<filter infra.mariadb.mysqld_safe>
|
||||
@type parser
|
||||
format /^(?<Timestamp>\d{6} {1,2}\d{1,2}:\d{1,2}:\d{1,2}) +(?<Payload>mysqld_safe .*)/
|
||||
time_format %y%m%d %k:%M:%S
|
||||
time_key Timestamp
|
||||
key_name Payload
|
||||
reserve_data true
|
||||
</filter>
|
||||
|
||||
# Parse MariaDB logs with 8 digit date format (mysqld)
|
||||
<filter infra.mariadb.mysqld>
|
||||
@type parser
|
||||
format /^(?<Timestamp>\d{4}-\d{2}-\d{2} {1,2}\d{1,2}:\d{1,2}:\d{1,2}) +(?<Payload>\w+ +(\[(?<log_level>\w+)\]|\w+: +(?<log_level>\w+):).*)/
|
||||
time_format %Y-%m-%d %k:%M:%S
|
||||
time_key Timestamp
|
||||
key_name Payload
|
||||
reserve_data true
|
||||
</filter>
|
||||
|
||||
# Re-add timestamp record now that the log date has been parsed
|
||||
<filter infra.mariadb.*>
|
||||
@type record_transformer
|
||||
<record>
|
||||
timestamp ${time}
|
||||
</record>
|
||||
</filter>
|
@ -1,11 +1,12 @@
|
||||
# mysqld and its wrapper script mysqld_safe output logs using a different timestamp.
|
||||
# Defer parsing the logs until the different formats have been retagged.
|
||||
<source>
|
||||
@type tail
|
||||
path /var/log/kolla/mariadb/mariadb.log
|
||||
pos_file /var/run/{{ fluentd_binary }}/mariadb.pos
|
||||
tag infra.mariadb
|
||||
format multiline
|
||||
format_firstline /^\d{6}/
|
||||
format1 /^(?<time>\d{6} \d{1,2}:\d{1,2}:\d{1,2}) (\[(?<log_level>\S+)\]|mysqld_safe) (?<Payload>.*)/
|
||||
time_format %y%m%d %k:%M:%S
|
||||
format_firstline /^(\d{4}-\d{2}-\d{2}|\d{6}) /
|
||||
format1 /^(?<Payload>.*)/
|
||||
enable_watch_timer false
|
||||
</source>
|
||||
|
Loading…
Reference in New Issue
Block a user