outlook 发表于 2018-10-1 09:00:53

利用filebeat推送mysql慢查询日志

input {  
beats {
  
port => 5044
  
}
  
}
  
filter {
  

  
grok {
  
match => [ "message", "(?m)^# User@Host: %{USER:query_user}\[[^\]]+\] @ (?:(?\S*) )?\[(?:%{IP:query_ip})?\]\s*Id: %{NUMBER:id:int}\s+# Query_time: %{NUMBER:query_time:float}\s+Lock_time: %{NUMBER:lock_time:float}\s+Rows_sent: %{NUMBER:rows_sent:int}\s+Rows_examined: %{NUMBER:rows_examined:int}\s*(?:use %{DATA:database};\s*)?SET timestamp=%{NUMBER:timestamp};\s*(?(?\w+)\s+.*)" ]
  
}
  
grok {
  
match => { "message" => "# Time: " }
  
add_tag => [ "drop" ]
  
tag_on_failure =>[]
  
}
  
if "drop" in {
  
drop {}
  
}
  
date {
  
match => [ "timestamp", "UNIX", "YYYY-MM-dd HH:mm:ss"]
  
remove_field => [ "timestamp" ]
  
}
  

  
}
  
output {
  
elasticsearch {
  
hosts => "192.168.1.63:9200"
  
manage_template => false
  
index => "%{[@metadata]}-%{}-%{+YYYY.MM.dd}"
  
document_type => "%{[@metadata]}"
  
}
  
}


页: [1]
查看完整版本: 利用filebeat推送mysql慢查询日志