Splunk Search

Can you reference a token value inside a token eval tag?

johnraftery
Communicator

Hello, I have a token called range (assume it has a value of "123-456"), and I am trying to use it inside a token eval:

<eval token="start">replace($range$,"-.*","")</eval>

So start should have a value of "123". But when I run it, $start$ is not defined.
The replace works fine if I hard-code the range value like this:

<eval token="start">replace("123-456","-.*","")</eval>

Any help much appreciated!
John

1 Solution

aljohnson_splun
Splunk Employee
Splunk Employee

Single quotes !

<eval token="start">replace('range',"-.*","")</eval>

View solution in original post

aljohnson_splun
Splunk Employee
Splunk Employee

Single quotes !

<eval token="start">replace('range',"-.*","")</eval>

Cuyose
Builder

Odd, I can't get this to work worth anything. I am using a click.name2 value and attempting to edit it and nothing I do actually edits the token.

<eval token="parsedError">replace($click.name2$, "^[\d-{0,3}]", "")</eval>
0 Karma

pmelon
Explorer

I'm struggling with this too. Code is:

<eval token="eventTime_epoch">strptime('eventTime',"%d/%m/%y %H:%M")</eval>

If I replace eventTime with 01/01/19 21:21 I get a proper epoch time. eventTime is never expanded within the tags. I am stuck.

0 Karma

johnraftery
Communicator

Lovely, thanks very much. It also seems to work with no quotes, ie replace(range,"-.*","")

aljohnson_splun
Splunk Employee
Splunk Employee
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...