Splunk Search

How to chart a line visual?

CodingMaestro
Path Finder

So I currently have a stats sum donuts for the last 90 days and i am getting the following results like below

sum(donuts)
54000

 

But i need a line chart to show the total number of donuts (sum (donuts) field)  for the last 90 days but just on  a 4 weeks interval. So i should have something like below

CodingMaestro_0-1677143093712.png

I have a field for the lastEaten date but that shows how many were eaten on that specific date. 

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

My original intention was for you to replace the last stats command with the timechart command I gave, but now that I see the full query I know that will not work.

You asked for a chart with a 4-week interval, but that requires a time field (preferably _time), which your query does not have.  Well, it appears to be missing, but the ... may be masking its presence.

Modify the query to pass _time through to the end and then the timechart command will be able to graph the results for you.

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

View solution in original post

richgalloway
SplunkTrust
SplunkTrust
| timechart span=4w sum(donuts) as Total
---
If this reply helps you, Karma would be appreciated.

CodingMaestro
Path Finder

CodingMaestro_0-1677177519263.png

I am getting no results found

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Please share the query.

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

CodingMaestro
Path Finder

index.....
| stats latest(...) latest(....) latest(....) by .....
| rename latest(*) as *
| eval eaten_90d = case(isnull(daysSince), null(), daysSince < 90, 1, 1=1, 0)
|eval eaten_30d = case(isnull(daysSince), null(), daysSince < 30, 1, 1=1, 0)
|eval eaten_60d = case(isnull(daysSince), null(), daysSince < 60, 1, 1=1, 0)
| stats dc(....) as Donuts sum(....) as Disabled sum(eaten_90d) as 90d_eaten sum(eaten_30d) as 30d_eaten sum(eaten_60d) as 60d_eaten by ... Donuts
| lookup ..... id as ..... OUTPUT......
| lookup .... OUTPUT ......
| search .....
| sort ....
| search 90d_eaten=0 AND 60d_eaten=0 AND 30d_eaten=0
| stats sum(Donuts)

0 Karma

CodingMaestro
Path Finder

i tried adding your timechart command after the last line but it did not work

0 Karma

richgalloway
SplunkTrust
SplunkTrust

My original intention was for you to replace the last stats command with the timechart command I gave, but now that I see the full query I know that will not work.

You asked for a chart with a 4-week interval, but that requires a time field (preferably _time), which your query does not have.  Well, it appears to be missing, but the ... may be masking its presence.

Modify the query to pass _time through to the end and then the timechart command will be able to graph the results for you.

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

CodingMaestro
Path Finder

Perfect, Thank You

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...