Splunk Search

How to write a search to display a bar graph with span=1d?

thippeshaj
Explorer

I have a search looking for 7 days of data and one field below.
STATUS="Delivered","created","released","Awaiting Delivery"
Now I want a bar graph of Total orders and Delivered orders.
Total orders means sum of ("Delivered","created","released","Awaiting Delivery") and Delivered in time span=1d.

please help me how to write a search for this.

0 Karma
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi thippeshaj,

take this run everywhere search as example:

index=_internal 
| stats count(eval(sourcetype="splunkd")) AS s count(eval(sourcetype="mongod")) AS m count(eval(sourcetype="scheduler")) AS sch by _time 
| timechart span=1d sum(eval(s+m)) AS sum sum(sch) AS sch

This will count some sourcetype and sum them per day. Applied to your question you should be able to get your result if you run this search:

your base search here to get all fields 
| stats count(eval(STATUS="Delivered")) AS d count(eval(STATUS="created")) AS c count(eval(STATUS="released")) AS r  count(eval(STATUS="Awaiting Delivery")) AS a by _time 
| timechart span=1d sum(eval(d+c+r+a)) AS sum sum(d) AS delivered

Tweaked it as needed to get your expected result.

Hope this helps ...

cheers, MuS

View solution in original post

0 Karma

stephanefotso
Motivator

Hello. Try like this;

index=......  STATUS=*|stats count as Total_orders by _time|timechart span=1d Total_orders

Thanks

SGF
0 Karma

MuS
SplunkTrust
SplunkTrust

Hi thippeshaj,

take this run everywhere search as example:

index=_internal 
| stats count(eval(sourcetype="splunkd")) AS s count(eval(sourcetype="mongod")) AS m count(eval(sourcetype="scheduler")) AS sch by _time 
| timechart span=1d sum(eval(s+m)) AS sum sum(sch) AS sch

This will count some sourcetype and sum them per day. Applied to your question you should be able to get your result if you run this search:

your base search here to get all fields 
| stats count(eval(STATUS="Delivered")) AS d count(eval(STATUS="created")) AS c count(eval(STATUS="released")) AS r  count(eval(STATUS="Awaiting Delivery")) AS a by _time 
| timechart span=1d sum(eval(d+c+r+a)) AS sum sum(d) AS delivered

Tweaked it as needed to get your expected result.

Hope this helps ...

cheers, MuS

0 Karma

thippeshaj
Explorer

Hi Mus,

Many thanks.

Now I'll run that search as per the today data and now how to plot a graph from 12 Am to 12 PM comparing with the Yesterday's trend data.
The graph should show today's Bar chart ( total_orders & delivered_orders) and the Yesterdays trend line from 12AM to 12PM.

Please help me.

0 Karma

MuS
SplunkTrust
SplunkTrust

easiest option here, use the timewrap app https://splunkbase.splunk.com/app/1645/

0 Karma

thippeshaj
Explorer

Many thanks Mus

0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...