Getting Data In

spath error parsing data

Marco_Andreis
New Member

Hi ,
I have this issue when try to parse with json. For example i evaluate a field (for example) a_configuration :
index="xxx" a_appl_id=YYY |
| eval a_configuration="[[\"A1\",\"A2\"],[\"B1\",\"B2\"],[\"C1\",\"C2\"],[\"D1\",\"D2\"],[\"E1\",\"E2\"],[\"F1\",\"F2\"],[\"G1\",\"G2\"]]"
| eval a_FieldX1=spath(a_configuration,"{0}{1}")
| eval a_FieldX2=spath(a_configuration,"{1}{1}")
| eval a_FieldX3=spath(a_configuration,"{2}{1}")
| eval a_FieldX4=spath(a_configuration,"{3}{1}")
| eval a_FieldX5=spath(a_configuration,"{4}{1}")
| eval a_FieldX6=spath(a_configuration,"{5}{1}")
| eval a_FieldX7=spath(a_configuration,"{6}{1}")
| table a_configuration a_FieldX1 a_FieldX2 a_FieldX3 a_FieldX4 a_FieldX5 a_FieldX6 a_FieldX7
the result expected is :
alt text
but the result is :
alt text
Can anyone teach me why ?
Thanks to all ...

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Marco.Andreis@unicredit.eu

Can you please try this?

| makeresults 
| eval a_configuration="[[\"A1\",\"A2\"],[\"B1\",\"B2\"],[\"C1\",\"C2\"],[\"D1\",\"D2\"],[\"E1\",\"E2\"],[\"F1\",\"F2\"],[\"G1\",\"G2\"]]"
| eval a_FieldX1=mvindex(spath(a_configuration,"{0}{}"),0)
| eval a_FieldX2=mvindex(spath(a_configuration,"{1}{}"),0)
| eval a_FieldX3=mvindex(spath(a_configuration,"{2}{}"),0)
| eval a_FieldX4=mvindex(spath(a_configuration,"{3}{}"),0)
| eval a_FieldX5=mvindex(spath(a_configuration,"{4}{}"),0)
| eval a_FieldX6=mvindex(spath(a_configuration,"{5}{}"),0)
| eval a_FieldX7=mvindex(spath(a_configuration,"{6}{}"),0)
| table a_configuration a_FieldX1 a_FieldX2 a_FieldX3 a_FieldX4 a_FieldX5 a_FieldX6 a_FieldX7
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Marco.Andreis@unicredit.eu

I'm also surprised about that. It should work. Well' I think your issue is resolved. So can you please accept this answer to close this question?

0 Karma

Marco_Andreis
New Member

Thanks . With your syntax the result is what I'm expect. I haven't understand why in same fields are loaded more than one value , but yor command fix this issue.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...