# Search for Matches in Arrays Using Dynatrace DQL

**URL:** <https://community.dynatrace.com/t/search-for-matches-in-arrays-using-dynatrace-dql/50863>\
**Category:** DQL\
**Tags:** dql, logs\
**Created:** [March 24, 2025, 10:34pm UTC](https://community.dynatrace.com/t/search-for-matches-in-arrays-using-dynatrace-dql/50863 "2025-03-24T22:34:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![triptisharma](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@triptisharma](https://community.dynatrace.com/u/triptisharma)\
**Post date:** [March 24, 2025, 10:34pm UTC](https://community.dynatrace.com/t/search-for-matches-in-arrays-using-dynatrace-dql/50863/1 "2025-03-24T22:34:34Z")

</div>

_Summary:&nbsp;This post explains how to use DQL to find matches within arrays of values. It includes syntax examples and tips for efficient query building in Dynatrace dashboards._

Dear Community Members,

I was looking to implement a log filter, and I was trying to filter the logs based on an array of chosen variables.

Ex ( tried this, but it does not work) :

fetch logs  
| filter matchesValue(log.source, “/opt/sa/log/core.trc”)  
| filter matchesPhrase(content , “failed to establish connection”)  
|filter matchesValue(content, array($IHost))

I want to match all logs which have individual matching entries of a failure to establish a connection basically, I would like to do this

array of IHost ={“[test.com](http://test.com)”,“[try.com](http://try.com)”,“[google.com](http://google.com)”}

fetch logs  
| filter matchesValue(log.source, “/opt/sa/log/core.trc”)  
| filter matchesPhrase(content , “failed to establish connection”)  
|filter matchesValue(content, “[test.com](http://test.com)”) or&nbsp;matchesValue(content, “[try.com](http://try.com)”) or&nbsp;matchesValue(content, “[google.com](http://google.com)”)

What would be the best way to do this?

---

<div class="post-metadata">

**Author:** ![marco\_irmer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marco_irmer/32/3038_2.png) [@marco\_irmer](https://community.dynatrace.com/u/marco_irmer)\
**Post date:** [March 24, 2025, 10:37pm UTC](https://community.dynatrace.com/t/search-for-matches-in-arrays-using-dynatrace-dql/50863/2 "2025-03-24T22:37:23Z")

</div>

I believe the [in](https://docs.dynatrace.com/docs/shortlink/general-functions#in) function will do what you are looking for.

---

<div class="post-metadata">

**Author:** ![triptisharma](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@triptisharma](https://community.dynatrace.com/u/triptisharma)\
**Post date:** [March 24, 2025, 10:49pm UTC](https://community.dynatrace.com/t/search-for-matches-in-arrays-using-dynatrace-dql/50863/3 "2025-03-24T22:49:49Z")

</div>

I have tried the in clause but it did not work, unfortunately.

Here is an example of the log content

2025-03-22 04:38:51,366 -0400#INFO#com.sap#AccessControl connection checker# #SccEndpointValidator failed to establish connection to [HTTPS://test.a4at.com:443](HTTPS://test.a4at.com:443)&nbsp;  
java.net.ConnectException: error 111 - Connection refused (Connection refused) (local port 40406 to address 10.99.123.123 ([test.a4at.com](http://test.a4at.com)), remote port 443 to address 10.99.8.55 ([test.a4at.com](http://test.a4at.com)))  
at java.net.PlainSocketImpl.socketConnect(Native Method)

2025-03-22 04:38:51,366 -0400#INFO#com.sap#AccessControl connection checker# #SccEndpointValidator failed to establish connection to [HTTPS://test.a4at.com:443](HTTPS://test.a4at.com:443)&nbsp;  
java.net.ConnectException: error 111 - Connection refused (Connection refused) (local port 40406 to address 10.99.123.123 ([try.com](http://try.com)), remote port 443 to address 10.99.8.55 ([test.a4at.com](http://test.a4at.com)))  
at java.net.PlainSocketImpl.socketConnect(Native Method)

I have a dropdown variable (IHost) in a dashboard in which two values are chosen [try.com](http://try.com),[test.a4at.com](http://test.a4at.com)

I wrote a query which used

fetch logs  
| filter matchesValue(log.source, “/opt/sap/scc/log/scc\_core.trc”)  
| filter matchesPhrase(content , “failed to establish connection”)  
|filter in(content, array($IHost))

And

| filter matchesValue(log.source, “/opt/sa/log/core.trc”)  
| filter matchesPhrase(content , “failed to establish connection”)  
|filter matchesValue(content, array($IHost))

Both of these didn’t work . My apologies if I am missing something basic.

---

<div class="post-metadata">

**Author:** ![marco\_irmer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marco_irmer/32/3038_2.png) [@marco\_irmer](https://community.dynatrace.com/u/marco_irmer)\
**Post date:** [March 25, 2025, 12:21am UTC](https://community.dynatrace.com/t/search-for-matches-in-arrays-using-dynatrace-dql/50863/4 "2025-03-25T00:21:42Z")

</div>

The issue is that you are using the field ‘content’ within the in() function. This won’t work because it’s comparing the entire log entry (‘content’) to see if it matches one of your variable values exactly. You will need use the [parse](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/commands/extraction-and-parsing-commands#parse) command to extract the host value into a new field using [Dynatrace Pattern Language (DPL)](https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-pattern-language) and then use that field in place of ‘content’.

The revised query would look something like this:

```javascript
fetch logs
| filter matchesValue(log.source, "/opt/sap/scc/log/scc_core.trc")
| filter matchesPhrase(content , "failed to establish connection")
| parse content, "<DPL PATTERN HERE>"
| filter in(<field name here>, array($IHost))

```

You’ll have to insert your own DPL pattern and then update the last filter line with the appropriate field name.

---

<div class="post-metadata">

**Author:** ![triptisharma](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@triptisharma](https://community.dynatrace.com/u/triptisharma)\
**Post date:** [March 25, 2025, 12:26am UTC](https://community.dynatrace.com/t/search-for-matches-in-arrays-using-dynatrace-dql/50863/5 "2025-03-25T00:26:02Z")

</div>

Thank you Marco! Let me try your suggestion and I will update here if it worked.

---

<div class="post-metadata">

**Author:** ![triptisharma](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@triptisharma](https://community.dynatrace.com/u/triptisharma)\
**Post date:** [March 25, 2025, 2:29pm UTC](https://community.dynatrace.com/t/search-for-matches-in-arrays-using-dynatrace-dql/50863/6 "2025-03-25T14:29:27Z")

</div>

Thank you so much for your help&nbsp;[@marco\_irmer](https://community.dynatrace.com/user/19769)&nbsp;that worked for me.
