# DQL parse of log not getting complete data.

**URL:** <https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716>\
**Category:** DQL\
**Tags:** dql\
**Created:** [November 5, 2024, 12:58pm UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716 "2024-11-05T12:58:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [November 5, 2024, 12:58pm UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716/1 "2024-11-05T12:58:19Z")

</div>

The log below has multiple entries I am only getting the first set with my parse, seems I am missing a way to make it iterate through to the end?

{  
“content”: {  
“alertText”: [  
{  
“Id”: “Workers-22”,  
“SpaceId”: “Spaces-1”,  
“WorkerPoolIds”: [  
“WorkerPools-42”  
],  
“HealthStatus”: “HasWarnings”,  
“HasLatestCalamari”: true,  
“StatusSummary”: “This machine is running an old version of Tentacle (xxxxx).”,  
“OperatingSystem”: “Microsoft Windows Server 2019 Standard xxxxxx”  
},  
{  
“Id”: “Workers-23”,  
“SpaceId”: “Spaces-1”,  
“WorkerPoolIds”: [  
“WorkerPools-42”  
],  
“HealthStatus”: “HasWarnings”,  
“HasLatestCalamari”: false,  
“StatusSummary”: “This machine is running an old version of Tentacle (6.1.1403).”,  
“OperatingSystem”: “Microsoft Windows Server 2019 Standard xxxxx”  
},

DQL:

fetch logs  
| filter contains(log.tag, “octopus\_workers”)  
| fields timestamp, content  
| parse content, “DATA '[{\“Id\”:\”’ DATA:Id ‘\“,\“SpaceId\”:\”’ DATA:SpaceId ‘\“,\“WorkerPoolIds\”:[\”’ DATA:WorkerPoolIds ‘\“],\“HealthStatus\”:\”’ DATA:HealthStatus ‘\",\“HasLatestCalamari\”:’ DATA:HasLatestCalamri ‘,\“StatusSummary\”:\"’ DATA:StatusSummary ‘\“,\“OperatingSystem\”:\”’ DATA:OperatingSystem ‘\"},’"

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [November 5, 2024, 1:34pm UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716/2 "2024-11-05T13:34:49Z")

</div>

Is there any problem with using the JSON parser?

> **[DQL use cases](https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/dql-use-cases)**
>
> Common uses cases of Dynatrace Query Language.

---

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [November 5, 2024, 2:45pm UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716/3 "2024-11-05T14:45:53Z")

</div>

I am not able to get JSON parser to do what I want either,

 ![rseibert1_0-1730817941305.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/0/70d8f29aa20ce5f5736ecc889ce68c13c15dbe1f.png)

---

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [November 7, 2024, 2:21pm UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716/4 "2024-11-07T14:21:23Z")

</div>

Seems like I am closer to a solution with the parse content approach but it fails to loop through the whole log, only getting first instance of all the fields:

fetch logs  
| filter contains(log.tag, “octopus\_workers”)  
| parse content, “”“DATA '\“Id\”:\”’ DATA:Id ‘\“,\“SpaceId\”:\”’ DATA:SpaceId ‘\“,\“WorkerPoolIds\”:[\”’ DATA:WorkerPoolIds ‘\“],\“HealthStatus\”:\”’ DATA:HealthStatus ‘\",\“HasLatestCalamari\”:’ DATA:HasLatestCalamri ‘,\“StatusSummary\”:\"’ DATA:StatusSummary ‘\“,\“OperatingSystem\”:\”’ DATA:OperatingSystem ‘\"},’“”"  
| fields Id, SpaceId, WorkerPoolIds, HealthStatus, StatusSummary, OperatingSystem

 ![rseibert1_0-1730989272670.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/9/0918ca1e9f56801b2f4825075c94575221039622.png)

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [November 8, 2024, 7:35am UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716/5 "2024-11-08T07:35:46Z")

</div>

For the json parser, Won’t be something like json.alertText[0].SpaceId ?  
Please check&nbsp;[https://community.dynatrace.com/t5/DQL/Json-parsing-in-DQL/m-p/242105](https://community.dynatrace.com/post/242105)

---

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [November 8, 2024, 5:20pm UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716/6 "2024-11-08T17:20:41Z")

</div>

yes, I found that page, I tried a few different ways to get a single field pulled from the json and not sure what I am missing?

 ![rseibert1_0-1731086371197.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/c/2c2f5c84d0a77fbb4451593a03c3a4903a7af7d4.png)

---

<div class="post-metadata">

**Author:** ![rseibert1](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rseibert1](https://community.dynatrace.com/u/rseibert1)\
**Post date:** [November 8, 2024, 6:15pm UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716/7 "2024-11-08T18:15:30Z")

</div>

I tried several solutions along those lines but all of them return null. I must be missing something ?

 ![rseibert1_0-1731086371197.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/c/2c2f5c84d0a77fbb4451593a03c3a4903a7af7d4.png)

---

<div class="post-metadata">

**Author:** ![Tiit\_Hallas](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@Tiit\_Hallas](https://community.dynatrace.com/u/Tiit_Hallas)\
**Post date:** [November 12, 2024, 10:07am UTC](https://community.dynatrace.com/t/dql-parse-of-log-not-getting-complete-data/48716/8 "2024-11-12T10:07:55Z")

</div>

The main issue seems to be that the JSON object is not complete (I presume this is due to copying a partial result of the content. If you right-click on the partial content in the **Security Investigator** and view field details, you can see it as a raw string with line-breaks, not as a JSON object:

 ![Tiit_Hallas_3-1731406268609.png](https://global.discourse-cdn.com/dynatrace/original/2X/8/812ff9a17a88958370b8097624e7b40ea2ea2892.jpeg)

If I added the proper ending to the JSON (added “]}}”), the field details looks better:

 ![Tiit_Hallas_4-1731406319760.png](https://global.discourse-cdn.com/dynatrace/original/2X/8/8eeb9ef9abe2dc8a4bcd39459dd96704a898e1d3.jpeg)

And then the JSON matcher parses it perfectly as well, see the attached screenshot from the Security Investigator record details:

 ![Tiit_Hallas_0-1731405088865.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/6/46c5387502d3ecda8da0142eb5056c974bbdc94c.jpeg)

To extract single elements from a JSON array to separate fields, you can use the **JSON** and **JSON\_ARRAY** matchers and if you want, you can also extract only specific fields by defining them to the pattern.

The final pattern that I created looked like this:

```markup
JSON{ 
  JSON{
    JSON_ARRAY{ 
      JSON{ 
        STRING:Id, 
        STRING:SpaceId, 
        STRING:HealthStatus
      } 
    }:alertText
  }(flat=true):content 
}(flat=true)

```

I used the “ **flat=true** ” to unnset the objects + defined the field. After that you can use DQL commands “ **expand** ” and “ **fieldsFlatten** ” to spread the array elements to different records and to flatten the object fields to separate columns.

 ![Tiit_Hallas_2-1731406045643.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/f/0fb2901f2ff695aaf8dd768cc058fb6152a3aada.jpeg)

I’ve shared the Security Investigation case in the Playground with you as well, you can see all the steps that I took by navigating the query tree in the right.

[https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/b9709361-dd10-4739-820a-145d89c7d4de](https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.security.investigator/share/b9709361-dd10-4739-820a-145d89c7d4de)
