Splunk Search

Query to show specified time per day in timechart

Codie
Engager

Hi, I would like to create a time chart for a specified time suppose 8AM to 2PM everyday for last 30 days. I am able to chart it however in visualisation, the line from 2PM to next day 8AM is a straight line.

How can we exclude that line for duration(2PM to next day 8AM) and just show chart for 8AM to 2PM everyday as a single line.

Can we exclude the Green box line?

Query Used(just conditions):

| eval hour=tonumber(strftime(_time,"%H"))
| where hour >=8
| where hour <=14
| fields - hour



Splunk issue.png

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Because you are using _time as your x-axis, the chart will show all times in your time range. You could change your chart settings so that the lines are not joined

ITWhisperer_0-1719834419449.png

Alternatively, you could rename the _time field to something else, but then you would also have to format the time - you may also have to remove events where the value is null (depending on how your search is setup)

 

| rename _time as time
| fieldformat time=strftime(time,"%F %T")

 

However, this is likely to lead to the x-axis values having ellipses in, so you could rotate the labels

ITWhisperer_1-1719834666512.png

 

View solution in original post

0 Karma

yuanliu
SplunkTrust
SplunkTrust

If you only have one count to display, another potentially useful visualization is to shift all days into one 24-hour period.  Here is a demonstration for 9am - 5pm:

 

| tstats count where index=_internal earliest=-30d latest=+0d@d by _time span=1h
| eval day = relative_time(_time, "-0d@d")
| where relative_time(_time, "-8h@h") > day AND relative_time(_time, "-18h@h") < day
| timechart span=1h sum(count)
| timewrap 1day

 

Screenshot 2024-07-03 at 8.41.09 AM.png

 

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Because you are using _time as your x-axis, the chart will show all times in your time range. You could change your chart settings so that the lines are not joined

ITWhisperer_0-1719834419449.png

Alternatively, you could rename the _time field to something else, but then you would also have to format the time - you may also have to remove events where the value is null (depending on how your search is setup)

 

| rename _time as time
| fieldformat time=strftime(time,"%F %T")

 

However, this is likely to lead to the x-axis values having ellipses in, so you could rotate the labels

ITWhisperer_1-1719834666512.png

 

0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...