log_level info # receive events over http # these logs are coming from our node app containers in other namespaces @type http port 8080 bind 0.0.0.0 body_size_limit 32m keepalive_timeout 10s @type json #add_http_headers true ### TLS security disabled # # self_hostname fluentd # shared_key fluentd # # # version TLSv1_2 # ca_path /fluentd/etc/ssl/ca.crt.pem # cert_path /fluentd/etc/ssl/server.crt.pem # private_key_path /fluentd/etc/ssl/server.key.pem # #private_key_passphrase "#{ENV["TLS_PRIVATE_KEY_PASSPHRASE"]}" # #client_cert_auth true # # 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 # # @type forward # port 24224 # bind 0.0.0.0 # ### 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