Splunk Search

How to add a word after a count?

jip31
Motivator

Hello

I use the search below and I would like to do 2 different things
1) How to do for adding a word after the stats count (for example I would like to have "250 machines")
2) How to do for adding a word with condition after the stats count (for example I would like to have "250 machines" if number of host is >0 and "any machines" if host=0 )

| inputlookup host.csv 
| stats count by host

Thanks

Tags (2)
0 Karma
1 Solution

chrisyounger
SplunkTrust
SplunkTrust

Try this:

| inputlookup host.csv 
| stats count by host
| eval count = if(count == 0, "any machines", tostring(count) + " machines")

View solution in original post

KailA
Contributor

You can try that

| inputlookup host.csv 
| stats count by host
| eval count = if(count > 0, count." machines","Any machines")

Let me know 🙂

0 Karma

vnravikumar
Champion

Hi

try like

|stats count by host | eval count = if(count >0, count." "."machines", "any machines")
0 Karma

chrisyounger
SplunkTrust
SplunkTrust

Try this:

| inputlookup host.csv 
| stats count by host
| eval count = if(count == 0, "any machines", tostring(count) + " machines")

jip31
Motivator

Thanks!!!!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...