Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logstash support for docker and kubernetes #175

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ services:
# logging: # Used for sending logs to ELK
# driver: "syslog"
# options:
# syslog-address: "tcp://localhost:5010"
# syslog-address: "tcp://localhost:5020"

exareme2_global:
image: madgik/exareme2_worker:${EXAREME2}
Expand Down Expand Up @@ -129,7 +129,7 @@ services:
# logging: # Used for sending logs to ELK
# driver: "syslog"
# options:
# syslog-address: "tcp://localhost:5010"
# syslog-address: "tcp://localhost:5020"

exareme2_controller:
image: madgik/exareme2_controller:${EXAREME2}
Expand Down Expand Up @@ -157,7 +157,7 @@ services:
# logging: # Used for sending logs to ELK
# driver: "syslog"
# options:
# syslog-address: "tcp://localhost:5010"
# syslog-address: "tcp://localhost:5020"

portalbackend_db:
image: postgres:11.20-alpine
Expand Down Expand Up @@ -219,7 +219,7 @@ services:
# logging: # Used for sending logs to ELK
# driver: "syslog"
# options:
# syslog-address: "tcp://localhost:5010"
# syslog-address: "tcp://localhost:5020"

gateway-db:
image: postgres
Expand Down
2 changes: 1 addition & 1 deletion dev/stop.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/env bash

docker-compose --env-file ../.versions_env down
docker compose --env-file ../.versions_env down
rm ../data/local.db
rm ../data/global.db
1 change: 1 addition & 0 deletions elk_stack/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
- "5044:5044"
- "9600:9600"
- "5010:5010/tcp"
- "5020:5020/tcp"
networks:
- elk
depends_on:
Expand Down
25 changes: 16 additions & 9 deletions elk_stack/logstash/pipeline/logstash.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
input
{
tcp {
beats {
port => 5010
type => syslog
add_field => { "source" => "kubernetes" }
}

tcp {
port => 5020
type => "syslog"
add_field => { "source" => "docker" }
codec => multiline {
pattern => "<%{NUMBER}>%{MONTH}%{SPACE}%{MONTHDAY}%{SPACE}%{TIME}%{SPACE}%{DATA}: %{TIMESTAMP_ISO8601} %{GREEDYDATA}"
negate => true
Expand All @@ -12,21 +18,22 @@ input
}

filter {
mutate{
gsub => [ "message", "\\n", "" ]
if [source] == "docker" {
mutate { #### Remove docker syslog driver prefix (only regex for multiline removal)
gsub => ["message", "<\d+>\w+\s+\d+\s+\d{2}:\d{2}:\d{2}\s+[^:]+:\s+", ""]
}
}

grok {
match => [

match => [
# ----- Match EXAREME2 logs -----
"message", "<%{NUMBER}>%{MONTH}%{SPACE}%{MONTHDAY}%{SPACE}%{TIME}%{SPACE}%{DATA}: %{TIMESTAMP_ISO8601:log_timestamp} - %{LOGLEVEL:loglevel} - %{DATA:method} - \[%{DATA:federation}\] - \[%{DATA:service}\] - \[%{DATA:node_id}\] - \[%{DATA:request_id}\] - %{GREEDYDATA:log_message}",
"message", "%{TIMESTAMP_ISO8601:log_timestamp} - %{LOGLEVEL:loglevel} - %{DATA:method} - \[%{DATA:federation}\] - \[%{DATA:service}\] - \[%{DATA:node_id}\] - \[%{DATA:request_id}\] - %{GREEDYDATA:log_message}",

# ----- Match PORTAL-BACKEND user generated logs -----
"message", "<%{NUMBER}>%{MONTH}%{SPACE}%{MONTHDAY}%{SPACE}%{TIME}%{SPACE}%{DATA}: %{TIMESTAMP_ISO8601:log_timestamp} - %{LOGLEVEL:loglevel}%{SPACE}- %{DATA:logger} - \[%{DATA:federation}\] - \[%{DATA:service}\] - User -> %{DATA:user} , Endpoint -> \(%{WORD:http_method}\) %{URIPATH:http_path} , Info -> %{GREEDYDATA:log_message}",
"message", "%{TIMESTAMP_ISO8601:log_timestamp} - %{LOGLEVEL:loglevel}%{SPACE}- %{DATA:logger} - \[%{DATA:federation}\] - \[%{DATA:service}\] - User -> %{DATA:user} , Endpoint -> \(%{WORD:http_method}\) %{URIPATH:http_path} , Info -> %{GREEDYDATA:log_message}",

# ----- Match PORTAL-BACKEND system generated logs -----
"message", "<%{NUMBER}>%{MONTH}%{SPACE}%{MONTHDAY}%{SPACE}%{TIME}%{SPACE}%{DATA}: %{TIMESTAMP_ISO8601:log_timestamp} - %{LOGLEVEL:loglevel}%{SPACE}- %{DATA:logger} - \[%{DATA:federation}\] - \[%{DATA:service}\] - %{GREEDYDATA:log_message}"
"message", "%{TIMESTAMP_ISO8601:log_timestamp} - %{LOGLEVEL:loglevel}%{SPACE}- %{DATA:logger} - \[%{DATA:federation}\] - \[%{DATA:service}\] - %{GREEDYDATA:log_message}"
]

add_tag => [ "parsed" ]
Expand Down