This repository has been archived by the owner on Aug 27, 2021. It is now read-only.
/
logstash.conf
152 lines (128 loc) · 4.52 KB
/
logstash.conf
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
#
# delete dimensions.path as it was required by the Monasca Log API
# but isn't necessary
#
# the date-match operation sets the timestamp to the value of log_date
#
input {
kafka {
bootstrap_servers => "kafka:9092"
topics => ["monasca-log"]
codec => "json"
}
}
filter {
mutate {
rename => { "[log][message]" => "msg_full" }
rename => { "[log][dimensions]" => "dimensions" }
rename => { "[dimensions][logsource]" => "node_source" }
rename => { "[dimensions][host]" => "host_ip" }
rename => { "[dimensions][hostname]" => "host_name" }
rename => { "[dimensions][region]" => "region" }
remove_field => [ "log", "[dimensions][path]", "dimensions" ]
}
grok {
match => {
"msg_full" => "^%{NOTSPACE:node_service} %{TIMESTAMP_ISO8601:log_date}%{SPACE}%{NUMBER:log_pid}?%{SPACE}?%{LOGLEVEL:log_level} \[?\b%{NOTSPACE:log_module}\b\]?%{SPACE}?%{GREEDYDATA:msg}?"
}
}
date {
match => [ "log_date", "ISO8601" ]
}
mutate {
remove_field => [ "log_date", "msg_full" ]
}
if [node_service] =~ "nova" {
mutate {
add_tag => [ "nova" ]
}
} else if [node_service] =~ "cinder" {
mutate {
add_tag => [ "cinder" ]
}
} else if [node_service] =~ "neutron" {
mutate {
add_tag => [ "neutron" ]
}
} else if [node_service] =~ "keystone" {
mutate {
add_tag => [ "keystone" ]
}
}
if [node_service] == "nova-api" {
if [log_module] == "nova.osapi_compute.wsgi.server" {
mutate {
gsub => [ "msg", "\"", "" ]
}
grok {
match => {
"msg" => "\[(req)?\-(%{NOTSPACE:msg_request_id} %{NOTSPACE:msg_uid} %{NOTSPACE:msg_tenant} \- \- \-)?\] %{IPV4:msg_node_ip} %{NOTSPACE:msg_method} %{NOTSPACE:msg_url} %{NOTSPACE:msg_http_ver} status\: %{NUMBER:msg_response_status} len\: %{NUMBER:msg_bytes} time\: %{NUMBER:msg_response_time}"
}
}
} else if [log_module] == "nova.metadata.wsgi.server" {
mutate {
gsub => [ "msg", "\"", "" ]
}
grok {
match => {
"msg" => "\[(req)?\-(%{NOTSPACE:msg_request_id} \- \- \- \- \-)?\] %{IPV4:msg_node_ip}(,%{IPV4:msg_node_ip_2})? %{NOTSPACE:msg_method} %{NOTSPACE:msg_url} %{NOTSPACE:msg_http_ver} status\: %{NUMBER:msg_response_status} len\: %{NUMBER:msg_bytes} time\: %{NUMBER:msg_response_time}"
}
}
}
} else if [node_service] == "nova-compute" {
if [log_module] == "nova.compute.resource_tracker" {
grok {
match => {
"msg" => [
"\[req\-%{NOTSPACE:msg_request_id} \- \- \- \- \-\] Total usable vcpus: %{NUMBER:resource_total_vcpus}, total allocated vcpus: %{NUMBER:resource_used_vcpus}",
"\[req\-%{NOTSPACE:msg_request_id} \- \- \- \- \-\] Final resource view: name=%{NOTSPACE:resource_name} phys_ram=%{NUMBER:resource_physical_ram}MB used_ram=%{NUMBER:resource_used_ram}MB phys_disk=%{NUMBER:resource_physical_disk}GB used_disk=%{NUMBER:resource_used_disk}GB total_vcpus=%{NUMBER:resource_total_vcpus} used_vcpus=%{NUMBER:resource_used_vcpus} pci_stats=(<nova.pci.stats.PciDeviceStats object at %{BASE16NUM}>)"
]
}
}
}
} else if [node_service] == "neutron-server" {
if [log_module] == "neutron.wsgi" {
if [msg] !~ "accepted" {
mutate {
gsub => [ "msg", "\"", "" ]
}
grok {
match => {
"msg" => "\[(req)?\-(%{NOTSPACE:msg_request_id} )?\] %{IPV4:msg_node_ip} \- \- \[(?<msg_request_date>%{NOTSPACE} %{TIME})\] %{NOTSPACE:msg_method} %{NOTSPACE:msg_url} %{NOTSPACE:msg_http_ver} %{NUMBER:msg_response_status} %{NUMBER:msg_bytes} %{NUMBER:msg_response_time}"
}
}
}
}
} else if [node_service] == "cinder-api" {
if [log_module] == "eventlet.wsgi.server" {
if [msg] !~ "accepted" {
mutate {
gsub => [ "msg", "\"", "" ]
}
grok {
match => {
"msg" => "\[(req)?\-(%{NOTSPACE:msg_request_id} %{NOTSPACE:msg_uid} %{NOTSPACE:msg_tenant} \- \- \-)?\] %{IPV4:msg_node_ip}(,%{IPV4:msg_node_ip_2})? \- \- \[(?<msg_request_date>%{NOTSPACE} %{TIME})\] %{NOTSPACE:msg_method} %{NOTSPACE:msg_url} %{NOTSPACE:msg_http_ver} %{NUMBER:msg_response_status} %{NUMBER:msg_bytes} %{NUMBER:msg_response_time}"
}
}
}
}
} else if [node_service] == "keystone" {
if [log_module] == "eventlet.wsgi.server" {
mutate {
gsub => [ "msg", "\"", "" ]
}
grok {
match => {
"msg" => "\[\-\] %{IPV4:msg_node_ip}(,%{IPV4:msg_node_ip_2})? \- \- \[(?<msg_request_date>%{NOTSPACE} %{TIME})\] %{NOTSPACE:msg_method} %{NOTSPACE:msg_url} %{NOTSPACE:msg_http_ver} %{NUMBER:msg_response_status} %{NUMBER:msg_bytes} %{NUMBER:msg_response_time}"
}
}
}
}
}
output {
kafka {
bootstrap_servers => "kafka:9092"
topic_id => "logstash-log"
codec => "json"
}
}