<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: JSON Field Extraction names with curly brackets in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366467#M108102</link>
    <description>&lt;P&gt;Thanks @DalJeanis.&lt;/P&gt;

&lt;P&gt;I tried, but it doesn't give any results, and even if it worked, given the case of a more complex JSON structure the amount of different names for the same node will be more than 4, whats makes this approach not appropiate for this situation.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2017 12:42:10 GMT</pubDate>
    <dc:creator>dmonsag</dc:creator>
    <dc:date>2017-10-06T12:42:10Z</dc:date>
    <item>
      <title>JSON Field Extraction names with curly brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366464#M108099</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;
I'm currently searching over a collection of events that contains some JSON structure, when applying SPATH over the field contaning the JSON, the resulting fields for a specific node of the JSON structure may vary according to the arrays on the message. I need to do some aritmetic operations over this particular node in order to sum all the values from all the events. These are the resulting fields when using SPATH:&lt;BR /&gt;
agreementsGroup.agreements.agreementParticipants.proportionalClaimAmount&lt;BR /&gt;
agreementsGroup.agreements.agreementParticipants{}.proportionalClaimAmount&lt;BR /&gt;
agreementsGroup.agreements{}.agreementParticipants{}.proportionalClaimAmount&lt;BR /&gt;
agreementsGroup{}.agreements.agreementParticipants{}.proportionalClaimAmount&lt;/P&gt;

&lt;P&gt;As you can see they all have different names but refer to the same data I need to sum. Here is an example of my search and the respective result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="idx_cuadre_core_gw" sourcetype="rbt_cuadre_gw_src_type" | spath input=msg_body | stats sum("agreementsGroup.agreements.agreementParticipants{}.proportionalClaimAmount") by "referenceIdSAP" "policy.currencyCode" | rename "referenceIdSAP" as ID_SAP "policy.currencyCode" as MONEDA sum("agreementsGroup.agreements.agreementParticipants{}.proportionalClaimAmount") as CLAIM_AMOUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3580iC44B96578147DE0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How can I treat these "different" named fields as one in order to sum and display the table without missing any data?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 20:41:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366464#M108099</guid>
      <dc:creator>dmonsag</dc:creator>
      <dc:date>2017-10-04T20:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Field Extraction names with curly brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366465#M108100</link>
      <description>&lt;P&gt;Have you tried...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval proportionalClaimAmount =coalesce(agreementsGroup.agreements.agreementParticipants.proportionalClaimAmount,
    agreementsGroup.agreements.agreementParticipants{}.proportionalClaimAmount,
    agreementsGroup.agreements{}.agreementParticipants{}.proportionalClaimAmount,
    agreementsGroup{}.agreements.agreementParticipants{}.proportionalClaimAmount)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Oct 2017 20:57:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366465#M108100</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-04T20:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Field Extraction names with curly brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366466#M108101</link>
      <description>&lt;P&gt;Do every event, after spath, contain all 4 field or just one of them? If it's later, @Daljeanis's answer can create a common field name from all those different named field which you can use in your stats.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 21:27:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366466#M108101</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-10-04T21:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Field Extraction names with curly brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366467#M108102</link>
      <description>&lt;P&gt;Thanks @DalJeanis.&lt;/P&gt;

&lt;P&gt;I tried, but it doesn't give any results, and even if it worked, given the case of a more complex JSON structure the amount of different names for the same node will be more than 4, whats makes this approach not appropiate for this situation.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 12:42:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366467#M108102</guid>
      <dc:creator>dmonsag</dc:creator>
      <dc:date>2017-10-06T12:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Field Extraction names with curly brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366468#M108103</link>
      <description>&lt;P&gt;After some tests I finally, use this kind of workaround which allows me to extract the values of all the nodes based on a regular expression. Not the best solution anyway but at least I was able to generate my report. If anybody comes up with a better solution I'll be glad to hear about it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="idx_cuadre_core_gw" sourcetype="rbt_cuadre_gw_src_type" | search "cop" "proportionalClaimAmount" | rex field=_raw max_match=0 "\"proportionalClaimAmount\":\"(?&amp;lt;proportionalClaimAmount&amp;gt;.*?)\"" | stats sum(proportionalClaimAmount)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 12:46:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/JSON-Field-Extraction-names-with-curly-brackets/m-p/366468#M108103</guid>
      <dc:creator>dmonsag</dc:creator>
      <dc:date>2017-10-06T12:46:44Z</dc:date>
    </item>
  </channel>
</rss>

