Dashboards & Visualizations

How create line chart showing the count for Current week, prior week and third week?

SG
Path Finder

Hi Team,

I am planning to draw the trend of the webpage test speed index trend in Splunk which gives the performance of the speed index for the current week, last week, and last before week. I developed the below query to do the job, but I am not getting the trend and query giving some error. Can someone please help me to draw the trend?

 

index=nextgen sourcetype=lighthouse_json sourcetype=lighthouse_json datasource=webpagetest step="Homepage"
| eval myTime=case(test >= relative_time(now(), "-7d"), "CurrentWeek", test >= relative_time(now(), "-14d") AND test < relative_time(now(), "-7d", "PriorWeek", test >= relative_time(now(), "-21d") AND test < relative_time(now(), "-14d", "ThirdWeek", 1=1, "Other")
| stats  values(speedindex) as score by myTime 
| eval fast = if(score>0 AND score<2000,score,0)  
| eval moderate = if(score>=2000 AND score<2999,score,0) 
| eval slow = if(score>=3000,score,0)
| fields - score

 

Labels (1)
Tags (1)
0 Karma
1 Solution

SG
Path Finder

I could get data week wise using "timewrap" function in splunk.

 

index=nextgen sourcetype=lighthouse_json sourcetype=lighthouse_json datasource=webpagetest step="Homepage" earliest=-21d@d | timechart span=1h list(speedindex) as score | timewrap w

Source - https://docs.splunk.com/Documentation/Splunk/8.2.0/SearchReference/Timewrap

 

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| stats  values(speedindex) as score by myTime 

This returns a multi-value field of all the unique scores in the time period. Is that what you were expecting?

0 Karma

SG
Path Finder

I modified the query to get speed index values as per the week 

index=nextgen sourcetype=lighthouse_json sourcetype=lighthouse_json datasource=webpagetest step="Homepage" earliest=-7d@d
| eval myTime=case(_time >= relative_time(now(), "-7d"), "CurrentWeek", _time >= relative_time(now(), "-14d") AND _time < relative_time(now(), "-7d"), "PriorWeek", _time >= relative_time(now(), "-21d") AND _time < relative_time(now(), "-14d"), "ThirdWeek", 1=1, "Other")
| stats  values(speedindex) as score by myTime

Now i am getting data in the statistics panel as below. 

SG_0-1621243492699.png

But i am not getting any trend in the visualization panel.

SG_1-1621243584977.png

 

0 Karma

SG
Path Finder

I got to know that "values" function is giving results as a string, that's the reason I am not getting any trend. 

index=nextgen sourcetype=lighthouse_json sourcetype=lighthouse_json datasource=webpagetest step="Homepage" earliest=-7d@d
| eval myTime=case(_time >= relative_time(now(), "-7d"), "CurrentWeek", _time >= relative_time(now(), "-14d") AND _time < relative_time(now(), "-7d"), "PriorWeek", _time >= relative_time(now(), "-21d") AND _time < relative_time(now(), "-14d"), "ThirdWeek", 1=1, "Other")
| stats  values(speedindex) as score by myTime

Can you please tell me instead of "values", which function i can use to get the trend?

0 Karma

SG
Path Finder

I could get data week wise using "timewrap" function in splunk.

 

index=nextgen sourcetype=lighthouse_json sourcetype=lighthouse_json datasource=webpagetest step="Homepage" earliest=-21d@d | timechart span=1h list(speedindex) as score | timewrap w

Source - https://docs.splunk.com/Documentation/Splunk/8.2.0/SearchReference/Timewrap

 

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!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...