Dashboards & Visualizations

How do I trim a field in a Splunk dashboard?

anthonyantos
Engager

Hello,

I have a dashboard that I'm first appending to, example: |eval host=host." @ ".type which would result in myhost @ kc.

Then, I'm using a token to do a search, which would be index={myindex} source={mysource} $host$ *. I need to strip the host back to its original by removing the " @ kc" in this case.

I've tried the |makeresults "index={myindex} source={mysource} $host$ *" |rex mode=sed field=host "s/\s@\s\w+//g" but it won't return any results in my search.

Any help would be appreciated

0 Karma
1 Solution

DalJeanis
Legend

Okay, so first, you haven't explained why you are adding the @.type Why don't you add it to a different version of the field, with a slightly different name, and then use the original for the new search?

Second, you can try something like this...

index={myindex} source={mysource} 
    [
    | makeresults 
    | eval host="$host$" 
    | table host 
    | rex mode=sed field=host "s/\s@\s\w+/*/g"
    ]

View solution in original post

0 Karma

DalJeanis
Legend

Okay, so first, you haven't explained why you are adding the @.type Why don't you add it to a different version of the field, with a slightly different name, and then use the original for the new search?

Second, you can try something like this...

index={myindex} source={mysource} 
    [
    | makeresults 
    | eval host="$host$" 
    | table host 
    | rex mode=sed field=host "s/\s@\s\w+/*/g"
    ]
0 Karma

anthonyantos
Engager

Thanks for the assistance

DalJeanis
Legend

@anthonyantos - Glad we were able to help. You didn't tell us which one worked for your use case.... whether you went with the deeper fix, or whether the code worked. People researching their own problems later might find that information helpful... - dal

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!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...