Getting Data In

I created a field that has 3 values. How can I change one of the values from WARNING to WARN using lookups?

krishnani
New Member

I created a field and it has 3 values. I just want change one of the values from WARNING to WARN using lookups(.CSV). I also want to know how to configure it in props.conf.

0 Karma
1 Solution

somesoni2
Revered Legend

Try this as your props.conf entry for field extraction

[yoursourcetype]
EXTRACT-logvalue=^=(?<logLevel>(WARN|\w+))

Working example (run anywhere search) to validate regex

| gentimes start=-1 | eval temp="=WARNING =ERROR =INFO =FATAL =SOMETHINGELSE" | table temp | makemv temp | mvexpand temp | rename temp as _raw | rex "^=(?<logLevel>(WARN|\w+))"

View solution in original post

0 Karma

somesoni2
Revered Legend

Try this as your props.conf entry for field extraction

[yoursourcetype]
EXTRACT-logvalue=^=(?<logLevel>(WARN|\w+))

Working example (run anywhere search) to validate regex

| gentimes start=-1 | eval temp="=WARNING =ERROR =INFO =FATAL =SOMETHINGELSE" | table temp | makemv temp | mvexpand temp | rename temp as _raw | rex "^=(?<logLevel>(WARN|\w+))"
0 Karma

krishnani
New Member

I updated the my extracted field and values in props.conf like this

- EXTRACT-logvalue=^=(?(INFO|ERROR|WARN))
- it's working fine now but in the above config I hardcoded my values but I want to hardcode only WARN as in future we're expecting more values will come under same sourcetype. if a new value come in to the same sourcetype I need to hard code every value in props.conf.

So I would like to update my regex will update only from "WARNING" to "WARN" and rest other values (INFO,ERROR etc) need to add automatically to "logvalue" field without hardcoding.

Any suggestions on regex?

0 Karma

krishnani
New Member

sorry there is typo in config. here is the correct one

EXTRACT-logvalue=^=(?logvalue(INFO|ERROR|WARN))

0 Karma

gcusello
SplunkTrust
SplunkTrust

You can also modify it in your searches at search_time:
| eval yourfield=if(yourfield="WARNING","WARN",yourfield)
in this way tou maintain logs as originals and show them as you want
Bye.
Giuseppe

0 Karma

sundareshr
Legend

If you want to make the change before indexing, you could try sed to replace text. Something like this in your props should work

SEDCMD-warn = s/(WARNING)/WARN/g

PS: This will only affect new data coming in.

0 Karma

somesoni2
Revered Legend

You want to change the value of an extracted field? Why you want to use lookup if you know which value to be replaced with which? You can achieve that using a simple eval/replace command. Further, same can be saved in props.conf on SH to make it happen automatically for your data.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...