Splunk Search

How do I exclude Mondays from a Timechart

splunkuser2127
Loves-to-Learn

There are no data on Mondays so my timecharts always dip to 0.

 

{search string} | eval date_wday=lower(strftime(_time,"%A")) | where NOT (date_wday=monday) | timechart span=1d count by ColName

 

Is there any way to make the timechart skip Mondays (not just set it to 0)? 

Labels (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Depends on what you want to achieve.

Generally, it depends on your timerange. If you want to have data points: Wed, Thu, Fri,Sat,Sun,Tue,Wed and so on, without any "spaces" between sunday and tuesday, you can't do that with simple timechart. As the name implies, timechart does a chart over time so it doesn't mind your data as much as time progress.

You can try timecharting, then filtering out mondays, then doing a chart (not timechart) of remaining values. (can't provide you with a resulting search, I'm on my mobile and don't have access to my splunk installation ATM).

BTW, don't you think it will be confusing for the recipient of your report if you skip every monday (especially if you want do draw a line or barchart from the resulting data)?

0 Karma

splunkuser2127
Loves-to-Learn

It doesn't seem to be working for me, I can't turn a timechart into a regular chart (at least not in the way that's useful for me)

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try this way around

{search string} | timechart span=1d count by ColName | eval date_wday=lower(strftime(_time,"%A")) | where NOT (date_wday=monday)
0 Karma

splunkuser2127
Loves-to-Learn

Same result, didn't work.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
{search string} | timechart span=1d count by ColName | eval date_wday=lower(strftime(_time,"%A")) | where NOT (date_wday=monday)
| rename _time as time
| fieldformat time=strftime(time,"%Y/%m/%d")
0 Karma

splunkuser2127
Loves-to-Learn

Same result, it doesn't work. Mondays still show up as 0

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Are you putting Monday in quotes?

0 Karma

splunkuser2127
Loves-to-Learn

No, but with or without doesn't work

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you share your search as it stands now?

0 Karma

splunkuser2127
Loves-to-Learn

This is one attempt:

{search} | timechart span=1d count by ColName | eval date_wday=lower(strftime(_time,"%A")) | where NOT (date_wday=monday) | chart max(date_wday), count by ColName

 

This is another:

{search} | bin span=1d _time | eval date_wday=lower(strftime(_time,"%A")) | where NOT (date_wday=monday) | chart count by ColName

 

This second one gives me a regular bar chart xaxis column name y axis count, not sure how to do a multiseries chart over time (without using timechart)

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try 

| rename _time as time
| fieldformat time=strftime(time,"%Y/%m/%d")

As I suggested earlier

_time is treated as a special fieldname by the chart viz and it fills in the gaps e.g. Monday, by renaming it, you avoid that issue.

0 Karma

splunkuser2127
Loves-to-Learn

I've tried it in your earlier suggestion, how do you want me to construct the search now?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...