Splunk Search

How to append multiple columns to get result

aaa2324
Explorer

I am looking to get the data in year, month, day, hour, minute and second basis

search criteria is index="abc" rex field=raw"few fields" | stats count yearcount by year

The above query is giving me below columns

year      yearcount

2023      10

Similar to the above query we want to get count of month, day...seconds

the final output should have below table

year   yearcount   month   monthcount   day  daycount  ......seconds   secondscount

Is it possible to get this output without using appendcols function multiple time as it is making the search query very long and not effective.

 

Labels (1)
Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Apart from @ITWhisperer 's solution (which is sound in itself) question is how would you interpret such results.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

index="abc" rex field=raw"few fields"
| bin _time as seconds span=1s
| bin _time as minutes span=1m
| bin _time as hours span=1h
| bin _time as days span=1d
| bin _time as months span=1mon
| bin _time as years span=1y
| stats count secondscount by seconds minutes hours days months years
| eventstats sum(secondscount) as minutescount by minutes
| eventstats sum(secondscount) as hourscount by hours
| eventstats sum(secondscount) as dayscount by days
| eventstats sum(secondscount) as monthscount by months
| eventstats sum(secondscount) as yearscount by years
0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...