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!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...