Splunk Search

replace special character "*" with NULL in datamodel

goyals05
Explorer

Hi,

In one of my numeric field sometimes I am getting value as " * ". I want to replace it with either NA or NULL if its " * ".

I am looking to add this regex in data model.

0 Karma
1 Solution

mayurr98
Super Champion

hey @goyals05

you can try this run anywhere search

| makeresults 
| eval raw="* 20 30 04 3 2 5 *" 
| makemv raw 
| mvexpand raw 
| rex field=raw mode=sed "s/\*/NA/g"

OR

| makeresults 
| eval raw="* 20 30 04 3 2 5 *" 
| makemv raw 
| mvexpand raw 
| eval raw1=case(raw="*","NA",1=1,raw)

Also in your environment, you should write in eval expression of data model

case(raw="*","NA",1=1,raw)

you can try anyone of these. which one you like bro? 🙂
let me know if this helps!

View solution in original post

mayurr98
Super Champion

hey @goyals05

you can try this run anywhere search

| makeresults 
| eval raw="* 20 30 04 3 2 5 *" 
| makemv raw 
| mvexpand raw 
| rex field=raw mode=sed "s/\*/NA/g"

OR

| makeresults 
| eval raw="* 20 30 04 3 2 5 *" 
| makemv raw 
| mvexpand raw 
| eval raw1=case(raw="*","NA",1=1,raw)

Also in your environment, you should write in eval expression of data model

case(raw="*","NA",1=1,raw)

you can try anyone of these. which one you like bro? 🙂
let me know if this helps!

goyals05
Explorer

Not sure if 1st one can be used in data model. But 2nd option worked for me. Cheers!!

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...