Splunk Search

How can I add quotes and comma to a multivalued field?

Woodpecker
Path Finder

HI,

I have a multivalued field with values as
A
B
C
I want it to be replaced as 'A','B','C' . I tried to do it with eval mvjoin, but the first and last values misses the quote like this
A','B','C

SPL used is: 

 

index=* sourcetype=* host=abc NAME IN ("*A*","*B*","*C*") |stats values(NAME) as NAME by host
| eval NAME = mvjoin(NAME,"','")

 

Any help would be appreciated, thankyou

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eval NAME="'".mvjoin(NAME,"','")."'"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| eval NAME="'".mvjoin(NAME,"','")."'"

Woodpecker
Path Finder

This works! thankyou

0 Karma

StefanoA
Explorer

You're almost there

Modify the last eval with

| eval NAME = "'".mvjoin(NAME,"','")."'"
0 Karma

Woodpecker
Path Finder

Hi,

Is it possible to get values like this: (ie., double quotes instead of single quotes)

"A","B","C"

0 Karma

Woodpecker
Path Finder

This works for me

| eval NAME = "\"".mvjoin(NAME,"\",\"")."\""
0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...