log_level info
# receive events over http
# these logs are coming from our node app containers in other namespaces
# Recieve events from 24224/tcp
# this is the preferred method for sending logs between fluent-bit and fluent-d peers
# not currently working accross multiple namespaces
#
### Process Error logs
# filter logs tagged with 'app' to include only code 5** errors
# and rewrite tag to app.error
@type rewrite_tag_filter
capitalize_regex_backreference yes
key code
# filter for 5** HTTP response codes
pattern ^5\d\d$
tag ${tag}.error
key log
# filter logs containing string 'EHOSTUNREACH'. for example: 'ERR! Error: connect EHOSTUNREACH 127.0.0.1:6379'
pattern EHOSTUNREACH
tag ${tag}.error
# reformat *.error logs into a Discord post
# content ${record["product"]} - HTTP response status code ${record["code"]}, hostname: ${record["hostname"]}, namespace: ${record["namespace"]}, agent: ${record["agent"]}, method: ${record["method"]}, path: ${record["path"]}, log: ${record["log"]}
@type record_transformer
enable_ruby true
auto_typecast true
username ${record["product"].upcase} (${record["namespace"]}) Alert
content ```json\n${record.to_json}\n```
## output errors to Discord AND stdout
# You need to use the 'copy' output plugin to output the same log to multiple sources
@type copy
# output using out_http plugin
@type http
# Discord webhook
endpoint https://discordapp.com/api/webhooks/abc/def
open_timeout 2
json_array false
content_type application/json
headers {"Content-Type":"application/json"}
@type json
flush_interval 2s
# send to stdout as well
@type stdout
### output all other logs to standard out
@type stdout