Splunk Search

How to append text in field on result not found

Lukas972
Engager

Let's suppose I have TOTO in successfully in my logs. I want to display the result for TOTO and append that no result found for TITI and TUTU with linecount=0 and their name in UNIT.

Somebody can help me ?

 

| search "successfully"
| makemv delim="," _raw
| table host, unit, linecount
| stats count by unit | where unit IN ("TOTO",TITI",TUTU")
| append [ ... I'm bugging ... ]

 

If there is another way to loop on value, I'm open. I didn't found how to declare and use variable exept with token ...

Labels (2)
Tags (3)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

There is no "looping" as such in Splunk. You can iterate over the fields in results but that's it. Yes, with some clever trick you can (ab)use this functionality to do "paraprogramming" but that's not what Splunk is about.

See my response to https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565220

 

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

There is no "looping" as such in Splunk. You can iterate over the fields in results but that's it. Yes, with some clever trick you can (ab)use this functionality to do "paraprogramming" but that's not what Splunk is about.

See my response to https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565220

 

0 Karma

Lukas972
Engager

Thanks, It work !

That's my new code :

<query>
index=mysourcelog "successfully" unit IN ($units_tok$)
| stats by unit
| append [ | makeresults
| eval _raw="TOTO
TUTU
TITI"
| multikv noheader=t
| rename Column_1 as unit
| stats sum(count(linecount)) by unit
</query>
<option name ="drilldown">cell</option>
<drilldown>
 <set token="units_tok">"TOTO","TITI","TUTU"</set>
</drilldown>

I understand now that i need to have another approch of Splunk ... I will try to variabilize the content for multikv. 

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...