Splunk Search

Summarize date per week

JandrevdM
Path Finder

Good day,

I have a query to summarize data per week. Is there a way to display my tables in a better way as my dates for the path month would just be the dates in number format? 

I would like to name the table Week 1, Week 2, Week 3 etc if possible.

index=db_it_network sourcetype=pan* url_domain="www.perplexity.ai" OR app=claude-base OR app=google-gemini* OR app=openai* OR app=bing-ai-base
| eval app=if(url_domain="www.perplexity.ai", url_domain, app)
| table user, app, _time
| stats count by user app _time
| chart count by app _time span=1w
| sort app 0


Labels (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

1. Don't put the "table" command in that place.  It doesn't do anything useful and (in distributed setup) moves the processing to the SH layer effectively losing the advantage of parallel stats processing on indexers.

2. I can't quite grasp what's the point of that | stats | chart idea. First you count, then you count the counts.

3. There is a timechart command for time series.

4. The overal idea with eval is OK but I'd rather use fieldformat - this way you can freely sort based on actual underlying time data but present the data in a human-readable way.

0 Karma

JandrevdM
Path Finder

Hi @PickleRick 

Thanks for the support.

The reason for the | stats | chart is to distinct my data by user. If I do not do this then I get multiple entries per user for each url. This allows for a user to only hit one url per week and then count them. 

I will try the suggestion. I recently moved from kql to spl and will try and figure out the format for timechart and fieldformat.

Thank you!

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Yup. That is one of ways to handle it. 🙂

 

0 Karma

JandrevdM
Path Finder
index=db_it_network sourcetype=pan* url_domain="www.perplexity.ai" OR app=claude-base OR app=google-gemini* OR app=openai* OR app=bing-ai-base
| eval app=if(url_domain="www.perplexity.ai", url_domain, app)
| table user, app, _time
| eval week_num = "Week Number" . strftime(_time, "%U")
| stats count by user app week_num
| chart count by app week_num
| sort app 0
0 Karma
Get Updates on the Splunk Community!

Splunk MCP & Agentic AI: Machine Data Without Limits

  Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization ...

Finding Based Detections General Availability

Overview  We’ve come a long way, folks, but here in Enterprise Security 8.4 I’m happy to announce Finding ...

Get Your Hands Dirty (and Your Shoes Comfy): The Splunk Experience

Hands-On Learning and Technical Seminars  Sometimes, you just need to see the code. For those looking for a ...