Splunk Search

How do I go about merging two result values and renaming them?

leninkp3005
Explorer

Hi Folks,

I want to merge two result values in a single field, which have the same name and to also rename the result values.

Please anyone help me out.

for Merging ex:-
NAS Type: Count
======== =====
Ethernet\ 10
Ethernet 10
wireless 20
wireless\ 20

What I need as table:
NAS Type: Count
======== =====
Ethernet 10
wireless 20

For renaming result fields:
Status Count
====== =====
Compliance 10
Unknown 20

What I need as table:
Status Count
====== =====
Compliance 10
Non-Compliance 20

Cheers,
Lenin Kp

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

An easy way to combine two fields is with concatenation and eval. Something like this:

.. | eval "NAS Type: Count" = 'NAS Type:'." ".'Count'
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

An easy way to combine two fields is with concatenation and eval. Something like this:

.. | eval "NAS Type: Count" = 'NAS Type:'." ".'Count'
---
If this reply helps you, Karma would be appreciated.
0 Karma

adonio
Ultra Champion

kindly share the search providing the results you mention so we can better assist you

0 Karma

leninkp3005
Explorer

Hello Adonio,
Apologies for delay response!!
This is not a big query it's very common query.

I used below query:

"" index="cisco" sourcetype="cisco:ise:syslog" NAS_Port_Type!=NULL | timechart count by NAS_Port_Type |sort -_time ""

This query given the result which is written in my question .
NAS Type: Count
======== =====
Ethernet\ 10
Ethernet 10
wireless 20
wireless\ 20

What I need as table:
NAS Type: Count
======== =====
Ethernet 10
wireless 20

Cheers,
Lenin Kp

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@leninkp3005

Can you please try this?

YOUR_SEARCH | rex mode=sed field=NAS_Port_Type "s/\\\//g" | dedup NAS_Port_Type

Thanks

0 Karma

leninkp3005
Explorer

Thanks., it works

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...