Last active
June 25, 2019 14:10
-
-
Save nicklaw5/7f7297f936c428e55603905122fbd13b to your computer and use it in GitHub Desktop.
Logstash & Filebeat configuration for parsing MariaDB Slow Logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=========================== Filebeat prospectors ============================= | |
filebeat.prospectors: | |
- input_type: log | |
document_type: mariadb-slowlogs | |
paths: | |
- "/var/log/mysql/mariadb-slow.log" | |
multiline: | |
pattern: '^# User@Host: ' | |
negate: true | |
match: after |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter { | |
if [type] == "mariadb-slowlogs" { | |
# Drop "Time" line since it does not appear on every log entry | |
if [message] =~ "^# Time: " { | |
drop {} | |
} | |
grok { | |
match => [ "message", "%{MYSQLSLOWLOGCOMBINED}" ] | |
} | |
date { | |
match => [ "query_timestamp", "UNIX" ] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MYSQLSLOWLOGHOST # User@Host: %{USER:query_user}?(\[%{WORD}\])? @ %{HOSTNAME:query_host} \[%{IP:query_ip}?\]\n | |
MYSQLSLOWLOGSTATS1 # Thread_id: %{NUMBER:query_thread_id:int} Schema: %{DATA:query_schema} QC_hit: %{DATA:query_qc_hit}\n | |
MYSQLSLOWLOGSTATS2 # Query_time: %{NUMBER:query_time:float} Lock_time: %{NUMBER:query_lock_time:float} Rows_sent: %{NUMBER:query_rows_sent:int} Rows_examined: %{NUMBER:query_rows_examined:int}\n | |
MYSQLSLOWLOGSTATS3 # Rows_affected: %{NUMBER:query_rows_affected:int}\n | |
MYSQLSLOWLOGSTATS4 (?:# Full_scan: %{DATA:query_full_scan} Full_join: %{DATA:query_full_join} Tmp_table: %{DATA:query_tmp_table} Tmp_table_on_disk: %{DATA:query_tmp_table_on_disk}\n)? | |
MYSQLSLOWLOGSTATS5 (?:# Filesort: %{DATA:query_filesort} Filesort_on_disk: %{DATA:query_filesort_on_disk} Merge_passes: %{DATA:query_merge_passes} Priority_queue: %{DATA:query_priority_queue}\n)? | |
MYSQLSLOWLOGQUERYSQL SET timestamp=%{NUMBER:query_timestamp:int};\n%{GREEDYDATA:query_sql} | |
MYSQLSLOWLOGCOMBINED %{MYSQLSLOWLOGHOST}%{MYSQLSLOWLOGSTATS1}%{MYSQLSLOWLOGSTATS2}%{MYSQLSLOWLOGSTATS3}%{MYSQLSLOWLOGSTATS4}%{MYSQLSLOWLOGSTATS5}%{MYSQLSLOWLOGQUERYSQL} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment