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!

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...

Everything Community at .conf24!

You may have seen mention of the .conf Community Zone 'round these parts and found yourself wondering what ...

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...