Splunk Search

Adding new expected Value to serach result

mikroice90
Explorer

Hi,

I tried search some data from logs using this statement:

 

index=* sourcetype="mySource" Types* | stats count by Types 

 

in result I receive table like this:

Type15
Type24
Type31

I know that in the future in logs can occur Type4 so I would like to add it in to serach result by force. I tried some lookup stuff but i cant use it properly to get expected result.

So for now I would like to have table like this:

Type15
Type24
Type31
Type40

Thanks in advice for help.

Labels (2)

inventsekar
SplunkTrust
SplunkTrust

Hi @mikroice90 .. maybe, check this idea -
EDIT - using eval, we can check if type4 exist, if its null, assign a zero value.

 

index=* sourcetype="mySource" Types* | eval type4=if(isnull(type4),0,type4) | stats count by Types 

 

0 Karma

mikroice90
Explorer
  • @inventsekar  how it works in case: when logs with type4 will exist? It will still shows 0 instead of count value?
0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi @mikroice90 

the if condition is checking if type4 is null, then it adds type4=0, if it is not null, then it will take the current value of type4. 

0 Karma

mikroice90
Explorer

Brilliant, thanks a lot

 

One more question, This strings "Type1,Types2" etc. exist in more than one field in data set. Is it possible to count it all together instead of counting only by Types?

0 Karma

isoutamo
SplunkTrust
SplunkTrust
Please send example of events, so we could help you easier.
r. Ismo
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!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...