According to the documentation there are two ways to send log information to the SwisscomDev ELK service.
Asking about way 2. How is is this achieved, especially how is the input expected?
We're using Monolog in our PHP buildpack based application and using its stdout_handler
is working fine.
I was trying the GelfHandler (connection refused), SyslogUdPHandler (no error, but no result), both configured to use VCAPServices logstashHost
and logstashPort
as API endpoint / host to send logs to.
Binding works, env variables are set, but I have no idea how to send SwisscomDev ELK service Logstash API endpoint compatible log information from our application.
Logstash is configured with a tcp input, which is reachable via logstashHost:logstashPort
. The tcp input is configured with its default codec, which is the line
codec (source code; not the plain
codec as stated in the documentation).
The payload of the log event should be encoded in JSON so that the fields are automatically recognized by Elasticsearch. If this is the case, the whole log event is forwarded without further processing to Elasticsearch.
If the payload is not JSON, the whole log line will end up in the field message
.
For your use case with Monolog, I suggest you to use the SocketHandler (pointing it to logstashHost:logstashPort
) in combination with the LogstashFormatter which will take care of the JSON encoding with the log events being line delimited.