Merge branch 'public-single-node' into pmm-6401-read-prometheus-data-files

This commit is contained in:
Aliaksandr Valialkin 2020-11-03 14:15:45 +02:00
commit 8772cb617c
2 changed files with 7 additions and 2 deletions

View file

@ -112,7 +112,8 @@ This functionality can be tried at [an editable Grafana dashboard](http://play-g
- `bottomk_min(k, q)` - returns bottom K time series with the min minimums on the given time range
- `bottomk_max(k, q)` - returns bottom K time series with the min maximums on the given time range
- `bottomk_avg(k, q)` - returns bottom K time series with the min averages on the given time range
- `bottomk_median(k, q)` - returns bottom K time series with the min medians on the given time range
- `bottomk_median(k, q)` - returns bottom K time series with the min medians on the given time range.
All the `topk_*` and `bottomk_*` functions accept optional third argument - label name for the sum of the remaining time series outside top K or bottom K time series. For example, `topk_max(3, process_resident_memory_bytes, "remaining_sum")` would return up to 3 time series with the maximum value for `process_resident_memory_bytes` plus fourth time series with the sum of the remaining time series if any. The fourth time series will contain `remaining_sum="remaining_sum"` additional label.
- `share_le_over_time(m[d], le)` - returns share (in the range 0..1) of values in `m` over `d`, which are smaller or equal to `le`. Useful for calculating SLI and SLO.
Example: `share_le_over_time(memory_usage_bytes[24h], 100*1024*1024)` returns the share of time series values for the last 24 hours when memory usage was below or equal to 100MB.

View file

@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"io"
"regexp"
"strings"
"time"
@ -13,11 +14,14 @@ import (
"github.com/VictoriaMetrics/metrics"
)
var versionRe = regexp.MustCompile(`v\d+\.\d+\.\d+`)
// WritePrometheusMetrics writes all the registered metrics to w in Prometheus exposition format.
func WritePrometheusMetrics(w io.Writer) {
metrics.WritePrometheus(w, true)
fmt.Fprintf(w, "vm_app_version{version=%q} 1\n", buildinfo.Version)
fmt.Fprintf(w, "vm_app_version{version=%q, short_version=%q} 1\n", buildinfo.Version,
versionRe.FindString(buildinfo.Version))
fmt.Fprintf(w, "vm_allowed_memory_bytes %d\n", memory.Allowed())
// Export start time and uptime in seconds