Splunk Search

max values from two weeks using timechart

secure
Path Finder

Hello Everyone,

i have a dataset where I'm generating a column of number of servers per day.  using a timechart command for last 2 weeks.
earliest="-14d" latest=now() index=*...... | timechart span=1d dc(hostname) as servercount

My requirement is to split the data in previous week and latest week and get the maximum count from the previous week and the latest week 

 

Labels (1)
Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @secure ,

did yu tried to use a different span period?

earliest="-14d" latest=now() index=*...... 
| timechart span=1w dc(hostname) AS servercount

Ciao.

Giuseppe

0 Karma

PickleRick
SplunkTrust
SplunkTrust

@gcuselloThat's something different. You're calculating weekly count of distict values whereas, as I understand, @secure wants to have maximum value of daily distinct count per week.

There are several possible approaches here.

One is to use the timechart output and use timewrap to transform the output into separate weekly data series. Since timewrap is a relatively straightforward command I'll leave the actual search to the reader 😉

Another way is to do manual binning

<@secure's search>
| bin _time span=1w as weekno
| stats max(servercount) by weekno
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...