put worker log to ELK

This commit is contained in:
aynsix
2020-04-24 20:27:11 +03:00
parent fa25b39da8
commit 30fa50f48d
4 changed files with 71 additions and 0 deletions

2
.gitignore vendored
View File

@@ -19,6 +19,8 @@
# Exclude configuration folder exception the configuration sample file
/config
!/config/configuration.sample.yml
!/config/filebeat.yml
!/config/logstash.conf
# Exclude generated proxies from doctrine2
#/resources/proxies

9
config/filebeat.yml Normal file
View File

@@ -0,0 +1,9 @@
filebeat:
inputs:
- type: log
enabled: true
paths:
- /var/alchemy/Phraseanet/logs/task_*.log
- /var/alchemy/Phraseanet/logs/worker_service*.log
output.logstash:
hosts: ["logstash:5044"]

36
config/logstash.conf Normal file
View File

@@ -0,0 +1,36 @@
input {
beats {
port => 5044
}
}
filter {
clone {
clones => ["to_stdout"]
}
if [type] == "to_stdout" {
#display only message field in the logstash stdout
prune {
whitelist_names => ["message"]
}
mutate {
add_field => { "[@metadata][type]" => "to_stdout" }
}
}
else {
mutate {
add_field => { "[@metadata][type]" => "to_elasticsearch" }
}
}
}
output {
if [@metadata][type][1] == "to_stdout" {
stdout {
codec => rubydebug
}
}
else {
elasticsearch { hosts => ["elasticsearch:9200"] }
}
}

View File

@@ -91,6 +91,30 @@ services:
image: kibana:4.6.6
ports:
- 5601:5601
links:
- elasticsearch
depends_on:
- elasticsearch
logstash:
image: logstash:7.6.2
links:
- elasticsearch
volumes:
- ${PHRASEANET_CONFIG_DIR}:/var/alchemy/Phraseanet/config:rw
command: logstash -f /var/alchemy/Phraseanet/config/logstash.conf
depends_on:
- elasticsearch
restart: on-failure
filebeat:
hostname: filebeat
image: "docker.elastic.co/beats/filebeat:7.6.2"
volumes:
- ${PHRASEANET_CONFIG_DIR}/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
- ${PHRASEANET_LOGS_DIR}:/var/alchemy/Phraseanet/logs:ro
command: filebeat run -e --strict.perms=false
restart: on-failure
networks:
default: