# Null values returned for pending pods

**URL:** <https://community.dynatrace.com/t/null-values-returned-for-pending-pods/40743>\
**Category:** DQL\
**Tags:** dql, kubernetes\
**Created:** [July 18, 2023, 10:58am UTC](https://community.dynatrace.com/t/null-values-returned-for-pending-pods/40743 "2023-07-18T10:58:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VivekRagupathy](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@VivekRagupathy](https://community.dynatrace.com/u/VivekRagupathy)\
**Post date:** [July 18, 2023, 10:58am UTC](https://community.dynatrace.com/t/null-values-returned-for-pending-pods/40743/1 "2023-07-18T10:58:16Z")

</div>

I am trying to filter the pending pods in one of the clusters and also only from any of the two namespaces, so I have written query like mentioned below,

I am getting null values as series,&nbsp;If there are no pending pods, I do expect that the query does not return any record.

Usually I take the last item from the array and consider that as the current state.

Am I missing anything here?

Query Used:

timeseries series=sum(dt.kubernetes.pods), by:{k8s.workload.name,k8s.namespace.name,k8s.cluster.name,pod\_phase}  
| filter k8s.cluster.name == “\<myclustername\>” and (startsWith(k8s.namespace.name, “\<startofmynamespace1\>”) or contains(k8s.namespace.name, “\<substringmynamespace2\>”)) and pod\_phase == “Pending”

Result:

{  
“series”: [  
null,  
null,  
null,  
null,  
null,  
null,  
null,  
null,  
null,  
null,  
null  
],  
“k8s.workload.name”: “\<myworkloadname\>”,  
“k8s.namespace.name”: “\<mynamespace1\>”,  
“k8s.cluster.name”: “\<Mycluster\>”,  
“pod\_phase”: “Pending”,  
“timeframe”: {  
“start”: “2023-07-18T10:19:00.000Z”,  
“end”: “2023-07-18T10:30:00.000Z”  
},  
“interval”: “60000000000”  
}

---

<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:** [July 18, 2023, 11:33am UTC](https://community.dynatrace.com/t/null-values-returned-for-pending-pods/40743/2 "2023-07-18T11:33:47Z")

</div>

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

I don’t see in your query where you take the last item from the array and consider that as the current state?

Can you try out following query, it works for me in my environment

```markup
timeseries series=sum(dt.kubernetes.pods), by:{k8s.workload.name,k8s.namespace.name,k8s.cluster.name,pod_phase}, 
  filter:pod_phase == "Pending" and k8s.workload.name == "" and k8s.namespace.name == "" and k8s.cluster.name == ""
| fields countPendingPods = arrayLast(series), k8s.workload.name,k8s.namespace.name,k8s.cluster.name
| filter isNotNull(countPendingPods)

```

with the arrayLast, I am retrieving the most recent value of the array.

Best,  
Sini

---

<div class="post-metadata">

**Author:** ![VivekRagupathy](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@VivekRagupathy](https://community.dynatrace.com/u/VivekRagupathy)\
**Post date:** [July 18, 2023, 4:02pm UTC](https://community.dynatrace.com/t/null-values-returned-for-pending-pods/40743/3 "2023-07-18T16:02:26Z")

</div>

Hi Sini,&nbsp;  
Thanks for looking in to this query.  
Yes I removed the arrayLast() function to show all the null records returned.&nbsp;  
Agree filtering with isNotNull() function is removing all the null records. Thanks for sharing this function.

I am curious to know when we are specifying pod\_phase == “Pending” it should not return any null values right?

---

<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:** [July 19, 2023, 10:40am UTC](https://community.dynatrace.com/t/null-values-returned-for-pending-pods/40743/4 "2023-07-19T10:40:39Z")

</div>

for querying the dt.kubernetes.pods metric the pod\_phase is a dimension, so you are filtering to that dimension. So the dimension with the value “Pending” of that metric is written usually once per minute only if a pod is in “Pending” state. If not, no it remains “null”. that is the reason why the timeseries consists of null values (no pod was at that point in time in “Pending”).

The result of the timeseries command is at least one record (depends on the dimension splitting you can specify). And a record consists of an array of datapoints which represent the value of a certain point in time.

I hope this explanation helps to understand you better what is happening?

---

<div class="post-metadata">

**Author:** ![VivekRagupathy](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@VivekRagupathy](https://community.dynatrace.com/u/VivekRagupathy)\
**Post date:** [July 19, 2023, 11:25am UTC](https://community.dynatrace.com/t/null-values-returned-for-pending-pods/40743/5 "2023-07-19T11:25:12Z")

</div>

Hi Sini,

Thanks for the clarification. It helps 🙂
