mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
lib/httpserver: add is_set
label to flag
metrics
This label allows determining the set flags with the query `flag{is_set="true"}`
This commit is contained in:
parent
5bc240bffe
commit
2df66dad7b
@ -15,6 +15,7 @@ sort: 15
|
||||
* `/select/<accountID>/vmui/` for `vmselect` at cluster version of VictoriaMetrics
|
||||
* FEATURE: support durations anywhere in [MetricsQL queries](https://docs.victoriametrics.com/MetricsQL.html). For example, `sum_over_time(m[1h]) / 1h` is a valid query, which is equivalent to `sum_over_time(m[1h]) / 3600`.
|
||||
* FEATURE: support durations without suffxies in [MetricsQL queries](https://docs.victoriametrics.com/MetricsQL.html). For example, `rate(m[3600])` is a valid query, which is equivalent to `rate(m[1h])`.
|
||||
* FEATURE: add `is_set` label to `flag` metrics. This allows determining explicitly set command-line flags with the query `flag{is_set="true"}`.
|
||||
|
||||
* BUGFIX: vmagent: remove `{ %space %}` typo in `/targets` output. The typo has been introduced in v1.62.0. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1408).
|
||||
* BUGFIX: vmagent: fix CSS styles on `/targets` page. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1422).
|
||||
|
@ -58,6 +58,10 @@ func writePrometheusMetrics(w io.Writer) {
|
||||
fmt.Fprintf(w, "vm_app_uptime_seconds %d\n", int(time.Since(startTime).Seconds()))
|
||||
|
||||
// Export flags as metrics.
|
||||
isSetMap := make(map[string]bool)
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
isSetMap[f.Name] = true
|
||||
})
|
||||
flag.VisitAll(func(f *flag.Flag) {
|
||||
lname := strings.ToLower(f.Name)
|
||||
value := f.Value.String()
|
||||
@ -65,7 +69,11 @@ func writePrometheusMetrics(w io.Writer) {
|
||||
// Do not expose passwords and keys to prometheus.
|
||||
value = "secret"
|
||||
}
|
||||
fmt.Fprintf(w, "flag{name=%q, value=%q} 1\n", f.Name, value)
|
||||
isSet := "false"
|
||||
if isSetMap[f.Name] {
|
||||
isSet = "true"
|
||||
}
|
||||
fmt.Fprintf(w, "flag{name=%q, value=%q, is_set=%q} 1\n", f.Name, value, isSet)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,20 @@ import (
|
||||
func logAllFlags() {
|
||||
Infof("build version: %s", buildinfo.Version)
|
||||
Infof("command line flags")
|
||||
isSetMap := make(map[string]bool)
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
isSetMap[f.Name] = true
|
||||
})
|
||||
flag.VisitAll(func(f *flag.Flag) {
|
||||
lname := strings.ToLower(f.Name)
|
||||
value := f.Value.String()
|
||||
if flagutil.IsSecretFlag(lname) {
|
||||
value = "secret"
|
||||
}
|
||||
Infof("flag %q = %q", f.Name, value)
|
||||
isSet := "false"
|
||||
if isSetMap[f.Name] {
|
||||
isSet = "true"
|
||||
}
|
||||
Infof("flag %q=%q (is_set=%s)", f.Name, value, isSet)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user