Splunk Search

I have to aggregate events in index by week and by month.

snigdhasaxena
Communicator

I have tried using bin command but as
index=test| bin span=1w _time | chart count as total_count by _time, action

But this gives me event count over a span of 30days for every 7 days.

Please help me understand how to aggregate events in index by week and by month.

Tags (1)
0 Karma
1 Solution

adonio
Ultra Champion

hello there,

try this out:

  index = test
    | bin _time span=1w as week
    | bin span=1mon _time as month
    | stats count as total_count by week month action
    | eval week_human = strftime(week, "%Y-%U")
    | eval month_human = strftime(month, "%Y-%B")

hope it helps

View solution in original post

woodcock
Esteemed Legend

It may be painful to do this on the raw data if you need to do this all the time, over and over. If you do, this is the kind of thing where a Summary Index is useful;

https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Configuresummaryindexes

If you aggregate daily, then it becomes trivial to mine it out by week or by month from your daily aggregation/summary.

0 Karma

adonio
Ultra Champion

hello there,

try this out:

  index = test
    | bin _time span=1w as week
    | bin span=1mon _time as month
    | stats count as total_count by week month action
    | eval week_human = strftime(week, "%Y-%U")
    | eval month_human = strftime(month, "%Y-%B")

hope it helps

Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...