Splunk ITSI

Timechart after Stats

andy
Engager

Hi everyone,

I am trying to create a timechart showing distribution of accesses in last 24h filtered through stats command. More precisely I am sorting services with low accesses number but higher than 2 and considerating only 4 less accessed services using this:

index =
|bin _time span=1h
| stats count by Service _time
| where count>2
| sort 4 count
| rename count as "Access number"
| timechart span=1h count by Service

 

Results would show services with number of accesses of 1 or 2 in a day despite the where clause. Thank you in advance for your help.

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Something like this?

richgalloway_0-1595280763615.png

Here's the search that produced it.

| gentimes start=07/19/2020 end=07/20/2020 increment=10m | eval Service="Service_".random()%10, _time=starttime
``` Above just sets up test data```
| bin _time span=1h
| stats count by Service _time
| where count>2
| sort 4 count
| timechart span=1h count by Service
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

andy
Engager

Yeah something like this is what I'm looking for, but first I need to consider only 4 services with lowest daily count

 

 

andy_0-1595317390378.png

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust
The query I gave you shows only 4 services.
---
If this reply helps you, Karma would be appreciated.
0 Karma

andy
Engager

Don't know why but in this way it only shows 1 service which reached 4 accesses in 1 hour, instead I would like to have a hour by hour timechart of the last 4 services by sum of daily events and having sum > 2 .

 

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Something like this?

richgalloway_0-1595280763615.png

Here's the search that produced it.

| gentimes start=07/19/2020 end=07/20/2020 increment=10m | eval Service="Service_".random()%10, _time=starttime
``` Above just sets up test data```
| bin _time span=1h
| stats count by Service _time
| where count>2
| sort 4 count
| timechart span=1h count by Service
---
If this reply helps you, Karma would be appreciated.
0 Karma

andy
Engager

But if I remove the sort how can I choose the 4 less accessed services?

This search gives me a list of data :

| stats count by Service _time
| where count>2
| sort 4 count

 

for instance  in last 24h

Service     |        Accesses
A                  |              3

B                 |              5

 

How can I reproduce a chart that would show me how this services are distributed  hour per hour in last 24h?

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Re-sort the results by time.

index =
| bin _time span=1h
| stats count by Service _time
| where count>2
| sort 4 count
| sort _time
| timechart span=1h count by Service

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The timechart command requires events to be in time order, but the query uses sort to put them in a different order.  Try removing the sort.

---
If this reply helps you, Karma would be appreciated.
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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...