Splunk Search

String validation in chart eval

marellasunil
Communicator
  1. For another query where I have to use not equal to in a query for string, even not equal to is not working properly in eval There are 10 services with Success and failures, Consider as A, B ...J, for one service say B there is an error code 102, 103 & 104 (It is an error). If errorcode is 102 I want to add it to success so I used the query

.. | chart count(eval(Status="Success" OR ServiceName="B" AND ErrorCode=102)) as "Success", count(eval(Status="Error" OR ServiceNameLookup="B" AND ErrorCode!=102)) as "Fail" by ServiceName

This query counting 102 for both sucess & falures.

Any suggetions for both please

Tags (3)
0 Karma

kristian_kolb
Ultra Champion

UPDATE (or rather a complete rewrite)

It's too late in this TZ to do any clever thinking. Forget the previous attempt, and do like this instead;

... | eval NewStat = if(errorcode=="102" AND service=="B", "success", status) | ...

This creates a temporary variable called NewStat in each event, which will be set to 'success' if the errorcode=102 and the service=B, for all other events it will just copy the value of 'status'.

Then you can use NewStat for any further reporting, such as;

... | chart c over service by NewStat

Hope this helps,

Kristian

kristian_kolb
Ultra Champion

see update above. tested and working. /k

0 Karma

marellasunil
Communicator

Sorry, Kristian. That did't work. 😞 tried in several ways

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...