Splunk Search

Is it possible to perform stats within a transaction?

the_wolverine
Champion

I have a transaction with multiple values for the same field. Is it possible for me to do a dc(other_field) within a transaction?

My search | transaction same_field maxspan=1m | stats dc(other_field)

Above doesn't seem to work, it just throws away my transactions.

Tags (2)
1 Solution

wpreston
Motivator

I think mvcount() could be your friend here. Something along these lines:

your search | transaction same_field maxspan=1m | eval same_field_count=mvcount(same_field)

...something like that. same_field_count should be a count of the distinct values of same_field within each transaction. If you want a total count of ALL values of same_field (including duplicates) within each transaction, use the mvlist option within your transaction. I'm not where I can test this search but I think it will be pretty close to what you need.

View solution in original post

wpreston
Motivator

I think mvcount() could be your friend here. Something along these lines:

your search | transaction same_field maxspan=1m | eval same_field_count=mvcount(same_field)

...something like that. same_field_count should be a count of the distinct values of same_field within each transaction. If you want a total count of ALL values of same_field (including duplicates) within each transaction, use the mvlist option within your transaction. I'm not where I can test this search but I think it will be pretty close to what you need.

nivedita_viswan
Path Finder

I dont believe mvcount returns a count of the distinct values. It simply returns a count of the number of values

0 Karma

wpreston
Motivator

Sure, happy to help!

0 Karma

the_wolverine
Champion

Yes! Thank you!!

0 Karma

kristian_kolb
Ultra Champion

eventstats perhaps?

0 Karma
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 ...