# Log processing rule - for each item in json array split on ":" then create fields using split\[0\] as key and split\[1\] as value

**URL:** <https://community.dynatrace.com/t/log-processing-rule-for-each-item-in-json-array-split-on-then-create-fields-using-split-0-as-key-and-split-1-as-value/41110>\
**Category:** DQL\
**Tags:** dql, log-processing, grail\
**Created:** [August 8, 2023, 5:02pm UTC](https://community.dynatrace.com/t/log-processing-rule-for-each-item-in-json-array-split-on-then-create-fields-using-split-0-as-key-and-split-1-as-value/41110 "2023-08-08T17:02:52Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Jack\_Stuart](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jack_stuart/32/34583_2.png) [@Jack\_Stuart](https://community.dynatrace.com/u/Jack_Stuart)\
**Post date:** [August 9, 2023, 9:39am UTC](https://community.dynatrace.com/t/log-processing-rule-for-each-item-in-json-array-split-on-then-create-fields-using-split-0-as-key-and-split-1-as-value/41110/3 "2023-08-09T09:39:16Z")

</div>

Hi Fin,

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

Example:

```javascript
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&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)

```

 ![Jack_Stuart_1-1691573910685.png](https://global.discourse-cdn.com/dynatrace/original/2X/8/8ccb243309c18423e78da2afcf51941b3a441953.png)

View of what I’m trying to achieve:

```javascript
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&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"

```

 ![Jack_Stuart_0-1691573725013.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/7/77702f2bbad4a821db54ded574e7d0fbfc914a68.png)

---

_[View the full topic](https://community.dynatrace.com/t/log-processing-rule-for-each-item-in-json-array-split-on-then-create-fields-using-split-0-as-key-and-split-1-as-value/41110)._
