# Nodata to Zero values query

**URL:** <https://discuss.prometheus.io/t/nodata-to-zero-values-query/2320>\
**Category:** PromQL\
**Created:** [June 26, 2024, 4:59am UTC](https://discuss.prometheus.io/t/nodata-to-zero-values-query/2320 "2024-06-26T04:59:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhilash](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@abhilash](https://discuss.prometheus.io/u/abhilash)\
**Post date:** [June 26, 2024, 4:59am UTC](https://discuss.prometheus.io/t/nodata-to-zero-values-query/2320/1 "2024-06-26T04:59:04Z")

</div>

Topic: Handling Missing HAProxy Logs in Prometheus Across Multiple Clusters

**Context:**

I’m currently working on monitoring HAProxy logs using Loki and Prometheus. I’ve created a recording rule in Loki to count the logs:

**Loki Query:**

```plaintext
sum by (hostname, k8s_cluster_name) (count_over_time({hostname=~".*haproxy.*"} |= "" | json [5m]))

```

This query aggregates the log counts over 5-minute intervals, grouped by `hostname` and `k8s_cluster_name`.

**Prometheus Query:**

```plaintext
avg_over_time(haproxylogs{}[15m])

```

This PromQL query calculates the average number of HAProxy logs over a 15-minute window.

**Problem:**

I want to handle scenarios where logs are not received for a particular cluster, and these missing logs should be represented as zero values in Prometheus. I found the `absent` function in Prometheus, which converts “no data” to zero values. However, the `absent` function only works for single clusters, not across multiple clusters.

**Question:**

How can I create a Prometheus query that handles missing HAProxy logs and shows zero values across multiple clusters?

I would appreciate any insights or suggestions on this topic. Thank you!
