<?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: Log processing rule - for each item in json array split on &amp;quot;:&amp;quot; then create fields using split[0] as key and split[1] in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/231486#M416</link>
    <description>&lt;P&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/6323"&gt;@peter_zahrer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm currently facing similar issue with dynamic key value pairs. The Log Processor Rule can parse the data using KVP parsing and store the data into an array. However, I want to extract those key:value into fields (key) so they can be used in DQL search or data explorer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the "fieldsFlatten" command is not supported in the Log processor definition (i.e. DPL). It works in Notebook DLP Architect, but not in the rule definition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any other solution available?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mosharref_hossn_0-1702308848127.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/16117i731FE545C48D57E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mosharref_hossn_0-1702308848127.png" alt="mosharref_hossn_0-1702308848127.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2023 15:34:49 GMT</pubDate>
    <dc:creator>mosharref_hossn</dc:creator>
    <dc:date>2023-12-11T15:34:49Z</dc:date>
    <item>
      <title>Log processing rule - for each item in json array split on ":" then create fields using split[0] as key and split[1] as value</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220181#M188</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I'm having a bit of trouble extracting data from a json array. Would you be able to assist me?&lt;BR /&gt;&lt;BR /&gt;for example&lt;/P&gt;&lt;P&gt;content={&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;"some_array" : [&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "key1:value1",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "key2:value2"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Is there a way for me to process each item in content.some_array, split on ":" and then create fields with the first item of the split being the field name/key and the second item being the field value?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 17:02:52 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220181#M188</guid>
      <dc:creator>Jack_Stuart</dc:creator>
      <dc:date>2023-08-08T17:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing rule - for each item in json array split on ":" then create fields using split[0] as key and split[1]</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220200#M189</link>
      <description>&lt;P&gt;Hey Jack,&lt;/P&gt;
&lt;P&gt;Is this what you were looking for?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Fin_Ubels_0-1691543186628.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/13475iEA202064BA8D27D3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Fin_Ubels_0-1691543186628.png" alt="Fin_Ubels_0-1691543186628.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data json:"""{"some_array":["key1:value1", "key2:value2"]}"""
| expand some_array
| fields some_array = splitString(some_array, ":")&lt;/LI-CODE&gt;
&lt;P&gt;Or were you looking for each record replacing "some_array" with "key1", "key2" etc and then each value being "value1", "value2" etc?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 01:08:24 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220200#M189</guid>
      <dc:creator>Fin_Ubels</dc:creator>
      <dc:date>2023-08-09T01:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing rule - for each item in json array split on ":" then create fields using split[0] as key and split[1]</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220257#M190</link>
      <description>&lt;P&gt;Hi Fin,&lt;BR /&gt;&lt;BR /&gt;That's really helpful and it is on the way to what I'm trying to do. I've included an real example below followed by a view of what I'm trying to achieve. The expand has allowed me access to the array elements but assigning them as fields after the split is proving difficult, and I'm not sure how I'd reverse the expand back into a single row&lt;BR /&gt;&lt;BR /&gt;Example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;data json:"""{"log.source": "thousandeyes-123456","level": "ALERT","dt.source_entity": "CUSTOM_DEVICE-B6DDABA85A5054AF","dt.source_entity_type": "CUSTOM_DEVICE","id": 859508901,"type": 2,"alert_state": 2,"alert_id": "some-alert-id","alert_rule_alertType.id": "WebTransaction","alert_severity": "INFO","alert_url": "app.thousandeyes.com/alerts/list/?__a=some-alert-id","alert_description": "*Alert ID*: some-alert-id\n*Test Name*: Dynatrace Heartbeat - dynatraceheartbeatevent.com\n*Target/s*: dynatraceheartbeatevent.com\n*Alert Rule*: Dynatrace-HEARTBEAT - Error is present\n*Details*: 2\n*Link*: app.thousandeyes.com/alerts/list/?__a=225896&amp;amp;alertId=some-alert-id","alert_test_name": "Dynatrace Heartbeat - dynatraceheartbeatevent.com","alert_test_labels": ["CMDB_APPID:AL08672","Location:Turkey","City:Istanbul"]}"""
| filter matchesValue(dt.source_entity, "CUSTOM_DEVICE-B6DDABA85A5054AF") AND matchesValue(log.source, "thousandeyes-123456")
| expand alert_test_labels
| fieldsAdd label=splitString(alert_test_labels, ":") // CMDB_APPID:AL012345
| fieldsAdd labelKey=arrayFirst(label)
| fieldsAdd labelValue=arrayLast(label)&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jack_Stuart_1-1691573910685.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/13491i1207D45B6A98949B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jack_Stuart_1-1691573910685.png" alt="Jack_Stuart_1-1691573910685.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;View of what I'm trying to achieve:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;data json:"""{"log.source": "thousandeyes-123456","level": "ALERT","dt.source_entity": "CUSTOM_DEVICE-B6DDABA85A5054AF","dt.source_entity_type": "CUSTOM_DEVICE","id": 859508901,"type": 2,"alert_state": 2,"alert_id": "some-alert-id","alert_rule_alertType.id": "WebTransaction","alert_severity": "INFO","alert_url": "app.thousandeyes.com/alerts/list/?__a=some-alert-id","alert_description": "*Alert ID*: some-alert-id\n*Test Name*: Dynatrace Heartbeat - dynatraceheartbeatevent.com\n*Target/s*: dynatraceheartbeatevent.com\n*Alert Rule*: Dynatrace-HEARTBEAT - Error is present\n*Details*: 2\n*Link*: app.thousandeyes.com/alerts/list/?__a=225896&amp;amp;alertId=some-alert-id","alert_test_name": "Dynatrace Heartbeat - dynatraceheartbeatevent.com","alert_test_labels": ["CMDB_APPID:AL08672","Location:Turkey","City:Istanbul"]}"""
| filter matchesValue(dt.source_entity, "CUSTOM_DEVICE-B6DDABA85A5054AF") AND matchesValue(log.source, "thousandeyes-123456")
| fieldsAdd CMDB_APPID="AL08672"
| fieldsAdd Location="Turkey"
| fieldsAdd City="Istanbul"&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jack_Stuart_0-1691573725013.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/13490i21735C2AD900B28C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jack_Stuart_0-1691573725013.png" alt="Jack_Stuart_0-1691573725013.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 09:39:16 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220257#M190</guid>
      <dc:creator>Jack_Stuart</dc:creator>
      <dc:date>2023-08-09T09:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing rule - for each item in json array split on ":" then create fields using split[0] as key and split[1]</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220337#M191</link>
      <description>&lt;P&gt;Hey Jack,&lt;/P&gt;
&lt;P&gt;Unfortunately I haven't been able to figure it out, I'm not sure how we can do that unless the number and order of "alert_test_labels" are fixed in which case we could do:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| fieldsAdd CMDB_APPID=arrayLast(splitString(alert_test_labels[0], ":"))
| fieldsAdd Location=arrayLast(splitString(alert_test_labels[1], ":"))
| fieldsAdd City=arrayLast(splitString(alert_test_labels[2], ":"))
| fieldsRemove alert_test_labels&lt;/LI-CODE&gt;
&lt;P&gt;Thats a very static solution but I'm not sure how else we could do this sorry.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 22:06:00 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220337#M191</guid>
      <dc:creator>Fin_Ubels</dc:creator>
      <dc:date>2023-08-09T22:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing rule - for each item in json array split on ":" then create fields using split[0] as key and split[1]</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220359#M192</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/15202"&gt;@Jack_Stuart&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest that you convert the array to string and use DPL to parse the fields.&lt;/P&gt;
&lt;P&gt;You can do this in a more declarative way:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data json:"""{"log.source": "thousandeyes-123456","level": "ALERT","dt.source_entity": "CUSTOM_DEVICE-B6DDABA85A5054AF","dt.source_entity_type": "CUSTOM_DEVICE","id": 859508901,"type": 2,"alert_state": 2,"alert_id": "some-alert-id","alert_rule_alertType.id": "WebTransaction","alert_severity": "INFO","alert_url": "app.thousandeyes.com/alerts/list/?__a=some-alert-id","alert_description": "*Alert ID*: some-alert-id\n*Test Name*: Dynatrace Heartbeat - dynatraceheartbeatevent.com\n*Target/s*: dynatraceheartbeatevent.com\n*Alert Rule*: Dynatrace-HEARTBEAT - Error is present\n*Details*: 2\n*Link*: app.thousandeyes.com/alerts/list/?__a=225896&amp;amp;alertId=some-alert-id","alert_test_name": "Dynatrace Heartbeat - dynatraceheartbeatevent.com","alert_test_labels": ["CMDB_APPID:AL08672","Location:Turkey","City:Istanbul"]}"""
| filter matchesValue(dt.source_entity, "CUSTOM_DEVICE-B6DDABA85A5054AF") AND matchesValue(log.source, "thousandeyes-123456")
| fieldsAdd helper = toString(alert_test_labels)
| parse helper, """LD 'CMDB_APPID:' LD:CMDB_APPID '"' """
| parse helper, """ LD 'Location:' LD:Location '"' """
| parse helper, """ LD 'City:' LD:City '"' """
| parse helper, """'[' KVP{'"' LD:key ':' LD:value '"' (', '|']')}:kvp"""
| fieldsRemove helper&lt;/LI-CODE&gt;
&lt;P&gt;or parsing with using &lt;A href="https://www.dynatrace.com/support/help/platform/grail/dynatrace-pattern-language/log-processing-key-value-pairs" target="_blank"&gt;KVP&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data json:"""{"log.source": "thousandeyes-123456","level": "ALERT","dt.source_entity": "CUSTOM_DEVICE-B6DDABA85A5054AF","dt.source_entity_type": "CUSTOM_DEVICE","id": 859508901,"type": 2,"alert_state": 2,"alert_id": "some-alert-id","alert_rule_alertType.id": "WebTransaction","alert_severity": "INFO","alert_url": "app.thousandeyes.com/alerts/list/?__a=some-alert-id","alert_description": "*Alert ID*: some-alert-id\n*Test Name*: Dynatrace Heartbeat - dynatraceheartbeatevent.com\n*Target/s*: dynatraceheartbeatevent.com\n*Alert Rule*: Dynatrace-HEARTBEAT - Error is present\n*Details*: 2\n*Link*: app.thousandeyes.com/alerts/list/?__a=225896&amp;amp;alertId=some-alert-id","alert_test_name": "Dynatrace Heartbeat - dynatraceheartbeatevent.com","alert_test_labels": ["CMDB_APPID:AL08672","Location:Turkey","City:Istanbul"]}"""
| filter matchesValue(dt.source_entity, "CUSTOM_DEVICE-B6DDABA85A5054AF") AND matchesValue(log.source, "thousandeyes-123456")
| fieldsAdd helper = toString(alert_test_labels)
| parse helper, """'[' KVP{'"' LD:key ':' LD:value '"' (', '|']')}:kvp"""
| fieldsAdd City = kvp[City], Location = kvp[Location], CMDB_APPID = kvp[CMDB_APPID]
| fieldsRemove helper&lt;/LI-CODE&gt;
&lt;P&gt;Best,&lt;BR /&gt;Sini&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 08:14:45 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220359#M192</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-08-10T08:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing rule - for each item in json array split on ":" then create fields using split[0] as key and split[1]</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220584#M199</link>
      <description>&lt;P&gt;Thanks for you help but to get around my problem I have decided to forward the data as events and trigger a workflow to process the JSON using a type script step. The problem is that the label values are dynamic so I can't add them as a kvp and access the label value without knowing the key up front&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 12:03:47 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/220584#M199</guid>
      <dc:creator>Jack_Stuart</dc:creator>
      <dc:date>2023-08-14T12:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing rule - for each item in json array split on ":" then create fields using split[0] as key and split[1]</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/227040#M325</link>
      <description>&lt;P&gt;Maybe this presents a way forward using the fieldsFlatten command:&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;data json:"""{"log.source": "thousandeyes-123456","level": "ALERT","dt.source_entity": "CUSTOM_DEVICE-B6DDABA85A5054AF","dt.source_entity_type": "CUSTOM_DEVICE","id": 859508901,"type": 2,"alert_state": 2,"alert_id": "some-alert-id","alert_rule_alertType.id": "WebTransaction","alert_severity": "INFO","alert_url": "app.thousandeyes.com/alerts/list/?__a=some-alert-id","alert_description": "*Alert ID*: some-alert-id\n*Test Name*: Dynatrace Heartbeat - dynatraceheartbeatevent.com\n*Target/s*: dynatraceheartbeatevent.com\n*Alert Rule*: Dynatrace-HEARTBEAT - Error is present\n*Details*: 2\n*Link*: app.thousandeyes.com/alerts/list/?__a=225896&amp;amp;alertId=some-alert-id","alert_test_name": "Dynatrace Heartbeat - dynatraceheartbeatevent.com","alert_test_labels": ["CMDB_APPID:AL08672","Location:Turkey","City:Istanbul"]}"""
| filter matchesValue(dt.source_entity, "CUSTOM_DEVICE-B6DDABA85A5054AF") AND matchesValue(log.source, "thousandeyes-123456")
| fieldsAdd helper = toString(alert_test_labels)
| parse helper, """'[' KVP{'"' LD:key ':' LD:value '"' (', '|']')}:kvp"""
| fieldsFlatten kvp&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 16:25:57 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/227040#M325</guid>
      <dc:creator>peter_zahrer</dc:creator>
      <dc:date>2023-10-30T16:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Log processing rule - for each item in json array split on ":" then create fields using split[0] as key and split[1]</title>
      <link>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/231486#M416</link>
      <description>&lt;P&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/6323"&gt;@peter_zahrer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm currently facing similar issue with dynamic key value pairs. The Log Processor Rule can parse the data using KVP parsing and store the data into an array. However, I want to extract those key:value into fields (key) so they can be used in DQL search or data explorer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the "fieldsFlatten" command is not supported in the Log processor definition (i.e. DPL). It works in Notebook DLP Architect, but not in the rule definition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any other solution available?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mosharref_hossn_0-1702308848127.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/16117i731FE545C48D57E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mosharref_hossn_0-1702308848127.png" alt="mosharref_hossn_0-1702308848127.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 15:34:49 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Log-processing-rule-for-each-item-in-json-array-split-on-quot/m-p/231486#M416</guid>
      <dc:creator>mosharref_hossn</dc:creator>
      <dc:date>2023-12-11T15:34:49Z</dc:date>
    </item>
  </channel>
</rss>

