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!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...