Splunk Search

Splunk query to skip alphanumeric string

Deprasad
Path Finder

I've below 3 different types of API logs where I've to treat all 3 as same and get the count of the API.

There are multiple versions of same API along with or without user guid which is a unique value.

Looing for a regex which reads the API until the alphanumeric string starts. In short , if I do stats count by API it should give the count as 3.

 

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

https://regex101.com/r/vFdbh7/1

| rex "\"address\":\"(?<api>[\w\/:]+?)(?=([a-z0-9]+\-[a-z0-9-]+)|$)"
0 Karma

Deprasad
Path Finder

Thanks a lot! This regex works for the given example. 

I've another pattern like this "address":"http://test-query-service.xxx-xxx.xxx.xxx.com/services/user/v1/deleteUser/342ad-123m4-r43rm-144dgdg" for which I'm trying to implement the regex you've given by modifying slightly but couldn't achieve the same result.

Can you please help here? Also can you please break down the regex for my better understanding.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

How much of this is real? For example, do you really have hyphens in the host name of the address? Are they the only place where hyphens occur apart from the end part?

Are there any other representative examples you wish to be considered?

0 Karma

Deprasad
Path Finder

Yes, I've hyphens and a full stop on the hostname that needs to be considered. 

So far identified those 4 patterns and that should be it.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Deprasad,

please try this regex:

| rex "\"address\":\"(?<uri>https*:\/\/[^\/]+\/[^\/]+\/[^\/]+)"

that you can test at https://regex101.com/r/Umz02I/1

if you already extracted the full APP value (and it's called "api_url "), you can use a different regex

| rex field=api_url "(?<uri>https*:\/\/[^\/]+\/[^\/]+\/[^\/]+)"

 Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...