Splunk Search

Can you give me some help with the coalesce command?

jip31
Motivator

hi,

When I execute the query below

index="x" sourcetype="WinEventLog:Microsoft-Windows-Diagnostics-Performance/Operational"

I can display a field called "OpCode". This field has many values and I want to display one of them.

Sometimes this field is in english, sometimes in French, sometimes in Spanish and sometimes in German.

So I need to use "coalesce" like this

| eval 'Boot_Degradation'=coalesce('Boot_Degradation','Détérioration du démarrage','Información del arranque','Startbeeinträchtigung') 
| table OpCode

but it doesn't work.

could you help me please???

0 Karma
1 Solution

vnravikumar
Champion

Hi @jip31

Try this, it will take first not null value

| makeresults 
   | eval OpCode=coalesce(null(),"Détérioration du démarrage","Información del arranque","Startbeeinträchtigung") | table OpCode

View solution in original post

0 Karma

FrankVl
Ultra Champion

'Boot_Degradation','Détérioration du démarrage','Información del arranque','Startbeeinträchtigung'

Are those your field names? Or your field values? The coalesce command takes field names as parameters, and returns the first non-null field.

0 Karma

nickhills
Ultra Champion

Coalesce is not the command you need here. Try this:

| makeresults 
| eval OpCode="Boot_Degradation,Détérioration du démarrage,Información del arranque,Startbeeinträchtigung"

| makemv delim="," OpCode
| eval OpCode=mvindex(OpCode, 0)

The first two lines make some sample data - hopefully I have interpreted this right?
The last two lines make the field multivalued, and then pick the first (0) value in the mv list and returns that value.

If you wanted french swap the 0 for a 1 etc

You full search would probably be something like this:

index="x" sourcetype="WinEventLog:Microsoft-Windows-Diagnostics-Performance/Operational"| makemv delim="," OpCode
| eval OpCode=mvindex(OpCode, 0)|table OpCode
If my comment helps, please give it a thumbs up!

vnravikumar
Champion

Hi @jip31

Try this, it will take first not null value

| makeresults 
   | eval OpCode=coalesce(null(),"Détérioration du démarrage","Información del arranque","Startbeeinträchtigung") | table OpCode
0 Karma
Get Updates on the Splunk Community!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...