Splunk Search

Not able to apply the timechart on mentioned query

nikhilup05
Observer

 

eval _raw = msg | rex "InputAmountToCredit\"\:\"(?<PayloadAmount>[^\"]+)" | rex "Request\#\:\s*(?<ID1>\d+) with (?<Status>\w+.\w+)" | rex "CRERequestId\"\:\"(?<ID2>[^\"]+)" | eval ID=coalesce(ID1,ID2) | stats latest(Status) as Status values(PayloadAmount) as Amount by ID| stats count(list()) by Status| eval _time=relative_time(now(),"-1d@d")|

 

Labels (1)
0 Karma

nikhilup05
Observer

I have passed  timechart usenull=f span=1d count by Status after the above query. But I am getting the error as no data found.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

This run-anywhere version of your query produces results.

| makeresults 
| eval msg="InputAmountToCredit\":\"23\", Request#: 11 with foo.bar CRERequestId\":\"fubar" 
| rex field=msg "InputAmountToCredit\"\:\"(?<PayloadAmount>[^\"]+)" 
| rex field=msg "Request\#\:\s*(?<ID1>\d+) with (?<Status>\w+.\w+)" 
| rex field=msg "CRERequestId\"\:\"(?<ID2>[^\"]+)" 
| eval ID=coalesce(ID1,ID2) 
| stats latest(Status) as Status values(PayloadAmount) as Amount by ID 
| stats count(list()) by Status 
| eval _time=relative_time(now(),"-1d@d") 
| timechart usenull=f span=1d count by Status

The results are uninteresting, however, because every value has the same timestamp (00:00 yesterday).

Also, what are you trying to achieve with stats count(list())?  The list() function is supposed to have an argument.

Perhaps you could explain the problem you are trying to solve so we can offer better solutions.

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

nikhilup05
Observer

I have to show Amount on barchart. I am not able to show it. pls help us

index = pcf_logs cf_org_name = creorg OR cf_org_name = SvcITDnFAppsOrg cf_app_name=VerifyReviewConsumerService host="*"
| eval _raw = msg | rex "InputAmountToCredit\"\:\"(?<PayloadAmount>[^\"]+)"
| rex field=msg "InputAmountToCredit\"\:\"(?<PayloadAmount>[^\"]+)"
| rex field=msg "Request\#\:\s*(?<ID1>\d+) with (?<Status>\w+.\w+)"
| rex field=msg "CRERequestId\"\:\"(?<ID2>[^\"]+)"
| eval ID=coalesce(ID1,ID2)
| stats latest(Status) as Status values(PayloadAmount) as Amount by ID
| stats count(list(PayloadAmount)) by Status
| eval _time=relative_time(now(),"-1d@d")
| timechart usenull=f span=1d count by Status

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

So you want Amount as one axis of the bar chart.  What should the other axis be?  Once we know that we can devise a query to produce the right information.  As it is now, the query seems to be doing a lot more work than is necessary.

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

nikhilup05
Observer

 On y axis, I I am trying show the amount  and in x axis status will be there on the date basis. 

Help me out with the mentioned query

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I'm still confused.  The x-axis will have "status on the date basis".  What does that mean?

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

nikhilup05
Observer

In x axis, I want to show the status (which will be approved/reject/Manual) and on the bar  I have to show the values of Amount for the particular status.  See the attached the sample view. 

 

nikhilup05_1-1635759315875.png

 

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Thanks for the clarifying charts.

Since each axis of a chart can use only one field, you will have to combine the date and Status fields into a single field before charting.

... | eval x_axis = date . " " . Status
| chart max(Amount) as Amount over x_axis
---
If this reply helps you, Karma would be appreciated.
0 Karma

nikhilup05
Observer

Please look this query and help to show the amount value on barchart

index = pcf_logs cf_org_name = creorg OR cf_org_name = SvcITDnFAppsOrg cf_app_name=VerifyReviewConsumerService host="*"
| eval _raw = msg | rex "InputAmountToCredit\"\:\"(?<PayloadAmount>[^\"]+)"
| rex field=msg "InputAmountToCredit\"\:\"(?<PayloadAmount>[^\"]+)"
| rex field=msg "Request\#\:\s*(?<ID1>\d+) with (?<Status>\w+.\w+)"
| rex field=msg "CRERequestId\"\:\"(?<ID2>[^\"]+)"
| eval ID=coalesce(ID1,ID2)
| stats latest(Status) as Status values(PayloadAmount) as Amount by ID
| stats count(list(PayloadAmount)) by Status
| eval _time=relative_time(now(),"-1d@d")
| timechart usenull=f span=1d count by Status

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

What is preventing you from applying a timechart?  How have you tried to do so?  What error do you get when you try?

---
If this reply helps you, Karma would be appreciated.
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 ...