From 34738679a1207e339dec8d30162e811454c04f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Thu, 15 Oct 2026 23:24:06 +0200 Subject: [PATCH] fix(service,iis,docs): flag error names, IIS help typo, mixin tooling and log.file default (#2732) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- AGENTS.md | 26 ++++++++++++++++++---- README.md | 2 +- docs/collector.iis.md | 2 +- internal/collector/iis/iis.go | 2 +- internal/collector/service/service.go | 6 ++--- internal/collector/service/service_test.go | 18 +++++++++++++++ 6 files changed, 46 insertions(+), 10 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 7ffc3f1d..fb988a7a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -228,10 +228,28 @@ Gate every tab, row, panel and variable on the collectors it queries with `jsonnet -J vendor tests/dashboard.test.jsonnet` to check the layout for several collector selections. -From `contrib/mixin`, install the pinned tools with `make tools`, ensure they -are on `PATH`, then run `make fmt`, `make generate`, `make check-dashboards` and -`make test`. Keep generated artifacts in sync. The tests cover Jsonnet format, -dashboard parity, promtool rules/tests, offline pint lint and runbook coverage. +From `contrib/mixin`, install the tools pinned in `mise.toml` with +`mise install`, then run `mise run fmt`, `mise run generate`, +`mise run check-dashboards` and `mise run test`. Keep generated artifacts in +sync. The tests cover Jsonnet format, dashboard parity, promtool rules/tests, +offline pint lint, dashboard lint and runbook coverage. + +The tasks are POSIX shell scripts (`set -eu`, `trap`, `mktemp`, `$(...)`) that +also call `rm`, `cp`, `diff`, `git` and, for `check-runbooks`, `python3`. On +Windows, mise runs inline tasks with `cmd /c` by default, so run them in WSL, or +from Git Bash with `MISE_WINDOWS_DEFAULT_INLINE_SHELL_ARGS="bash -c"` and Git's +`bash` (not `C:\Windows\System32\bash.exe`, which starts WSL) first on `PATH`. + +Without mise, run the Jsonnet tools with `go run` at the versions pinned in +`mise.toml`, for example +`go run github.com/google/go-jsonnet/cmd/jsonnet@v0.22.0` (also `jsonnetfmt` +and `jsonnet-lint`) and +`go run github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@v0.6.0 install`. That +covers formatting, generation and the Jsonnet tests; promtool, pint and +dashboard-linter still need their release binaries, so report those checks as +skipped. A Windows checkout with `core.autocrlf` has CRLF sources, so compare +generated output with `diff --strip-trailing-cr`. + Preserve target/device labels, apply counter rates before aggregation, and handle zero denominators. Keep optional-role alerts configurable and provide a runbook for each alert. Check required collector availability and the Grafana diff --git a/README.md b/README.md index a5609127..79bbdf49 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ windows_exporter accepts flags to configure certain behaviours. The ones configu | `--scrape.stdout` | Collect metrics once and write them to stdout, then exit. Logs go to stderr unless `--log.file` is set. PDH rate counters cover only a short interval on the first scrape after startup. | `false` | | `--web.config.file` | A [web config][web_config] for setting up TLS and Auth | None | | `--config.file` | [Using a config file](#using-a-configuration-file) from path | None | -| `--log.file` | Output file of log messages. One of [stdout, stderr, eventlog, \]
**NOTE:** The MSI installer will add a default argument to the installed service setting this to eventlog | stderr | +| `--log.file` | Output file of log messages. One of [stdout, stderr, eventlog, \]. When the exporter runs as a Windows service, such as one installed by the MSI, the default is `eventlog`. | `stdout` | | `--log.rotation.max-size` | Size in megabytes at which the log file is rotated. Requires `--log.file` to be a path. If another process holds the file open without delete sharing, the exporter keeps writing to it and retries the rotation every minute. A moved or deleted log file is recreated within a minute. | `0` (off) | | `--log.rotation.max-backups` | Number of rotated log files to keep. `0` keeps all. | `0` | | `--log.rotation.compress` | Compress rotated log files with gzip. | `false` | diff --git a/docs/collector.iis.md b/docs/collector.iis.md index 9ec47343..cb4b1659 100644 --- a/docs/collector.iis.md +++ b/docs/collector.iis.md @@ -48,7 +48,7 @@ See [#2698](https://github.com/prometheus-community/windows_exporter/issues/2698 | Name | Description | Type | Labels | |----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-----------------------------| -| `windows_iis_info` | ISS information | gauge | `version` (const label) | +| `windows_iis_info` | IIS information | gauge | `version` (const label) | | `windows_iis_current_anonymous_users` | The number of users who currently have an anonymous request pending with the web service | gauge | `site` | | `windows_iis_current_blocked_async_io_requests` | _Not yet documented_ | gauge | `site` | | `windows_iis_current_cgi_requests` | The number of CGI requests that are being processed simultaneously by the web service | gauge | `site` | diff --git a/internal/collector/iis/iis.go b/internal/collector/iis/iis.go index f610323a..a0b3fec9 100644 --- a/internal/collector/iis/iis.go +++ b/internal/collector/iis/iis.go @@ -187,7 +187,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { c.info = prometheus.NewDesc( prometheus.BuildFQName(types.Namespace, Name, "info"), - "ISS information", + "IIS information", []string{}, prometheus.Labels{"version": fmt.Sprintf("%d.%d", c.iisVersion.major, c.iisVersion.minor)}, ) diff --git a/internal/collector/service/service.go b/internal/collector/service/service.go index 4880eae2..6e4875f8 100644 --- a/internal/collector/service/service.go +++ b/internal/collector/service/service.go @@ -152,7 +152,7 @@ func NewWithFlags(app *kingpin.Application) *Collector { app.Flag( "collector.service.include", - "Regexp of service to include. Process name (not the display name!) must both match include and not match exclude to be included.", + "Regexp of service to include. Service name (not the display name!) must both match include and not match exclude to be included.", ).Default(".+").StringVar(&serviceInclude) app.Flag( @@ -165,12 +165,12 @@ func NewWithFlags(app *kingpin.Application) *Collector { c.config.ServiceExclude, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", serviceExclude)) if err != nil { - return fmt.Errorf("collector.process.exclude: %w", err) + return fmt.Errorf("collector.service.exclude: %w", err) } c.config.ServiceInclude, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", serviceInclude)) if err != nil { - return fmt.Errorf("collector.process.include: %w", err) + return fmt.Errorf("collector.service.include: %w", err) } c.config.ServiceStartModeInclude = strings.Split(serviceStartModeInclude, ",") diff --git a/internal/collector/service/service_test.go b/internal/collector/service/service_test.go index 69a99753..dff9d362 100644 --- a/internal/collector/service/service_test.go +++ b/internal/collector/service/service_test.go @@ -20,8 +20,10 @@ package service_test import ( "testing" + "github.com/alecthomas/kingpin/v2" "github.com/prometheus-community/windows_exporter/internal/collector/service" "github.com/prometheus-community/windows_exporter/internal/utils/testutils" + "github.com/stretchr/testify/require" ) func BenchmarkCollector(b *testing.B) { @@ -31,3 +33,19 @@ func BenchmarkCollector(b *testing.B) { func TestCollector(t *testing.T) { testutils.TestCollector(t, service.New, nil) } + +func TestNewWithFlagsReportsRegexpFlagName(t *testing.T) { + t.Parallel() + + for _, flagName := range []string{"collector.service.exclude", "collector.service.include"} { + t.Run(flagName, func(t *testing.T) { + t.Parallel() + + app := kingpin.New("test", "") + service.NewWithFlags(app) + + _, err := app.Parse([]string{"--" + flagName + "=("}) + require.ErrorContains(t, err, flagName+":") + }) + } +}