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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...