Skip to content

Commit f523a40

Browse files
committed
merge application and router logs into single pipeline
1 parent f1024b2 commit f523a40

File tree

7 files changed

+143
-80
lines changed

7 files changed

+143
-80
lines changed

lagoon-remote/logs-forwarder-logstash/.lagoon.yml

+8
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,11 @@ objects:
118118
externalName: ${SERVICE_NAME}.${OPENSHIFT_PROJECT}.svc.cluster.local
119119
sessionAffinity: None
120120
type: ExternalName
121+
- apiVersion: v1
122+
kind: Service
123+
metadata:
124+
name: application-logs
125+
spec:
126+
externalName: ${SERVICE_NAME}.${OPENSHIFT_PROJECT}.svc.cluster.local
127+
sessionAffinity: None
128+
type: ExternalName

services/logs2logs-db/.lagoon.yml

+8
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,11 @@ objects:
186186
externalName: ${SERVICE_NAME}.${OPENSHIFT_PROJECT}.svc.cluster.local
187187
sessionAffinity: None
188188
type: ExternalName
189+
- apiVersion: v1
190+
kind: Service
191+
metadata:
192+
name: application-logs
193+
spec:
194+
externalName: ${SERVICE_NAME}.${OPENSHIFT_PROJECT}.svc.cluster.local
195+
sessionAffinity: None
196+
type: ExternalName

services/logs2logs-db/pipeline/application-logs.conf

-29
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
input {
2+
udp {
3+
port => 5140
4+
queue_size => 5000
5+
receive_buffer_bytes => 26214400
6+
}
7+
lumberjack {
8+
port => 5044
9+
ssl_certificate => "certs/lumberjack.cert"
10+
ssl_key => "certs/lumberjack.key"
11+
codec => json
12+
}
13+
}
14+
15+
filter {
16+
if [message] =~ /^{.*}$/ {
17+
# message is JSON, this is an application log
18+
mutate {
19+
add_field => { "log-type" => "application-logs" }
20+
}
21+
json {
22+
source => "message"
23+
}
24+
if ![type] {
25+
mutate {
26+
add_field => { "type" => "noproject" }
27+
}
28+
}
29+
} else {
30+
# Not JSON, therefore a syslog and a router log entry
31+
mutate {
32+
add_field => { "log-type" => "router-logs" }
33+
}
34+
grok {
35+
match => ["message", "(?:%{SYSLOGTIMESTAMP:syslog_timestamp}|%{TIMESTAMP_ISO8601:timestamp8601}) %{SYSLOGPROG}: %{HAPROXYHTTPBASE}"]
36+
}
37+
grok {
38+
match => ["captured_request_headers", "%{URIHOST:request_header_host}\|%{GREEDYDATA:request_header_useragent}"]
39+
}
40+
grok {
41+
match => ["backend_name", "%{NOTSPACE:haproxy_backend}:%{NOTSPACE:openshift_project}:%{NOTSPACE:openshift_route}"]
42+
}
43+
grok {
44+
match => ["server_name", "pod:%{NOTSPACE:openshift_pod}:%{NOTSPACE:openshift_service}:%{NOTSPACE:openshift_pod_ip}:%{NOTSPACE:openshift_pod_port}"]
45+
}
46+
if ![openshift_project] {
47+
mutate {
48+
add_field => { "openshift_project" => "noproject" }
49+
}
50+
}
51+
}
52+
}
53+
54+
output {
55+
# stdout { codec => rubydebug }
56+
if [log-type] == "router-logs" {
57+
elasticsearch {
58+
user => admin
59+
password => "${LOGSDB_ADMIN_PASSWORD}"
60+
hosts => ["${ELASTICSEARCH_URL}"]
61+
index => "router-logs-%{[openshift_project]}-%{+YYYY.MM}"
62+
template => "/usr/share/logstash/templates/router-logs.json"
63+
template_name => "router-logs"
64+
template_overwrite => true
65+
}
66+
} else {
67+
elasticsearch {
68+
user => admin
69+
password => "${LOGSDB_ADMIN_PASSWORD}"
70+
hosts => ["${ELASTICSEARCH_URL}"]
71+
index => "application-logs-%{[type]}-%{+YYYY.MM}"
72+
template => "/usr/share/logstash/templates/application-logs.json"
73+
template_name => "application-logs"
74+
template_overwrite => true
75+
}
76+
}
77+
78+
}

services/logs2logs-db/pipeline/router-logs.conf

-47
This file was deleted.

services/logs2logs-db/pipelines.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
- pipeline.id: lagoon-logs
22
path.config: "pipeline/lagoon-logs.conf"
3-
- pipeline.id: router-logs
4-
path.config: "pipeline/router-logs.conf"
3+
- pipeline.id: router-application-logs
4+
path.config: "pipeline/router-application-logs.conf"
55
- pipeline.id: service-logs
66
path.config: "pipeline/service-logs.conf"
7-
- pipeline.id: application-logs
8-
path.config: "pipeline/application-logs.conf"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"template" : "application-logs-*",
3+
"version" : 60002,
4+
"settings" : {
5+
"index.refresh_interval" : "5s",
6+
"number_of_shards": 1,
7+
"number_of_replicas": 1
8+
},
9+
"mappings" : {
10+
"_default_" : {
11+
"dynamic_templates" : [ {
12+
"message_field" : {
13+
"path_match" : "message",
14+
"match_mapping_type" : "string",
15+
"mapping" : {
16+
"type" : "text",
17+
"norms" : false
18+
}
19+
}
20+
}, {
21+
"string_fields" : {
22+
"match" : "*",
23+
"match_mapping_type" : "string",
24+
"mapping" : {
25+
"type" : "text", "norms" : false,
26+
"fields" : {
27+
"keyword" : { "type": "keyword", "ignore_above": 256 }
28+
}
29+
}
30+
}
31+
} ],
32+
"properties" : {
33+
"@timestamp": { "type": "date"},
34+
"@version": { "type": "keyword"},
35+
"geoip" : {
36+
"dynamic": true,
37+
"properties" : {
38+
"ip": { "type": "ip" },
39+
"location" : { "type" : "geo_point" },
40+
"latitude" : { "type" : "half_float" },
41+
"longitude" : { "type" : "half_float" }
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)