Splunk Search

How to display a custom field with underscore from search result

splunkrocks2014
Communicator

For instance, how to show "_msg" from the search result? Thanks.

| makeresults
| eval _msg="Hello World"
Tags (1)
0 Karma

elliotproebstel
Champion

You can rename the field to not start with an underscore, and then Splunk will display it:

| makeresults
| eval _msg="Hello World"
| rename "_msg" AS "msg"

If you have many fields that start with underscores, you could do this:

| makeresults
| eval _msg="Hello World"
| rename "_*" AS "*"

Note that this will also display and convert other internal fields, like _time.

elliotproebstel
Champion

If you are wondering why you need to rename them at all, it's because Splunk uses underscores to identify internal fields:

https://docs.splunk.com/Splexicon:Internalfield
http://docs.splunk.com/Documentation/SplunkCloud/7.0.0/Knowledge/Usedefaultfields

Get Updates on the Splunk Community!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...