mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-17 10:09:05 +02:00
fix(service,iis,docs): flag error names, IIS help typo, mixin tooling and log.file default (#2732)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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, \<path to log file>]<br>**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, \<path to log file>]. 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` |
|
||||
|
||||
@@ -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` |
|
||||
|
||||
@@ -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)},
|
||||
)
|
||||
|
||||
@@ -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, ",")
|
||||
|
||||
@@ -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+":")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user