<?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 Help! Best Practices for Handling fields in Business Event Processing in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Help-Best-Practices-for-Handling-fields-in-Business-Event/m-p/265161#M1533</link>
    <description>&lt;P&gt;Hello Community! I’m trying to create processing rules for fields corresponding to already configured business events. Specifically, I am extracting a field with the structure "[{},{},{},{},{},{},{},{},{}]", which I can’t process to get the last array/object. In the file, you can see the structure that is obtained daily. The data is collected minute by minute, with a new object being added, ending in 319 with a daily cycle, but this doesn’t affect the result.&lt;/P&gt;
&lt;P&gt;So far, I have implemented a rather rudimentary solution where I remove the brackets and read it as JSON. But the result is not as expected, although it's close.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch bizevents
| filter event.provider == "VORTEX Nginx"
| fieldsAdd Array1=replaceString(res.body.result, "[", "")
| fieldsAdd result=replaceString(Array1, "]", "")
| parse result, "JSON:json"
| fieldsFlatten json
| fields json.time&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="afuentes_0-1734037979129.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25207i92051CB22D741D52/image-size/medium?v=v2&amp;amp;px=400" role="button" title="afuentes_0-1734037979129.png" alt="afuentes_0-1734037979129.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;In the previous query, I get the first value from all the objects. How can I process the field to extract only the last array/object?&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="afuentes_1-1734038441567.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25208iF48F1BD63D597338/image-size/medium?v=v2&amp;amp;px=400" role="button" title="afuentes_1-1734038441567.png" alt="afuentes_1-1734038441567.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;I sincerely appreciate any help you can provide!&lt;/FONT&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2024 08:01:54 GMT</pubDate>
    <dc:creator>tracegazer</dc:creator>
    <dc:date>2024-12-13T08:01:54Z</dc:date>
    <item>
      <title>Help! Best Practices for Handling fields in Business Event Processing</title>
      <link>https://community.dynatrace.com/t5/DQL/Help-Best-Practices-for-Handling-fields-in-Business-Event/m-p/265161#M1533</link>
      <description>&lt;P&gt;Hello Community! I’m trying to create processing rules for fields corresponding to already configured business events. Specifically, I am extracting a field with the structure "[{},{},{},{},{},{},{},{},{}]", which I can’t process to get the last array/object. In the file, you can see the structure that is obtained daily. The data is collected minute by minute, with a new object being added, ending in 319 with a daily cycle, but this doesn’t affect the result.&lt;/P&gt;
&lt;P&gt;So far, I have implemented a rather rudimentary solution where I remove the brackets and read it as JSON. But the result is not as expected, although it's close.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch bizevents
| filter event.provider == "VORTEX Nginx"
| fieldsAdd Array1=replaceString(res.body.result, "[", "")
| fieldsAdd result=replaceString(Array1, "]", "")
| parse result, "JSON:json"
| fieldsFlatten json
| fields json.time&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="afuentes_0-1734037979129.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25207i92051CB22D741D52/image-size/medium?v=v2&amp;amp;px=400" role="button" title="afuentes_0-1734037979129.png" alt="afuentes_0-1734037979129.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;In the previous query, I get the first value from all the objects. How can I process the field to extract only the last array/object?&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="afuentes_1-1734038441567.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25208iF48F1BD63D597338/image-size/medium?v=v2&amp;amp;px=400" role="button" title="afuentes_1-1734038441567.png" alt="afuentes_1-1734038441567.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;I sincerely appreciate any help you can provide!&lt;/FONT&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 08:01:54 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Help-Best-Practices-for-Handling-fields-in-Business-Event/m-p/265161#M1533</guid>
      <dc:creator>tracegazer</dc:creator>
      <dc:date>2024-12-13T08:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help! Best Practices for Handling fields in Business Event Processing</title>
      <link>https://community.dynatrace.com/t5/DQL/Help-Best-Practices-for-Handling-fields-in-Business-Event/m-p/265308#M1537</link>
      <description>&lt;P&gt;The object in the text file is an JSON array. There is a &lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-pattern-language/log-processing-json-array" target="_self"&gt;JSON_ARRAY matcher&lt;/A&gt; for that in DPL that can be used without additional processing. If you want to extract ONLY the last element, you can use the following DQL query:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch bizevents
| filter event.provider == "VORTEX Nginx"
| parse content, """JSON_ARRAY:parsed_json_elements"""
| fields last_element = arrayLast(parsed_json_elements)
&lt;/LI-CODE&gt;
&lt;P&gt;If you would like to use the JSON elements as separate fields, you can add the fieldsFlatten command to the end of the query, as follows:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch bizevents
| filter event.provider == "VORTEX Nginx"
| parse content, """JSON_ARRAY:parsed_json_elements"""
| fields last_element = arrayLast(parsed_json_elements)
| fieldsFlatten last_element&lt;/LI-CODE&gt;
&lt;P&gt;I created a demo for this in the Security Investigator at our Playgorund: &lt;A href="https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/3262363c-d7a6-429a-b55d-a25dc5e1a9f0" target="_blank"&gt;https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/3262363c-d7a6-429a-b55d-a25dc5e1a9f0&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2024 21:32:22 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Help-Best-Practices-for-Handling-fields-in-Business-Event/m-p/265308#M1537</guid>
      <dc:creator>Tiit_Hallas</dc:creator>
      <dc:date>2024-12-15T21:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help! Best Practices for Handling fields in Business Event Processing</title>
      <link>https://community.dynatrace.com/t5/DQL/Help-Best-Practices-for-Handling-fields-in-Business-Event/m-p/265694#M1544</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Thanks to your comment&lt;/STRONG&gt;, I was able to obtain the required information. I wasn’t aware of the use of JSON_ARRAY, but I’ve saved it for future cases.&lt;/P&gt;&lt;P&gt;That said, is it possible to transform the DQL query into a processing definition?&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;PARSE(res.body.result, "JSON_ARRAY:jsonElement")&lt;BR /&gt;| FIELDS_ADD(lastElement:ARRAY_LAST(jsonElement))&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="afuentes_0-1734538709828.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/25328i492A16B8071B39D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="afuentes_0-1734538709828.png" alt="afuentes_0-1734538709828.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 16:17:38 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Help-Best-Practices-for-Handling-fields-in-Business-Event/m-p/265694#M1544</guid>
      <dc:creator>tracegazer</dc:creator>
      <dc:date>2024-12-18T16:17:38Z</dc:date>
    </item>
  </channel>
</rss>

