Splunk Search

count value not returning

kiran007
Explorer

Hi,

I'm Trying to calculate success percentage, for that I'm taking total and request count. but, I'm unable to get count for the request.

Please see the attachments to get more insights.

Image1 :- Gives total count of book appointment  request count.

Image2 :-  Unable to get Request count from the total book appointments.

Image3 :-  Example of   Successfully getting results.

 

Please help me to resolve this. 

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

I think I see the problem.  Splunk looks at "*bookappointment*" as a literal string whereas you're probably expecting the asterisks to be treated as wildcards.  To find a string within a string, use either the like or match function.

| stats ..., sum(eval(like(msg, "%bookappointment%"))) as response

or

| stats ..., sum(eval(match(msg, "bookappointment"))) as response

Notice I changed the count function to sum.  That's because count will include all of the 1's and 0's returned by eval, giving the same result regardless of the value of msg.  The sum function, however, effectively counts only 1's.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

kiran007
Explorer

Thanks @richgalloway  for quick response. I tried both but no luck.

Please see attachment.

0 Karma

kiran007
Explorer

Getting Individual Book Appointment Response count, but not getting bookappointmentresponse count from *bookappointment*

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I think I see the problem.  Splunk looks at "*bookappointment*" as a literal string whereas you're probably expecting the asterisks to be treated as wildcards.  To find a string within a string, use either the like or match function.

| stats ..., sum(eval(like(msg, "%bookappointment%"))) as response

or

| stats ..., sum(eval(match(msg, "bookappointment"))) as response

Notice I changed the count function to sum.  That's because count will include all of the 1's and 0's returned by eval, giving the same result regardless of the value of msg.  The sum function, however, effectively counts only 1's.

---
If this reply helps you, Karma would be appreciated.

kiran007
Explorer

Thanks @richgalloway  it worked....👍

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Two thoughts.

1) Try 'data.msg' similar to what is done in Image 3.

2) Try renaming data.msg.

... | rename "data.msg" as msg
| stats ... eval(msg="...") as response
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...