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
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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...