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

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!

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...