Splunk Search

How to extract from multivalue field result

Noob_splunker
Explorer

Hi,

Below is the result from my transaction command. How do I extract only one date from the  multiple dates below?
I only need the first one which is 2020-07-05 22:02:01.
 
 
2020-07-05 22:02:01
2020-07-05 22:02:36
2020-07-05 22:02:58
2020-07-06 03:02:41
 

extract.PNG

 

I tried mvindex and split but it doesnt give me a result.

 

Thanks,

Labels (1)
Tags (1)
0 Karma
1 Solution

renjith_nair
SplunkTrust
SplunkTrust

@Noob_splunker,

It looks like your field name is the culprit.

Try renaming the field it to start with a letter.

| rename 4G_OutageStart as FG_OutageStart
| eval firstValue=mvindex(FG_OutageStart,0)

 

Happy Splunking!

View solution in original post

renjith_nair
SplunkTrust
SplunkTrust

@Noob_splunker,

It looks like your field name is the culprit.

Try renaming the field it to start with a letter.

| rename 4G_OutageStart as FG_OutageStart
| eval firstValue=mvindex(FG_OutageStart,0)

 

Happy Splunking!

Noob_splunker
Explorer

yup it worked after i renamed it! thanks much!

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Surrounding fields with single quotes ' will ensure eval command works with field names that start with numbers or have spaces in, as in my example

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

Yes sure

Happy Splunking!
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Split and mvindex should work, try this

| makeresults
| eval 4G_OutageStart="2020-07-05 22:02:01,2020-07-05 22:02:36,2020-07-05 22:02:58,2020-07-06 03:02:41"
| eval 4G_OutageStart=split('4G_OutageStart',",")
| eval DataPoints=mvcount('4G_OutageStart')
| eval FirstDateTime=mvindex('4G_OutageStart',0,0)

If things are not working, it may be that your data looks like an MV field, but is not. You can check with the mvcount eval statement I included above.  

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...