diff --git a/app/vmagent/main.go b/app/vmagent/main.go index f86e3b85e5..befe066eb2 100644 --- a/app/vmagent/main.go +++ b/app/vmagent/main.go @@ -161,6 +161,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { {"/api/v1/targets", "advanced information about discovered targets in JSON format"}, {"/config", "-promscrape.config contents"}, {"/metrics", "available service metrics"}, + {"/flags", "command-line flags"}, {"/-/reload", "reload configuration"}, }) return true diff --git a/app/vmalert/web.go b/app/vmalert/web.go index a82ba776e0..e1034dab73 100644 --- a/app/vmalert/web.go +++ b/app/vmalert/web.go @@ -28,6 +28,7 @@ func initLinks() { {path.Join(pathPrefix, "api/v1/groups"), "list all loaded groups and rules"}, {path.Join(pathPrefix, "api/v1/alerts"), "list all active alerts"}, {path.Join(pathPrefix, "api/v1/groupID/alertID/status"), "get alert status by ID"}, + {path.Join(pathPrefix, "flags"), "command-line flags"}, {path.Join(pathPrefix, "metrics"), "list of application metrics"}, {path.Join(pathPrefix, "-/reload"), "reload configuration"}, } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0d207eb5e9..8b878fe3dc 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -18,6 +18,7 @@ sort: 15 * FEATURE: add trigonometric functions, which are going to be added in [Prometheus 2.31](https://github.com/prometheus/prometheus/pull/9239): [acosh](https://docs.victoriametrics.com/MetricsQL.html#acosh), [asinh](https://docs.victoriametrics.com/MetricsQL.html#asinh), [atan](https://docs.victoriametrics.com/MetricsQL.html#atan), [atanh](https://docs.victoriametrics.com/MetricsQL.html#atanh), [cosh](https://docs.victoriametrics.com/MetricsQL.html#cosh), [deg](https://docs.victoriametrics.com/MetricsQL.html#deg), [rad](https://docs.victoriametrics.com/MetricsQL.html#rad), [sinh](https://docs.victoriametrics.com/MetricsQL.html#sinh), [tan](https://docs.victoriametrics.com/MetricsQL.html#tan), [tanh](https://docs.victoriametrics.com/MetricsQL.html#tanh). Also add `atan2` binary operator. See [this pull request](https://github.com/prometheus/prometheus/pull/9248). * FEATURE: consistently return the same set of time series from [limitk](https://docs.victoriametrics.com/MetricsQL.html#limitk) function. This improves the usability of periodically refreshed graphs. * FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): varios UX improvements. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1711). +* FEATURE: add `/flags` page to all the VictoriaMetrics components. This page contains command-line flags passed to the component. * BUGFIX: vmstorage: fix `unaligned 64-bit atomic operation` panic on 32-bit architectures (arm and 386). The panic has been introduced in v1.67.0. * BUGFIX: vmalert, vmauth: prevent from frequent closing of TCP connections established to backends under high load. This should reduce the number of TCP sockets in `TIME_WAIT` state at `vmalert` and `vmauth` under high load. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1704). diff --git a/lib/flagutil/flag.go b/lib/flagutil/flag.go new file mode 100644 index 0000000000..706dc13f00 --- /dev/null +++ b/lib/flagutil/flag.go @@ -0,0 +1,15 @@ +package flagutil + +import ( + "flag" + "fmt" + "io" +) + +// WriteFlags writes all the explicitly set flags to w. +func WriteFlags(w io.Writer) { + flag.Visit(func(f *flag.Flag) { + value := f.Value.String() + fmt.Fprintf(w, "-%s=%q\n", f.Name, value) + }) +} diff --git a/lib/httpserver/httpserver.go b/lib/httpserver/httpserver.go index fcf4cf06ed..f48215825e 100644 --- a/lib/httpserver/httpserver.go +++ b/lib/httpserver/httpserver.go @@ -22,6 +22,7 @@ import ( "time" "github.com/VictoriaMetrics/VictoriaMetrics/lib/fasttime" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/flagutil" "github.com/VictoriaMetrics/VictoriaMetrics/lib/logger" "github.com/VictoriaMetrics/VictoriaMetrics/lib/netutil" "github.com/VictoriaMetrics/metrics" @@ -271,6 +272,10 @@ func handlerWrapper(s *server, w http.ResponseWriter, r *http.Request, rh Reques WritePrometheusMetrics(w) metricsHandlerDuration.UpdateDuration(startTime) return + case "/flags": + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + flagutil.WriteFlags(w) + return default: if strings.HasPrefix(r.URL.Path, "/debug/pprof/") { pprofRequests.Inc()