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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...