Splunk Dev

Parsing logs from Python Docker container sent to Splunk HEC

reallyliri
Explorer

I'm sending all my docker containers logs to my local Splunk server.

One of these containers is running a Python server (using Flask/nginx).

For debugging and log file reasons, my Python logs are foramtted with a standard line: %(asctime)s - %(name)s - %(levelname)s - %(message)s

I can see the log line clearly in Splunk, however, I would also want to parse the timestamp, log-level etc. In addition, it seems that stack traces are split to multiple messages.

screenshot

Note that not all messages from the host sent to this server are from Python, but the other ones don't require additional formatting.

So:

  • How can I configure Splunk to parse my messages according to my log format?

  • How can I merge the stack trace logs to a single message (I'm guessing that it should be done on consuming)

  • Can I define formatting for the Python messages without damaging the 'other' messages?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...

[Puzzles] Solve, Learn, Repeat: Tiling

This puzzle (first published here) is based on finding groups of tessellated tiles (inspired by floor tiles I ...

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...