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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...