diff --git a/CHANGELOG.md b/CHANGELOG.md index 26938816d8..81d0d1328e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ #### Loki ##### Enhancements +* [7023](https://github.com/grafana/loki/pull/7023) **liguozhong**: logql engine support exec `vector(0)` grammar. * [6983](https://github.com/grafana/loki/pull/6983) **slim-bean**: `__timestamp__` and `__line__` are now available in the logql `label_format` query stage. * [6821](https://github.com/grafana/loki/pull/6821) **kavirajk**: Introduce new cache type `embedded-cache` which is an in-process cache system that runs loki without the need for an external cache (like memcached, redis, etc). It can be run in two modes `distributed: false` (default, and same as old `fifocache`) and `distributed: true` which runs cache in distributed fashion sharding keys across peers if Loki is run in microservices or SSD mode. * [6691](https://github.com/grafana/loki/pull/6691) **dannykopping**: Update production-ready Loki cluster in docker-compose diff --git a/docs/sources/logql/metric_queries.md b/docs/sources/logql/metric_queries.md index a26f668b33..2a2d03bdcd 100644 --- a/docs/sources/logql/metric_queries.md +++ b/docs/sources/logql/metric_queries.md @@ -121,3 +121,20 @@ The `without` clause removes the listed labels from the resulting vector, keepin The `by` clause does the opposite, dropping labels that are not listed in the clause, even if their label values are identical between all elements of the vector. See [vector aggregation examples](../query_examples/#vector-aggregation-examples) for query examples that use vector aggregation expressions. + +## Functions + +LogQL supports a set of built-in functions. + +- `vector(s scalar)`: returns the scalar s as a vector with no labels. This behaves identically to the [Prometheus `vector()` function](https://prometheus.io/docs/prometheus/latest/querying/functions/#vector). + `vector` is mainly used to return a value for a series that would otherwise return nothing; this can be useful when using LogQL to define an alert. + +Examples: + +- Count all the log lines within the last five minutes for the traefik namespace. + + ```logql + sum(count_over_time({namespace="traefik"}[5m])) # will return nothing + or + vector(0) # will return 0 + ```