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!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

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

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...