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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...