# Is this a bug? Why does matchesPhrase fail and at the same time contains works?

**URL:** <https://community.dynatrace.com/t/is-this-a-bug-why-does-matchesphrase-fail-and-at-the-same-time-contains-works/42015>\
**Category:** DQL\
**Tags:** dql\
**Created:** [October 10, 2023, 5:36pm UTC](https://community.dynatrace.com/t/is-this-a-bug-why-does-matchesphrase-fail-and-at-the-same-time-contains-works/42015 "2023-10-10T17:36:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GerrysR6](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@GerrysR6](https://community.dynatrace.com/u/GerrysR6)\
**Post date:** [October 10, 2023, 5:36pm UTC](https://community.dynatrace.com/t/is-this-a-bug-why-does-matchesphrase-fail-and-at-the-same-time-contains-works/42015/1 "2023-10-10T17:36:19Z")

</div>

Below is my query, which finds results. Note that both dt.kubernetes.event.message and event.name have the same value, which is “Back-off restarting failed container”

fetch events  
| filter event.status != “CLOSED” and matchesPhrase(dt.kubernetes.event.message, “restarting”) and contains(event.name, “restarting”)  
| fields timestamp, event.name, event.status, dt.kubernetes.event.message  
| limit 1000

If I change contains to matchesPhrase there are no results. Why not? If I use&nbsp;matchesPhrase(event.name, “\*restarting\*”) there are results, why do I have to use a wildcard for event.name but not for dt.kubernetes.event.message?

---

<div class="post-metadata">

**Author:** ![GerardJ](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerardj/32/154_2.png) [@GerardJ](https://community.dynatrace.com/u/GerardJ)\
**Post date:** [October 11, 2023, 8:31am UTC](https://community.dynatrace.com/t/is-this-a-bug-why-does-matchesphrase-fail-and-at-the-same-time-contains-works/42015/2 "2023-10-11T08:31:21Z")

</div>

Hello  
Maybe in the event.name field, there is a non-word character succeeding the word “restarting” (eg. a dot or a comma) so that the matchesPhrase is not validated without the wildcard.

 ![GerardJ_0-1697012982204.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/1/c15beaa208a8d6f7d3eed32effc5bc078add1007.png)

Hope this helps

---

<div class="post-metadata">

**Author:** ![GerrysR6](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@GerrysR6](https://community.dynatrace.com/u/GerrysR6)\
**Post date:** [October 11, 2023, 3:11pm UTC](https://community.dynatrace.com/t/is-this-a-bug-why-does-matchesphrase-fail-and-at-the-same-time-contains-works/42015/3 "2023-10-11T15:11:41Z")

</div>

If there was a dot or a common I’d see it. Added a **==** to make the problem even more clear. Note that “restarting” obviously starts and ends with a word character, and before and after it are non-word characters, so it meets the criteria for matchesPhrase. I’ll be doing training with some people at my company and at this point I will be recommending they use contains and not matchesPhrase.

// this finds data:

fetch events  
| filter event.status != “CLOSED” and matchesPhrase(dt.kubernetes.event.message, “restarting”) and **contains** (event.name, “restarting”)

| filter dt.kubernetes.event.message == event.name

// this does not find data (unless wildcards are added):

fetch events&nbsp;  
| filter event.status != “CLOSED” and matchesPhrase(dt.kubernetes.event.message, “restarting”) and **matchesPhrase** (event.name, “restarting”)

| filter dt.kubernetes.event.message == event.name

You can run the above queries using the demo site and get the same responses.&nbsp;This is what the actual data looks like:

**timestamp&nbsp;10/11/2023, 8:03:28 AM&nbsp;event.name&nbsp;Back-off restarting failed&nbsp; container&nbsp;event.status&nbsp;ACTIVE&nbsp;dt.kubernetes.event.message&nbsp;Back-off restarting failed container**

---

<div class="post-metadata">

**Author:** ![GerrysR6](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@GerrysR6](https://community.dynatrace.com/u/GerrysR6)\
**Post date:** [October 11, 2023, 4:03pm UTC](https://community.dynatrace.com/t/is-this-a-bug-why-does-matchesphrase-fail-and-at-the-same-time-contains-works/42015/4 "2023-10-11T16:03:59Z")

</div>

Unable to find documentation for “contains”…

---

<div class="post-metadata">

**Author:** ![GerardJ](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerardj/32/154_2.png) [@GerardJ](https://community.dynatrace.com/u/GerardJ)\
**Post date:** [October 12, 2023, 6:46am UTC](https://community.dynatrace.com/t/is-this-a-bug-why-does-matchesphrase-fail-and-at-the-same-time-contains-works/42015/5 "2023-10-12T06:46:22Z")

</div>

I found this in the DQL docs :&nbsp;[DQL functions | Dynatrace Docs](https://www.dynatrace.com/support/help/platform/grail/dynatrace-query-language/functions)

 ![GerardJ_0-1697093044263.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/1/3161128f3b3fa0346fee25b9c83635f3b5a13c69.png)

---

<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:** [October 12, 2023, 1:58pm UTC](https://community.dynatrace.com/t/is-this-a-bug-why-does-matchesphrase-fail-and-at-the-same-time-contains-works/42015/6 "2023-10-12T13:58:38Z")

</div>

Hi&nbsp;[@GerrysR6](https://community.dynatrace.com/user/67468)

We have noticed that a bug was introduced when doing some special filtering operations (in your case filtering with matchesPhrase on event.name). The issue was already fixed and the fix will be rolled out with one of the next releases.&nbsp; For more details about the fix, please reach out to&nbsp;[Tech Support](https://one.dynatrace.com/hc/en-us/requests)

A workaround would be to use the lower function for event.name

```markup
fetch events
| filter event.status != "CLOSED" and matchesPhrase(dt.kubernetes.event.message, "restarting") and matchesPhrase(lower(event.name), "restarting")
| fields timestamp, event.name, event.status, dt.kubernetes.event.message
| limit 1000

```

Best,  
Sini
