portainer: JSON-formatted logs fail on portainer-ce 2.16.0
Bug description
Viewing JSON-formatted container logs in portainer-ce 2.16.0 shows this “Failure” popup:
JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 15 (6 by maintainers)
Fixed by introducing a fallback to “raw display” if an error is encountered during parsing. The fix will be available in the next release.
Hello there, first thank you all for your reports that helped narrow the issue 🙌
To give you some details, with 2.16 we introduced the ability for Logs Viewers to automatically format / prettify JSON logs (so you don’t have to read raw JSON). The prettified version being what you can find in Portainer container’s logs.
These logs can be in many formats:
"{\"some_key\":\"some value\"}\"
)This 3rd scenario (serialized JSON logs) requires to parse the logs 2 times to be able prettify them
The pattern used to detect if we were receiving logs as serialized JSON was broken and detected serialized JSON logs in regular logs when there was none…
➡️ A fix candidate is available in image
portainerci/portainer:pr7961
This image is based on our latest release image
portainer/portainer-ce:2.16.0
. If some of you are able to give it a shot, with the diversity of images you all have, it will ensure everything is working fine for everyone 🙌Downgrading to 2.15.1 works fine with same configuration.