Is your feature request related to a problem? Please describe.
I want to turn null (no data) to zero in query result in easy and reliable way.
There are other Loki users who want the same.
https://community.grafana.com/t/how-can-i-turn-no-data-to-zero-in-loki/40694
Describe the solution you'd like
Implement a function like vector() in PromQL.
vector(s scalar) returns the scalar s as a vector with no labels.
Then users can join their query with vector() to turn NULL to zero, as below.
Describe alternatives you've considered
(1) Grafana's transform feature.
However, this feature only works for a dashboard panel with single Loki query. It doesn't work for multiple queries for a panel.
(2) Tried to generate zeros reliably, but not perfect
sum(count_over_time({namespace="traefik"}|="foo"[1m]))
or
sum(count_over_time({namespace="traefik"}[1m])) < bool 0
The 2nd vector can still return NULL if there is no log data matching labels sets. Not useful for log streams which has fluctuating log ingestion.
(3) Tried absent_over_time() as 2nd vector instead, it didn't work for me.
(4) First, stored the log-metrics in Prometheus. Second, use vector() in Prometheus.
This works of course. But I wish I can do the same using LokiQL which is upstream.
Additional context
Is your feature request related to a problem? Please describe.
I want to turn null (no data) to zero in query result in easy and reliable way.
There are other Loki users who want the same.
https://community.grafana.com/t/how-can-i-turn-no-data-to-zero-in-loki/40694
Describe the solution you'd like
Implement a function like vector() in PromQL.
Describe alternatives you've considered
(1) Grafana's transform feature.
However, this feature only works for a dashboard panel with single Loki query. It doesn't work for multiple queries for a panel.
(2) Tried to generate zeros reliably, but not perfect
The 2nd vector can still return NULL if there is no log data matching labels sets. Not useful for log streams which has fluctuating log ingestion.
(3) Tried absent_over_time() as 2nd vector instead, it didn't work for me.
(4) First, stored the log-metrics in Prometheus. Second, use vector() in Prometheus.
This works of course. But I wish I can do the same using LokiQL which is upstream.
Additional context