Open philippkahr opened 5 years ago
@philippkahr Did you ever make progress on this? I think this is my issue at the moment as well.
@clarkritchie sadly, no I never did any good progress on this. I think I solved it by doing some Docker filesystem mapping and picking it up with filebeat. I talked to @xeraa about that a while ago, that's what he has told me.
You can mount files around for Docker logging, but it's probably not the most elegant solution. System.Out is nicer, since you can then just pick up the default docker logs and also enrich them with metadata. https://github.com/xeraa/java-logging shows the different approaches in detail more detail and you can use those. And you will want to pick up the ECS output with https://www.elastic.co/guide/en/beats/filebeat/current/decode-json-fields.html. But I'll try to get a complete example out in the next couple of days anyway.
@philippkahr sorry, this got burried under too much other stuff. I just worked with something similar today and also ran into Error decoding JSON: json: cannot unmarshal number into Go value of type map[string]interface {}
.
You are collecting the log files from all the containers ('/var/lib/docker/containers/*/*.log'
) and try to convert them into JSON (json.message_key: log
). Are you running Filebeat in a container as well? Because Filebeat itself doesn't log JSON by default, so trying to convert those logs into JSON will fail. The two workaround could be:
logging.to_files: true
), so Filebeat won't try to collect its own (non-JSON) logs. Also you would avoid a logging loop when an error in Filebeat triggers a log statement that it then tries to collect itself,...Hi, this issue hasn't had any update in a long time !
Regarding integration of ECS logs and APM integration we now have a few "ready to use" examples in our contrib repo: https://github.com/elastic/apm-contrib/tree/main/apm-agent-java/log-ingest.
In particular here, the example 02 uses ECS logging library (the one in this repo) with a filebeat integration. Those examples remain file-based and do not use auto-discovery, but it should provide you a good start.
You are running into this issue https://github.com/elastic/beats/issues/20053#issuecomment-1899155624
You are JSON decoding your log three times.
First time by adding the container
input.
Second time by adding the json
keys to the container input, against log
, which does not exist anymore after the first decode.
Third time in decode_json_fields
processor.
The documentation is confusing in this regard to be fair, I spent quite some time on it.
If anyone is running into this, start simple by removing the processors and parsers and only keep the input type and path, with output to console, look at it, make sure you understand the output and move on.
output.console:
pretty: true
This can be closed I suppose, just like the issue I linked in the beginning, but the docs really need some quality examples added.
Hi,
I am having a hard time working out how to use it in conjunction with docker. I have a Java application that logs everything in JSON to a file inside the docker container. I have created a
ln -sf /dev/stdout /opt/application.json
symlink, so everything will be output to stdout. Of course, looking into the -json.log file created by Docker in the/var/lib/docker/container/containerid/*-json.log
it looks something like this:My filebeat config looks like this:
I am using the message decoder like suggested in the README
however, I can see a couple of errors in
journalctl -u filebeat -f
Any idea on how to use the ECS logging in combination with docker? I would love to have it, so I can jump from the APM to the
container logs
.