Dashboards & Visualizations

Why is sparkline returning '0' or '1'?

lennys26
Communicator

I have a query that returns an avg calculation over time and I am using a sparkline to try to show the results for each 'period' over that time, however although my results are showing a correct value, my sparkline only shows a value of 0 or 1.

My search is:

 

 

 

| tstats SUM(ABC) as ABC, sum(DEF) as DEF where index=FOO earliest=-4h latest=-45m by _time platform span=5m 
| eval AVG_ABC=((sum(DEF)/sum(ABC))/60) 
| stats sparkline avg(AVG_ABC) by platform

 

 

 

 

Instead of the single line result with the sparkline over time, I get the following:

sparkline2.png

Can anyone point me in the right direction? Essentially I am looking to create something like a single number value viz with a trendline.

Thanks.

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| tstats SUM(ABC) as ABC, sum(DEF) as DEF where index=FOO earliest=-4h latest=-45m by _time platform span=5m 
| eval AVG_ABC=(DEF/ABC)/60 
| stats sparkline(avg(AVG_ABC)) by platform

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Try this since you have already renamed sum(DEF) as DEF and sum(ABC) as ABC

| eval AVG_ABC=(DEF/ABC)/60 
0 Karma

lennys26
Communicator

Hi@ITWhisperer. Bad SPL on my side (or perhaps i just foobar'ed by code when I was replacing all of the FOOs and BARs in my post 😁), but either way, thanks for the correction.

Anyhow, I have made the change, but this does not affect the end result.

Sparkline.png

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| tstats SUM(ABC) as ABC, sum(DEF) as DEF where index=FOO earliest=-4h latest=-45m by _time platform span=5m 
| eval AVG_ABC=(DEF/ABC)/60 
| stats sparkline(avg(AVG_ABC)) by platform

lennys26
Communicator

Ahh haa! I had spaces between the 'sparkline' and the function: 

| stats sparkline avg(AVG_LOC) by platform

instead of

| stats sparkline(avg(AVG_LOC)) by platform

The strange thing is that my notes show that I have used this with the space in the past. Either way, it is working now.

Thanks.

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 ...