# Is it possible to add multiple fields as sourceField for lookup to work in DQL?

**URL:** <https://community.dynatrace.com/t/is-it-possible-to-add-multiple-fields-as-sourcefield-for-lookup-to-work-in-dql/52617>\
**Category:** DQL\
**Tags:** dql\
**Created:** [July 23, 2025, 5:01pm UTC](https://community.dynatrace.com/t/is-it-possible-to-add-multiple-fields-as-sourcefield-for-lookup-to-work-in-dql/52617 "2025-07-23T17:01:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![virdavindersing](https://avatars.discourse-cdn.com/v4/letter/v/e9a140/32.png) [@virdavindersing](https://community.dynatrace.com/u/virdavindersing)\
**Post date:** [July 23, 2025, 5:01pm UTC](https://community.dynatrace.com/t/is-it-possible-to-add-multiple-fields-as-sourcefield-for-lookup-to-work-in-dql/52617/1 "2025-07-23T17:01:57Z")

</div>

Here’s the query

fetch spans  
| filter dt.system.bucket == “default\_spans”  
AND matchesValue(entityAttr(dt.entity.kubernetes\_cluster, “entity.name”), “cluster\_name”)  
AND NOT (matchesPhrase(endpoint.name, “\*liveness\*”) or matchesPhrase(endpoint.name, “\*health\*”) or matchesPhrase(endpoint.name, “\*readiness\*”))  
AND http.response.status\_code\>399  
// | fieldsAdd is\_failed = http.response.status\_code\>399  
| fieldsAdd cluster=entityName(dt.entity.kubernetes\_cluster)  
| fieldsAdd traces = concat(“[DT Link](https://{environmentid}.apps.dynatrace.com/ui/apps/dynatrace.distributedtracing/explorer?filter=dt.host\_group.id+in+%28”,cluster,“%29+AND+k8s.namespace.name+%3D+”,k8s.namespace.name,“+AND+k8s.workload.name+%3D+”,dt.kubernetes.workload.name,“+AND+endpoint.name+%3D+”,endpoint.name,“+AND+http.response.status\_code+%3E+399&tf=now-2h%3Bnow)”)  
| summarize errorcount=count(), by:{cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name, http.response.status\_code, traces}  
| lookup [ fetch spans  
| filter dt.system.bucket == “default\_spans”  
AND matchesValue(entityAttr(dt.entity.kubernetes\_cluster, “entity.name”), “cluster\_name”)  
AND NOT in(dt.kubernetes.workload.name, {“collab-datamart-content-proxy”})  
AND NOT (matchesPhrase(endpoint.name, “\*liveness\*”) or matchesPhrase(endpoint.name, “\*health\*”) or matchesPhrase(endpoint.name, “\*readiness\*”))  
AND isNotNull(http.response.status\_code)  
// | fieldsAdd is\_failed = http.response.status\_code\>399  
| fieldsAdd cluster=entityName(dt.entity.kubernetes\_cluster)

| summarize all=count(), by:{cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name}],  
source: {cluster: cluster, k8s.namespace.name: k8s.namespace.name, dt.kubernetes.workload.name: dt.kubernetes.workload.name, endpoint.name: endpoint.name},  
fields: {all},  
joinType: “inner”  
| fields cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name, http.response.status\_code, errorcount, all, traces

---

<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:** [July 23, 2025, 7:32pm UTC](https://community.dynatrace.com/t/is-it-possible-to-add-multiple-fields-as-sourcefield-for-lookup-to-work-in-dql/52617/2 "2025-07-23T19:32:17Z")

</div>

Hi there. You may wish to add some additional explanation/context, in addition to the DQL query, to your post in order to help community members understand what you are trying to accomplish and what challenge you are facing.

---

<div class="post-metadata">

**Author:** ![virdavindersing](https://avatars.discourse-cdn.com/v4/letter/v/e9a140/32.png) [@virdavindersing](https://community.dynatrace.com/u/virdavindersing)\
**Post date:** [July 24, 2025, 5:31pm UTC](https://community.dynatrace.com/t/is-it-possible-to-add-multiple-fields-as-sourcefield-for-lookup-to-work-in-dql/52617/3 "2025-07-24T17:31:49Z")

</div>

sure I am trying to building a table like below but it should have the “failure rate” column for the endpoint as well

 ![virdavindersing_0-1753378198333.png](https://global.discourse-cdn.com/dynatrace/original/2X/d/d5e248150b9717d723d2aa9c4dd924ea7596f8c4.png)

---

<div class="post-metadata">

**Author:** ![virdavindersing](https://avatars.discourse-cdn.com/v4/letter/v/e9a140/32.png) [@virdavindersing](https://community.dynatrace.com/u/virdavindersing)\
**Post date:** [July 24, 2025, 5:32pm UTC](https://community.dynatrace.com/t/is-it-possible-to-add-multiple-fields-as-sourcefield-for-lookup-to-work-in-dql/52617/4 "2025-07-24T17:32:52Z")

</div>

does it help from context perspective ?

---

<div class="post-metadata">

**Author:** ![virdavindersing](https://avatars.discourse-cdn.com/v4/letter/v/e9a140/32.png) [@virdavindersing](https://community.dynatrace.com/u/virdavindersing)\
**Post date:** [July 25, 2025, 12:13pm UTC](https://community.dynatrace.com/t/is-it-possible-to-add-multiple-fields-as-sourcefield-for-lookup-to-work-in-dql/52617/5 "2025-07-25T12:13:54Z")

</div>

Basically I need to have the error count based on all the entities (cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name, http.response.status\_code, errorcount, traces)

At the same time, I need to add a column for failure rate based on errorcount/“all requests count” as well&nbsp;  
I couldn’t add the failure rate based on&nbsp;http.response.status\_code together with error count

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [July 28, 2025, 7:10pm UTC](https://community.dynatrace.com/t/is-it-possible-to-add-multiple-fields-as-sourcefield-for-lookup-to-work-in-dql/52617/6 "2025-07-28T19:10:08Z")

</div>

In _ **lookup** _ it is possible with a trick, but in this case it ok just to use _ **join** _ to get this effect. I think this query will give you what you need:

```markup
fetch spans
| filter dt.system.bucket == "default_spans"
  AND matchesValue(entityAttr(dt.entity.kubernetes_cluster, "entity.name"), "cluster_name")
  AND NOT (matchesPhrase(endpoint.name, "*liveness*") 
    or matchesPhrase(endpoint.name, "*health*") 
    or matchesPhrase(endpoint.name, "*readiness*"))
  AND http.response.status_code>399
| fieldsAdd cluster=entityName(dt.entity.kubernetes_cluster)
| fieldsAdd traces = concat("[DT Link](https://{environmentid}.apps.dynatrace.com/ui/apps/dynatrace.distributedtracing/explorer?filter=dt.host_group.id+in+%28",cluster,"%29+AND+k8s.namespace.name+%3D+",k8s.namespace.name,"+AND+k8s.workload.name+%3D+",dt.kubernetes.workload.name,"+AND+endpoint.name+%3D+",endpoint.name,"+AND+http.response.status_code+%3E+399&tf=now-2h%3Bnow)")
| summarize errorcount=count(), 
  by:{cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name, http.response.status_code, traces}

| join 
[ fetch spans
  | filter dt.system.bucket == "default_spans"
  AND matchesValue(entityAttr(dt.entity.kubernetes_cluster, "entity.name"), "cluster_name")
  AND NOT in(dt.kubernetes.workload.name, {"collab-datamart-content-proxy"})
  AND NOT (matchesPhrase(endpoint.name, "*liveness*") 
    or matchesPhrase(endpoint.name, "*health*") 
    or matchesPhrase(endpoint.name, "*readiness*"))
  AND isNotNull(http.response.status_code)
  | fieldsAdd cluster=entityName(dt.entity.kubernetes_cluster)
  | summarize all=count(), 
    by:{cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name}
],
on: {cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name}, 
fields: {all}, kind:inner

| fields cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name, 
  http.response.status_code, errorcount, 100.0*errorcount/all, traces

```

In this case subquery will always produce record for record in main query, so it is safe to use _ **inner** _ join.

_ **lookup** _ command allows only single fields to be user, but you can construct a record containing all needed fields to be used for comparison. Important thing is that on both sides fields need to be names the same and in be in same order.

Such query should produce same results:

```markup
fetch spans
| filter dt.system.bucket == "default_spans"
  AND matchesValue(entityAttr(dt.entity.kubernetes_cluster, "entity.name"), "cluster_name")
  AND NOT (matchesPhrase(endpoint.name, "*liveness*") 
    or matchesPhrase(endpoint.name, "*health*") 
    or matchesPhrase(endpoint.name, "*readiness*"))
  AND http.response.status_code>399
| fieldsAdd cluster=entityName(dt.entity.kubernetes_cluster)
| fieldsAdd traces = concat("[DT Link](https://{environmentid}.apps.dynatrace.com/ui/apps/dynatrace.distributedtracing/explorer?filter=dt.host_group.id+in+%28",cluster,"%29+AND+k8s.namespace.name+%3D+",k8s.namespace.name,"+AND+k8s.workload.name+%3D+",dt.kubernetes.workload.name,"+AND+endpoint.name+%3D+",endpoint.name,"+AND+http.response.status_code+%3E+399&tf=now-2h%3Bnow)")
| summarize errorcount=count(), 
  by:{cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name, http.response.status_code, traces}
| fieldsAdd key = record(cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name)

| lookup 
[ fetch spans
  | filter dt.system.bucket == "default_spans"
  AND matchesValue(entityAttr(dt.entity.kubernetes_cluster, "entity.name"), "cluster_name")
  AND NOT in(dt.kubernetes.workload.name, {"collab-datamart-content-proxy"})
  AND NOT (matchesPhrase(endpoint.name, "*liveness*") 
    or matchesPhrase(endpoint.name, "*health*") 
    or matchesPhrase(endpoint.name, "*readiness*"))
  AND isNotNull(http.response.status_code)
  | fieldsAdd cluster=entityName(dt.entity.kubernetes_cluster)
  | summarize all=count(), 
    by:{cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name}
  | fieldsAdd key = record(cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name)
], sourceField:key, lookupField:key, fields: {all}

| fields cluster, k8s.namespace.name, dt.kubernetes.workload.name, endpoint.name, 
  http.response.status_code, errorcount, 100.0*errorcount/all, traces

```
