Best way to send complex logs from NodeJS


(Simon Bruneaud) #1

Hey,

I have a NodeJS application, and I would like to send logs to our ELK server (in a docker-container).
I read a lot about Logstash pipeline, and a lot of articles about how to send logs.
But I can't figure out what is the best way to send complex data logs to Kibana.

I would like to send server request logs. The logs should contain the following data field:

  • IP adress
  • Geolocalization
  • Country
  • request_method
  • request_path
  • request_duration
  • response_status
  • response_message
  • server_error
  • log_level
  • log_message

This logs enable me to extract metrics from it and notify in case of errors.
What is the best way to send this data in order to handle this in Kibana?
I could use the add_field property from the HTTP input and add every field.

Here is my plugins configuration (but I don't know if it works to parse in Kibana) :

input {
  http {
    port => "8080"
    codec => "json"
  }
}

filter {
  json {
    source => "message"
  }
}

output {
  elasticsearch {
    host => "localhost"
    document_type => "logs"
    codec => "json"
    index => "logstash-%{+YYYY.MM.dd}"
  }
}

Note: maybe the best way is not to use Logstash?
Best regards


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.