Splunk Search

How to get failure and success percentage based on a particular field?

krishnamurthyj
Observer

Hi,

I have many logs like this 

 

{"line":{"timestamp":"2022-07-27T20:35:32.756Z","level":"DEBUG","thread":"http-nio-8080-exec-4","mdc":{"clientId":"9AuZjs2vQMCfAYpSB","requestId":"62d-b003-3aff82daddc9","requestUrl":"http://example.com","requestMethod":"POST","apigeeRequestIdHeader":"rrt-0e9fc19850 378837932","requestUri":"/v1/exchanges","userId":"ZWJ5FWLNM"},"logger":"com.eServiceImpl","message":"ChangeSet is not Valid. Error count is : 4. Aggregate error message is : Property of type 'source.acc-1.0.0' is missing required property 'schemaNamespace'.\nProperty of type 'source.acc-1.0.0' is missing required property 'sourceId'.\nProperty of type 'host.acc-1.0.0' is missing required property 'fileUrn'.\nProperty of type 'host.acc-1.0.0' is missing required property 'versionUrn'..Total time for validation is : 0ms"},"source":"stdout","tag":"cd76691","attrs":{"cloudos.portfolio.version":"0.1.2001","com.amazonaask-arn":"arn:aus-west-716:task/COSV2-C-UW2/5e563a4","docker.image":"artifactory.devcloud.net/oud/001","obs.mnkr":"fdxs-abcd22"}}

 

 

Success validations are identified by the string "ChangeSet is Valid" in line.message field and failed validations are identified by the string "ChangeSet is not Valid" in line.message as shown above.

Now I want a query to get results of % of failed and passed events by line.mdc.clientId field.

Please Help!

Output:

ClientId     | failed %. | failed events (number).  | pass %  | passed events (number)

A.                 | X%            |. a                                              | Y%          |.  b

.

.

 

 

Basic search | line.message="ChangeSet is*"

 

 The above search is the basic search where I want the grouping of results (as discussed above in example as per clientId) to be happened .

Tags (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Would something like this do?

 

| rex field=line.message "ChangeSet is (?<verdict>[^\.]+)"
| stats count by verdict line.mdc.clientId
| eventstats sum(count) as total
| eval percent = round(100*count/total, 1)
| fields - count, total

 

It should give something like

verdictline.mdc.clientIdpercent
Valid9AuZjs2vQMCfAYpSB66.7
not Valid9AuZjs2vQMCfAYpSB33.3
0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...