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!

Monitoring Postgres with OpenTelemetry

Behind every business-critical application, you’ll find databases. These behind-the-scenes stores power ...

Mastering Synthetic Browser Testing: Pro Tips to Keep Your Web App Running Smoothly

To start, if you're new to synthetic monitoring, I recommend exploring this synthetic monitoring overview. In ...

Splunk Edge Processor | Popular Use Cases to Get Started with Edge Processor

Splunk Edge Processor offers more efficient, flexible data transformation – helping you reduce noise, control ...