-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongo_logs.cfg
168 lines (153 loc) · 4.59 KB
/
mongo_logs.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
input {
stdin {
tags => [ "tech_talk" ]
}
}
filter {
# Initial grok to remove the syslog timestamp
grok {
match => [ "message" , "%{SYSLOGBASE} %{GREEDYDATA:message}" ]
overwrite => [ "message" ]
}
# If the log comes from mongo, then fall into this conditional
if [program] =~ "mongos" {
# Mutate the timestamp field into syslog_timestamp.
# We will populate 'timestamp' with the value from the mongo process
mutate {
rename => [ "timestamp" , "syslog_timestamp" ]
add_tag => "mongos"
}
# Use the %MONGO_LOG pattern to pull out the timestamp.
# Overwrite the message abd timestamp fields
# Add a new field
grok {
match => [ "message" , "%{MONGO_LOG}" ]
match => [ "message" , "%{SYSLOGTIMESTAMP:timestamp} %{GREEDYDATA:message}" ]
overwrite => [ "message" , "timestamp" ]
add_field => { "mongo_timestamp" => "%{timestamp}" }
add_tag => [ "%{component}" ]
}
if [component] =~ "conn" {
mutate {
replace => [ "component", "conn" ]
}
}
# Capture the following lines
#
# Jan 14 12:50:55 lonapp0-2vz74 mongos.23074[2420]: Wed Jan 14 12:50:55.254 [mongosMain] connection accepted from 10.183.224.66:53539 #4364679 (12 connections now open)
#
#
if [component] == "conn" {
if [message] =~ "end connection" {
mutate {
add_tag => [ "end_connection" ]
}
}
if [message] =~ "authenticate" {
grok {
match => [ "message" , "authenticate db: %{WORD:authdb} { %{GREEDYDATA:message} }"]
overwrite => [ "message" ]
add_tag => [ "authenticate" ]
}
kv {
value_split => ":"
field_split => ","
trim => " \""
}
}
}
if [component] == "mongosMain" {
grok {
break_on_match => false
match => ["message" , "connection accepted from %{IP:connect_from}:%{POSINT:connect_from_port} %{DATA} \(%{POSINT:open_conns} connections now open\)"]
}
geoip {
source => "connect_from"
}
}
if [component] == "Balancer" {
}
}#if
if [program] =~ "mongod" {
# Mutate the timestamp field into syslog_timestamp.
# We will populate 'timestamp' with the value from the mongo process
mutate {
rename => [ "timestamp" , "syslog_timestamp" ]
add_tag => "mongod"
}
grok {
match => [ "message" , "%{MONGO_LOG}" ]
match => [ "message" , "%{SYSLOGTIMESTAMP:timestamp} \[%{DATA:component}\] %{GREEDYDATA:message}" ]
match => [ "message" , "%{SYSLOGTIMESTAMP:timestamp} %{GREEDYDATA:message}" ]
match => [ "message" , "%{GREEDYDATA:message}" ]
overwrite => [ "message" , "timestamp" ]
add_field => { "mongo_timestamp" => "%{timestamp}" }
add_tag => [ "%{component}" ]
tag_on_failure => [ "_grokparsefailure","_gp1"]
}
if [message] =~ "dbexit" {
mutate {
add_tag => ["dbexit"]
# There is no timestamp set now, use the syslog one.
replace => [ "timestamp", "%{syslog_timestamp}" ]
}
}
if [component] =~ "conn" {
mutate {
replace => [ "component", "conn" ]
}
}
if [component] == "initandlisten" {
grok {
match => [ "message" , "connection accepted from %{IP:connect_from}:%{POSINT:connect_from_port} %{DATA} \(%{POSINT:open_conns:int} connections now open\)"]
match => [ "message" , "%{GREEDYDATA:message}" ]
overwrite => [ "message" , "timestamp" ]
}
if [message] =~ "MongoDB starting" {
grok {
match => [ "message" , "MongoDB starting : pid=%{POSINT} port=%{POSINT:port:int} dbpath=%{DATA:dbpath} %{DATA} host=%{DATA:host}" ]
add_tag => [ "startup" ]
}
}
}
if [component] == "conn" {
if [message] =~ "end connection" {
mutate {
add_tag => [ "end_connection" ]
}
}
if [message] =~ "authenticate db" {
grok {
match => [ "message" , "authenticate db: %{WORD:authdb} { %{GREEDYDATA:message} }"]
overwrite => [ "message" ]
add_tag => [ "authenticate" ]
}
kv {
value_split => ":"
field_split => ","
trim => " \""
}
}
if [message] =~ "nreturned" {
grok {
match => [ "message", "%{MONGO_SLOWQUERY}"]
add_tag => [ "query" ]
}
}
}
}
date {
match => [ "timestamp", "MMM d HH:mm:ss", "MMM d HH:mm:ss.SSS" ,"MMM dd HH:mm:ss.SSS", "MMM DD HH:mm:ss" ]
}
}
output {
#if "_grokparsefailure" in [tags] {
# stdout {
# codec => rubydebug
# }
#}
elasticsearch_http {
host => "134.213.133.52"
replication=> "async"
}
}