Splunk Search

How to search all the events consisting of a word that I get from a variable?

piece
Explorer

Consider I have 8 events.
1. txn started for fruit.mango
2. money paid for fruit.mango
3. received fruit.mango
4. txn completed for fruit.mango
5. cust wants to buy apple
6. getting money for apple
7. sending apple to cust
8. txn started for veegtable.carrot


I get a variable 'name' from my dashboard. This name is actually a string consisting of space separated words or just a single word. For ex. it could be either 'apple' or 'txn started for fruit.mango'.  What I want to do is first I want to extract the name of article then search the whole event space with that article name and then do further processing.

Ex. If I get $name$= 'txn started for fruit.mango'. I want to extract mango and then run the query such that I get all the events which have the word mango in it. After that i create a table of the steps the transaction took. I use 

 

 

index=.. $name | if(match($name, "\s"), mvindex(split($name, "."), 1), $name)

 

 

to extract the name but  then I get only a single event matching that is `txn started for fruit.mango`, other events which also has 'mango' in it like 'received fruit.mango' doesnt match.

How do I go about it? Any help will be much appreciated, thanks.

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
<form version="1.1">
  <label>Text parsing</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="name">
      <label>Select name</label>
      <choice value="txn started for fruit.mango">txn started for fruit.mango</choice>
      <change>
        <eval token="app">mvindex(split($name$,"."),1)</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>app is $app$</html>
    </panel>
  </row>
</form>

View solution in original post

piece
Explorer

@ITWhisperer Oh, in that case could you please help me to figure out how to use <eval> before <search> tag in xml.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Where is this "variable" coming from?

If it is from a SimpleXML input, you could include some change processing on the input to create a token which has split "mango" from the rest of the input token value, and use that token instead.

0 Karma

piece
Explorer

@ITWhisperer I can not make changes to the input variable 'name' as a lot of other things depend on it.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I am not saying to change 'name', I said to create a token (based on the contents of 'name')

0 Karma

piece
Explorer

@ITWhisperer Oh, in that case could you please help me determine how do I use <eval> tag to extract the value before the <search><query>My splunk query</query></search>

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
<form version="1.1">
  <label>Text parsing</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="name">
      <label>Select name</label>
      <choice value="txn started for fruit.mango">txn started for fruit.mango</choice>
      <change>
        <eval token="app">mvindex(split($name$,"."),1)</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>app is $app$</html>
    </panel>
  </row>
</form>
Get Updates on the Splunk Community!

Splunk Observability Synthetic Monitoring - Resolved Incident on Detector Alerts

We’ve discovered a bug that affected the auto-clear of Synthetic Detectors in the Splunk Synthetic Monitoring ...

Video | Tom’s Smartness Journey Continues

Remember Splunk Community member Tom Kopchak? If you caught the first episode of our Smartness interview ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud? Learn how unique features like ...