Splunk Search

distinct count of specific words with replacing them with another word

amitkore3483
New Member

Hi,

I have logs coming with server names listed into it and my requirement is to the distinct count of server by assigning region to them.

for example.

entries are like 

{"server":"abc.uk" "details": xxxx"}

{"server":"abc.uk" "details": yyyy"}

{"server":"xyz.uk" "details": xxxx"}

{"server":"abc.us" "details": xxxx"}

{"server":"xyz.us" "details": xxxx"}

{"server":"xyz.us" "details": yyyy"}

{"server":"abc.hk" "details": xxxx"}

 

so now from the above list we have 2 unique servers from UK, 2 unique servers from US and 1 from HK, so i need them to be show as per below.

North America : 2

Europe : 2

Asia : 1

i have tried search as <count(eval(searchmatch("*.us*")))> AS North America but this will not give me the count of unique server

Labels (2)
0 Karma

amitkore3483
New Member

will try this.. thanks

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @amitkore3483,

please try something like this:

<your_search>
| rex field=ppp "server\":\"\w+\.(?<nation>[^\"]+)\"\s\"details\":\s(?<details>[^\"]+)"
| stats count By nation details

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...