Outcold Solutions LLC

Using Splunk fields extractor to extract fields from container logs

June 20, 2018

Getting logs and metrics in your Splunk cluster is just a first step to manage your logs. Next step is to build your own custom dashboard to be able to explore the data you forward to Splunk.

The collector has a special format for sources that it forwards from container logs. We on purpose decided to replace it from unused and non-interesting /var/lib/docker/containers/{container_id}/{container_id}-logs.json to something that we can leverage with Splunk. So instead we are sending logs with the format that includes container name, image name and more, depends on used orchestration. You can find the format definition in Docker, Kubernetes and OpenShift documentation.

With the following example, we show how you can leverage this knowledge to extract fields from your container logs and start building custom dashboards. We use Monitoring OpenShift as an example, but you can apply this to any of our applications.

At first, you need to find the logs and define the source rule. Using wildcards you can cover multiple sources, like all containers that created from a specific image like in the example below

Finding logs

In our deployment we have 6 pods with similar sources.


Based on the format for OpenShift container logs we can define the source by applying wildcards to container id and pod suffix.


Using this pattern we can define field extraction in Splunk. For that go to the Settings, Fields, Field extractions and choose Open Field Extractor. Change data type to source and paste the source defined above. Verify that you can see all the logs that you expect and define fields extraction by following the wizard.

Finding logs

With this simple approach you can easily extract fields from container logs and start building custom dashboards.

kubernetes, openshift, docker, splunk

About Outcold Solutions

Outcold Solutions provides solutions for monitoring Kubernetes, OpenShift and Docker clusters in Splunk Enterprise and Splunk Cloud. We offer certified Splunk applications, which give you insights across all containers environments. We are helping businesses reduce complexity related to logging and monitoring by providing easy-to-use and deploy solutions for Linux and Windows containers. We deliver applications, which help developers monitor their applications and operators to keep their clusters healthy. With the power of Splunk Enterprise and Splunk Cloud, we offer one solution to help you keep all the metrics and logs in one place, allowing you to quickly address complex questions on container performance.