# Notebook query

**URL:** <https://community.dynatrace.com/t/notebook-query/39407>\
**Category:** DQL\
**Tags:** dql, latest-dynatrace, notebooks\
**Created:** [April 21, 2023, 3:40pm UTC](https://community.dynatrace.com/t/notebook-query/39407 "2023-04-21T15:40:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen1\_Lee](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stephen1\_Lee](https://community.dynatrace.com/u/Stephen1_Lee)\
**Post date:** [April 21, 2023, 3:40pm UTC](https://community.dynatrace.com/t/notebook-query/39407/1 "2023-04-21T15:40:23Z")

</div>

Hi

I can see that event.kind == “DAVIS\_PROBLEM” can be used as a filter for notebook events.

But can we also filter on the labels.

For example in the event, I can see

labels.management\_zone:Synthetic

So can I add a&nbsp; filter expression?&nbsp; I tried (labels.management\_zone == “Synthetic”) but my query returns nothing.

---

<div class="post-metadata">

**Author:** ![michal\_zawislak](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/michal_zawislak/32/13613_2.png) [@michal\_zawislak](https://community.dynatrace.com/u/michal_zawislak)\
**Post date:** [April 24, 2023, 6:43am UTC](https://community.dynatrace.com/t/notebook-query/39407/2 "2023-04-24T06:43:33Z")

</div>

Hi&nbsp;[@Stephen1\_Lee](https://community.dynatrace.com/user/24856),

You could try with _matchesValue_&nbsp;e.g.

```auto
fetch events | filter event.kind == "DAVIS_PROBLEM" AND matchesValue(labels.management_zone, "Synthetic")

```

Please check out the [documentation](https://www.dynatrace.com/support/help/observe-and-explore/query-data/dynatrace-query-language/functions#matchesValue) for more usage examples.

---

<div class="post-metadata">

**Author:** ![Stephen1\_Lee](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stephen1\_Lee](https://community.dynatrace.com/u/Stephen1_Lee)\
**Post date:** [May 1, 2023, 5:48pm UTC](https://community.dynatrace.com/t/notebook-query/39407/3 "2023-05-01T17:48:26Z")

</div>

hi.&nbsp; the matchesValue works.

I as trying to dashboard a barchart of problems per management zone so I could make it into a tile.

Running this over the past 2 hrs only give me 2 records.

fetch events  
| filter (event.kind == “DAVIS\_PROBLEM”) and matchesValue(labels.management\_zone, “EBE”)  
| summarize value = count(), by:{display\_id,event.status}  
| fields display\_id,event.status

---

<div class="post-metadata">

**Author:** ![Stephen1\_Lee](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stephen1\_Lee](https://community.dynatrace.com/u/Stephen1_Lee)\
**Post date:** [May 1, 2023, 5:50pm UTC](https://community.dynatrace.com/t/notebook-query/39407/4 "2023-05-01T17:50:40Z")

</div>

but when I go to problems and filter to the same management zone I see 10 active problems.

I would like a dashboard tile of the same bar chart.

 ![problemsInEBE.JPG](https://global.discourse-cdn.com/dynatrace/original/2X/9/9b097300838eba53e5fe5dbecdfa5058353f0b88.jpeg)

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [May 2, 2023, 2:39pm UTC](https://community.dynatrace.com/t/notebook-query/39407/5 "2023-05-02T14:39:06Z")

</div>

Hi Stephen,

First, I would like to share with you some info about Davis problems in Grail. Davis problem records in Grail represent snapshots of a problem. So for one problem, there are multiple records and the most recent record for a problem represents the current status of a problem. E.g. here you have a DQL query that shows you the open and close time stamps for problems

```markup
fetch events
| filter event.kind == "DAVIS_PROBLEM"
| fieldsAdd close_ts = if(event.status == "CLOSED" AND event.status_transition == "RESOLVED",timestamp)
| fieldsAdd open_ts = if(event.status == "ACTIVE" AND event.status_transition == "UPDATED",timestamp)
| filter isNotNull(close_ts) or isNotNull(open_ts)
| summarize 
  open = min(open_ts),
  closed = max(close_ts),
  by:{display_id, event.category, event.name }
| sort open asc

```

So it might be possible if you query for problems in the last 2h that you don’t get all active problems of the last 2 hours. For instance if a problem was opened more than 3 hours ago and there was no update since then.

Unfortunately what you want to achieve, to display number of problems per management zone, is currently not possible with DQL & Grail. The management zone information is stored as array information for a problem. But the team is currently working on a “expand” command which expands arrays to multiple records. With that new command the query will be possible. Expect it to be released within the next couple months.

Best,  
Sini

---

<div class="post-metadata">

**Author:** ![Bhargav\_314](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@Bhargav\_314](https://community.dynatrace.com/u/Bhargav_314)\
**Post date:** [August 18, 2023, 6:57am UTC](https://community.dynatrace.com/t/notebook-query/39407/6 "2023-08-18T06:57:27Z")

</div>

Hi Sini,

I am trying to fetch Count of problems raised in each week for each management Zone by using NoteBooks. I was facing issue to apply filter for management zone. Could you please help me.

Regards,

Bhargav Vuyyuru

---

<div class="post-metadata">

**Author:** ![andruccioli50](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@andruccioli50](https://community.dynatrace.com/u/andruccioli50)\
**Post date:** [May 13, 2024, 2:49pm UTC](https://community.dynatrace.com/t/notebook-query/39407/7 "2024-05-13T14:49:46Z")

</div>

Hi Sinisa,

could I ask you if it is now possible to achive this one?

> Unfortunately what you want to achieve, to display number of problems per management zone, is currently not possible with DQL & Grail. The management zone information is stored as array information for a problem. But the team is currently working on a “expand” command which expands arrays to multiple records. With that new command the query will be possible. Expect it to be released within the next couple months.

any advice on how to reach this goal? Could you share in case it is now possible an example or docs?

Thanks in advance wish you a good day,

Matteo
