Splunk Search

Case sensitivity of name, in name=value pairs

NK_1
Path Finder

I would like to do a "stats distinct_count(accountID)"

However, some code modules log "accountID=xxxx", while others log "AccountID=xxxx"

Is there a way to get a distinct count of Account IDs without having to change the code that does the logging?

1 Solution

southeringtonp
Motivator

As long as only one or the other is present, use coalesce:

| eval accountID=coalesce(accountID, AccountID)
| stats dc(accountID)

Another possibility would be to use rex. If, for example IDs are numeric:

| rex field=_raw "(?i)AccountID=(?<accountID>\d+)"

The rex approach is better if you need to deal with the possibility of multiple matches in one event.

View solution in original post

southeringtonp
Motivator

As long as only one or the other is present, use coalesce:

| eval accountID=coalesce(accountID, AccountID)
| stats dc(accountID)

Another possibility would be to use rex. If, for example IDs are numeric:

| rex field=_raw "(?i)AccountID=(?<accountID>\d+)"

The rex approach is better if you need to deal with the possibility of multiple matches in one event.

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...