Splunk Search

Regex

nathanluke86
Communicator

Hi,

I am trying to find unique id's the have 3 letters followed by 6 numbers for example

 

bhg111111

 

My issue is I want to not count duplicates and would like to do this within the regex itself (not dedup by field.

 

is this possible

 

thanks,

Labels (1)
0 Karma

493669
Super Champion

Hi @nathanluke86 

You can use Stats like below-

...|stats count by fieldname

 Here It will give Unique values of fieldname with count and If count is not required you can remove it using 

|fields - count

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So still not completely within the rex (which I am not sure you could do anyway) and based @493669 suggestion

--- your search
| rex field=yourfield max_match=0 "(?<id>[a-zA-Z]{3}\d{6})"
| stats count by id
| fields - count
0 Karma

nathanluke86
Communicator

hi @ITWhisperer 

yes thats exactly what I am trying to achieve,

Kind regards,

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Hi @nathanluke86 

Why do you not want to use dedup, it does what you need to do a lot easier than trying to write some complicated alternative?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Just to clarify, your field could contain multiple occurrences of this pattern and you want to count the unique occurrences but you don't want to use dedup?

bhg111111 bhg111111 bhg222222 is two matches?

0 Karma
Get Updates on the Splunk Community!

Splunk Platform | Upgrading your Splunk Deployment to Python 3.9

Splunk initially announced the removal of Python 2 during the release of Splunk Enterprise 8.0.0, aiming to ...

From Product Design to User Insights: Boosting App Developer Identity on Splunkbase

co-authored by Yiyun Zhu & Dan Hosaka Engaging with the Community at .conf24 At .conf24, we revitalized the ...

Detect and Resolve Issues in a Kubernetes Environment

We’ve gone through common problems one can encounter in a Kubernetes environment, their impacts, and the ...