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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...