Splunk Search

How can I apply mvdedup to field dst.port only if numbers of dst ports = field COUNT?

bosseres
Contributor

Hello everyone!

I have basic search

index=main
| stats list(src.port), list(dst.port) count(src.ip) as COUNT by id

How can I apply mvdedup (or stats dc, don't know how better) to field dst.port only if numbers of dst ports = field COUNT?

Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The mvdedup function and stats dc() command do different things. mvdedup removes duplicate entries whereas stats dc() counts unique values and does nothing to duplicates. The query below will only work with mvdedup because the stats command would not work in the same context.

index=main 
| stats list(src.port), list(dst.port) count(src.ip) as COUNT by id 
| eval dst.port = if(mvcount(dst.port) = COUNT, mvdedup(dst.port), dst.port)
---
If this reply helps you, Karma would be appreciated.

bosseres
Contributor

Thank you very much for your respond!

And what if I want to apply function mvdedup to multivalue field ONLY if there are all values of dst.port are the same? Example:

1) dst.port 80 80 80 80 and COUNT 4 - mvdedup

2) dst.port 80 80 80 70 and COUNT 4 - no mvdedup

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
index=main 
| stats list(src.port), list(dst.port) as list_dst values(dst.port) as values_dst count(src.ip) as COUNT by id
| eval list_dst=if(mvcount(values_dst)=1,values_dst,list_dst)
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...