Splunk Search

How to change the search that will convert table format to bar or column chart?

power12
Communicator

Hello Splunkers ,

I have the following search which gives me the the dashboard look as table...but can  we make this as a column or bar chart where each bar is a SN and when hover over shows the duration 

 

 

index=abc  
| stats earliest(_time) as etime latest(_time) as ltime by SN 
| eval duration=ltime - etime
| eval time_duration=tostring(duration, "duration")
| fields  SN time_duration

 

 

 

Below is the sample events

2023-03-01T11:14:41.094095-08:00 hostabc log-inventory.sh[22269]: GPU7: PCISLOT: xx.yyy, MODEL: Graphics Device, PN: 2vvv1, BOARDPN: vvv, SN: 155552
2022-03-01T11:14:41.094095-08:00 hostabc log-inventory.sh[22269]: GPU7: PCISLOT: xx.yyy, MODEL: Graphics Device, PN: 2vvv1, BOARDPN: vvv, SN: 155552,

Thanks in Advance

Labels (2)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

If you want the Y-axis to be duration, then it must be numeric, so you can't use tostring. You will have to represent it in whatever time quantifier makes sense, in this case, where the duration is 365 days, so in this example,

| eval duration=ltime - etime
| eval duration=duration/86400
| fields  SN duration

Convert the time to days (divide by 86400) and then show as a bar chart. Your divisor can be 3600 for hours or whatever makes sense given your data.

If you have big differences between durations, then it will make sense to show a log scale Y-axis.

0 Karma

power12
Communicator

@bowesmana Thank you for your reply .But I am trying to see if can we make one ourselves and define our own bins....
For example, if the longest time a SN has been installed is 400 days, and we have xx SN's.  divide 400 days by 20, Then we define the bin, and each bin is 400/20.
xaxis is
Bin 1- 0-20 days
Bin 2 21-40 days
bin 3 41-60 days
blah blah Can we determine how many SN's have been installed for 0-20 days sum it and plot is for bin 1.... Maybe the Y-axis is 5 for bin1 because 5 SN's have been in the there for 0-20 days. etc

Thanks in Advance

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

index=abc  
| stats earliest(_time) as etime latest(_time) as ltime by SN 
| eval duration=ltime - etime
| eval duration=duration/86400
| bin duration as days span=20
| chart count by days
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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...