Splunk Search

How to add values from a split to an existing field?

fatanyk
Explorer

Hello, i'm trying to add values to an existing field but i'm running into a wall.

I have a field name vector and another field name source, the pattern of the source field is XXX - YYY - ZZZ,

i only want to keep the XXX part, so i've done

 

 

| eval temp = mvindex(split(source, " - "),0)

 

 

then i try to add these result to the vector field like this :

 

 

|eval vector = vector + temp

 

 

but it doesn't work.

 

Can you help me ?

Labels (1)
0 Karma
1 Solution

goncalocoelho
Path Finder

If vector doesn't exist, and you are creating it based on source, then try this:

| eval vector = if(isnull(temp), "<null or something else>", temp)

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

goncalocoelho
Path Finder

If vector doesn't exist, and you are creating it based on source, then try this:

| eval vector = if(isnull(temp), "<null or something else>", temp)

 

---
If this reply helps you, Karma would be appreciated.

fatanyk
Explorer

it works thank you !

Actually it looks like this : 

| eval vector= if(isnull(temp),vector,temp)
0 Karma

goncalocoelho
Path Finder

Hi,

Do you know for sure if the source field exists in 100% of the events? Sometimes concatenating fields fails because one of the fields doesn't exist on all events.

Try this:

| eval vector = if(isnull(temp), vector, vector.temp)

 

Also try to concatenate using the "." instead of "+"

| eval vector = vector.temp

 

---
If this reply helps you, Karma would be appreciated.

0 Karma

fatanyk
Explorer

No, the source field does not exist in 100% of the events, in fact I want to create the field "vector" for the events that do not have it with the value XXX.

 

i've try both of your solutions but neither worked.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...