mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-10 15:14:09 +00:00
add short_version label to vm_app_version metric (#877)
* add short_version label to vm_app_version metric use case: Version panel of Grafana dashboard should use a live query, but currently it uses a template query which becomes stale. Grafana is not able to preform regex substitution on labels. * Update metrics.go * fix compile
This commit is contained in:
parent
cd071357d8
commit
51e661ecfe
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue