# Log processing rules : how to set newfeild=success by checking if a key exist in Parsed JSON

**URL:** <https://community.dynatrace.com/t/log-processing-rules-how-to-set-newfeild-success-by-checking-if-a-key-exist-in-parsed-json/42166>\
**Category:** DQL\
**Tags:** dql, log-processing, log-monitoring-class, dpl\
**Created:** [October 18, 2023, 5:07pm UTC](https://community.dynatrace.com/t/log-processing-rules-how-to-set-newfeild-success-by-checking-if-a-key-exist-in-parsed-json/42166 "2023-10-18T17:07:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pallepavan](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@pallepavan](https://community.dynatrace.com/u/pallepavan)\
**Post date:** [October 18, 2023, 5:07pm UTC](https://community.dynatrace.com/t/log-processing-rules-how-to-set-newfeild-success-by-checking-if-a-key-exist-in-parsed-json/42166/1 "2023-10-18T17:07:43Z")

</div>

is it possible to add a field to logs by check if a KEY exist in a Parsed JSON while processing logs,

JSON SAMPLE :  
{

“name” : “test”

“action” : “some random string”

…

…

}

requirement : add a new\_feild as log attribute if json contains a key named “action”

PARSE(content,“JSON:data”) |  
FIELDS\_ADD( new\_feild: IF{ ??? })

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [October 27, 2023, 9:05pm UTC](https://community.dynatrace.com/t/log-processing-rules-how-to-set-newfeild-success-by-checking-if-a-key-exist-in-parsed-json/42166/2 "2023-10-27T21:05:10Z")

</div>

Hi [@pallepavan](https://community.dynatrace.com/user/66885)

Yep, you can do that. You don’t even need to parse your json, assuming the string ‘action’ is not present anywhere.

|fieldsAdd hasaction = contains(content,“action”)

This will add a ‘hasaction’ field as boolean (true/false) to your results. Then you can use it in your IF condition, to add a new field with some other log attribute.

Check this doc to get more details: [DQL functions — Dynatrace Docs](https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/functions#if)
