Splunk Search

help on eval like condition

jip31
Motivator

hello

In my search I use an eval command like below in order to identify character string in web url

| eval Kheo=case(
    like(url,"%SLG%"),"G",
    like(url,"%SLK%"),"G",
    like(url,"%SLY%"),"I",
    like(url,"%SK%"),"T",
    like(url,"%SL%"),"E"
    ) 
| search Kheo=*

The problem I have is that my eval identify every url which conatains for example "SLG" letters in lowercase or uppercse

My need is to strictly identify URL which contains "SLG" letters in uppercase

I tried with match but it changes nothing

| eval Kheo=case(
    match(url,"SLG"),"G",

 could you help please?

Labels (1)
Tags (1)
0 Karma
1 Solution

VatsalJagani
SplunkTrust
SplunkTrust

@jip31 - Try this instead:

| eval Kheo=case(
    match(url,"SLG"),"G",
    match(url,"SLK"),"G",
    match(url,"SLY"),"I",
    match(url,"SK"),"T",
    match(url,"SL"),"E"
    ) 

 

-------
I hope this helps!!! Kindly upvote if it does!!!

View solution in original post

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@jip31 - Try this instead:

| eval Kheo=case(
    match(url,"SLG"),"G",
    match(url,"SLK"),"G",
    match(url,"SLY"),"I",
    match(url,"SK"),"T",
    match(url,"SL"),"E"
    ) 

 

-------
I hope this helps!!! Kindly upvote if it does!!!

0 Karma

jip31
Motivator

thanks

0 Karma

jip31
Motivator

I dont say its not working but it doesnt work exactly like i need

For exemple, if i am looking for 

eval Kheo=case(
    like(url,"%SLG%"),"G",

I dont want to display URL with lowercase like "slg" but just with uppercase like "SLG"

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you provide some examples of where this is not working?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you provide some examples of where this is not working?

This runanywhere example shows it working

| makeresults
| eval url=split("abSLGcd,abslgcd,ab/SLG/cd,ab/slg/cd",",")
| mvexpand url
| eval kheo=case(like(url,"%SLG%"),"G")
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...