Splunk Search

Show data from current week and breakdown weekly for the whole year for some fields

sumitdhameja1
Loves-to-Learn Everything

Hi,

I am a newbie to splunk so apologies if I didn't follow any right etiquettes while creating this issue.

I am trying to create a table where I can show some statistical fields(avg,95perc,count) from current week for a given host and then show the trend from the beginning of the year for only count,95perc. Something like the table below:

Service

CurrentWeek:total

CurrentWeek:

avg_some_field

CurrentWeek:

some_field_95

2021-03-19:total

2021-03-19:

some_field_95

2021-03-12:total

2021-03-12:

some_field_95

HOST1

 

 

 

 

 

 

 

HOST2

 

 

 

 

 

 

 

 

The way I'm currently doing this by using a join for the current week and aggregating data for the year broken down by week on host field as shown below:

    

    index=some_index earliest=@w latest=now sourcetype="some_src_type" 
    | stats count as total, avg(some_fieldas avg_some_field,  perc95(some_fieldas some_field_95 by host_name
    | join type=outer host_name
    [search index=some_index  earliest=@y latest=@w  sourcetype="some_src_type" 
     | bin _time span=1w
     | eval week=strftime(_time,"%Y-%m-%d")
     | stats count as total_by_week,  perc95(some_fieldas some_field_95 by host_name, week
     | chart sum(total_by_weekas total,  mean(some_field_95as some_field_95  by host_name, week useother=f
    ]
    | rename host_name as "Host", total as "CurrentWeek:total", avg_some_field as "CurrentWeek:avg_some_field", some_field_95 as "CurrentWeek:some_field_95" 


ASK:
If a host doesn't exist in current week, it doesn't show up in final table (because of the join) Is there a better way to solve this? Also, I would like following weeks to be in descending order in columns to show the most recent ones first. Currently it shows then in ascending order.

@woodcock @DalJeanis @niketn 
Labels (4)
0 Karma
Get Updates on the Splunk Community!

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...