From 0846c2805f6c58f89ca7a82e0f0fb7236eac4a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Fri, 4 Apr 2025 20:20:08 +0200 Subject: [PATCH] logon: deprecate collector. Use `terminal_services` instead (#1957) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- README.md | 1 - docs/collector.logon.md | 78 ------------------- internal/collector/logon/logon.go | 11 ++- internal/collector/os/os.go | 6 +- .../terminal_services/terminal_services.go | 2 +- tools/e2e-output.txt | 4 +- 6 files changed, 15 insertions(+), 87 deletions(-) delete mode 100644 docs/collector.logon.md diff --git a/README.md b/README.md index b636e8d2..9088114c 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ Name | Description | Enabled by default [iis](docs/collector.iis.md) | IIS sites and applications | [license](docs/collector.license.md) | Windows license status | [logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | ✓ -[logon](docs/collector.logon.md) | User logon sessions | [memory](docs/collector.memory.md) | Memory usage metrics | ✓ [mscluster](docs/collector.mscluster.md) | MSCluster metrics | [msmq](docs/collector.msmq.md) | MSMQ queues | diff --git a/docs/collector.logon.md b/docs/collector.logon.md deleted file mode 100644 index 93d7088f..00000000 --- a/docs/collector.logon.md +++ /dev/null @@ -1,78 +0,0 @@ -# logon collector - -The logon collector exposes metrics detailing the active user logon sessions. - -| | | -|---------------------|-----------| -| Metric name prefix | `logon` | -| Source | Win32 API | -| Enabled by default? | No | - -## Flags - -None - -## Metrics - -| Name | Description | Type | Labels | -|-------------------------------------------|--------------------------------------------|-------|------------------------------------| -| `windows_logon_session_logon_timestamp_seconds` | timestamp of the logon session in seconds. | gauge | `domain`, `id`, `type`, `username` | - -### Example metric -Query the total number of interactive logon sessions -``` -# HELP windows_logon_session_logon_timestamp_seconds timestamp of the logon session in seconds. -# TYPE windows_logon_session_logon_timestamp_seconds gauge -windows_logon_session_logon_timestamp_seconds{domain="",id="0x0:0x8c54",type="System",username=""} 1.72876928e+09 -windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0x991a",type="Interactive",username="UMFD-1"} 1.728769282e+09 -windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0x9933",type="Interactive",username="UMFD-0"} 1.728769282e+09 -windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0x994a",type="Interactive",username="UMFD-0"} 1.728769282e+09 -windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0x999d",type="Interactive",username="UMFD-1"} 1.728769282e+09 -windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0xbf25a",type="Interactive",username="UMFD-2"} 1.728769532e+09 -windows_logon_session_logon_timestamp_seconds{domain="Font Driver Host",id="0x0:0xbf290",type="Interactive",username="UMFD-2"} 1.728769532e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x130241",type="Network",username="vm-jok-dev$"} 1.728769625e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x24f7c9",type="Network",username="vm-jok-dev$"} 1.728770121e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x276846",type="Network",username="vm-jok-dev$"} 1.728770195e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x3e4",type="Service",username="vm-jok-dev$"} 1.728769283e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x3e7",type="System",username="vm-jok-dev$"} 1.728769279e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x71d0f",type="Network",username="vm-jok-dev$"} 1.728769324e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x720a3",type="Network",username="vm-jok-dev$"} 1.728769324e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x725cb",type="Network",username="vm-jok-dev$"} 1.728769324e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0x753d8",type="Network",username="vm-jok-dev$"} 1.728769325e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0xa3913",type="Network",username="vm-jok-dev$"} 1.728769385e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0xbe7f2",type="Network",username="jok"} 1.728769531e+09 -windows_logon_session_logon_timestamp_seconds{domain="JKROEPKE",id="0x0:0xc76c4",type="RemoteInteractive",username="jok"} 1.728769533e+09 -windows_logon_session_logon_timestamp_seconds{domain="NT AUTHORITY",id="0x0:0x3e3",type="Service",username="IUSR"} 1.728769295e+09 -windows_logon_session_logon_timestamp_seconds{domain="NT AUTHORITY",id="0x0:0x3e5",type="Service",username="LOCAL SERVICE"} 1.728769283e+09 -windows_logon_session_logon_timestamp_seconds{domain="NT Service",id="0x0:0xae4c7",type="Service",username="MSSQLSERVER"} 1.728769425e+09 -windows_logon_session_logon_timestamp_seconds{domain="NT Service",id="0x0:0xb42f1",type="Service",username="SQLTELEMETRY"} 1.728769431e+09 -windows_logon_session_logon_timestamp_seconds{domain="Window Manager",id="0x0:0xbfbac",type="Interactive",username="DWM-2"} 1.728769532e+09 -windows_logon_session_logon_timestamp_seconds{domain="Window Manager",id="0x0:0xbfc72",type="Interactive",username="DWM-2"} 1.728769532e+09 -windows_logon_session_logon_timestamp_seconds{domain="Window Manager",id="0x0:0xdedd",type="Interactive",username="DWM-1"} 1.728769283e+09 -windows_logon_session_logon_timestamp_seconds{domain="Window Manager",id="0x0:0xdefd",type="Interactive",username="DWM-1"} 1.728769283e+09 -``` - -### Possible values for `type` - -- System -- Interactive -- Network -- Batch -- Service -- Proxy -- Unlock -- NetworkCleartext -- NewCredentials -- RemoteInteractive -- CachedInteractive -- CachedRemoteInteractive -- CachedUnlock - -## Useful queries -Query the total number of local and remote (I.E. Terminal Services) interactive sessions. -``` -count(windows_logon_logon_type{type=~"Interactive|RemoteInteractive"}) by (type) -``` - -## Alerting examples -_This collector doesn’t yet have alerting examples, we would appreciate your help adding them!_ diff --git a/internal/collector/logon/logon.go b/internal/collector/logon/logon.go index 6d91829b..c3955a89 100644 --- a/internal/collector/logon/logon.go +++ b/internal/collector/logon/logon.go @@ -34,6 +34,7 @@ type Config struct{} var ConfigDefaults = Config{} // A Collector is a Prometheus Collector for WMI metrics. +// Deprecated: Use windows_terminal_services_session_info instead. type Collector struct { config Config @@ -64,10 +65,16 @@ func (c *Collector) Close() error { return nil } -func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { +func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { + logger.Warn("The logon collector will be removed mid 2025. "+ + "See https://github.com/prometheus-community/windows_exporter/pull/1957 for more information. If you see values in this collector"+ + " that you need, please open an issue to discuss how to get them into the new collector.", + slog.String("collector", Name), + ) + c.sessionInfo = prometheus.NewDesc( prometheus.BuildFQName(types.Namespace, Name, "session_logon_timestamp_seconds"), - "timestamp of the logon session in seconds.", + "Deprecated. Use windows_terminal_services_session_info instead.", []string{"id", "username", "domain", "type"}, nil, ) diff --git a/internal/collector/os/os.go b/internal/collector/os/os.go index ddbca422..cec7aca5 100644 --- a/internal/collector/os/os.go +++ b/internal/collector/os/os.go @@ -53,7 +53,7 @@ type Collector struct { processesLimit *prometheus.Desc // users - // Deprecated: Use count(windows_logon_logon_type) instead. + // Deprecated: Use `sum(windows_terminal_services_session_info{state="active"})` instead. users *prometheus.Desc // physicalMemoryFreeBytes @@ -106,7 +106,7 @@ func (c *Collector) Close() error { } func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { - logger.Warn("The os collect holds a number of deprecated metrics and will be removed mid 2025. "+ + logger.Warn("The os collector holds a number of deprecated metrics and will be removed mid 2025. "+ "See https://github.com/prometheus-community/windows_exporter/pull/1596 for more information.", slog.String("collector", Name), ) @@ -180,7 +180,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { ) c.users = prometheus.NewDesc( prometheus.BuildFQName(types.Namespace, Name, "users"), - "Deprecated: Use `count(windows_logon_logon_type)` instead.", + "Deprecated: Use `sum(windows_terminal_services_session_info{state=\"active\"})` instead.", nil, nil, ) diff --git a/internal/collector/terminal_services/terminal_services.go b/internal/collector/terminal_services/terminal_services.go index 107345a2..717ee95e 100644 --- a/internal/collector/terminal_services/terminal_services.go +++ b/internal/collector/terminal_services/terminal_services.go @@ -439,7 +439,7 @@ func (c *Collector) collectWTSSessions(ch chan<- prometheus.Metric) error { for _, session := range sessions { // only connect metrics for remote named sessions n := strings.ReplaceAll(session.SessionName, "#", " ") - if n == "" || n == "Services" || n == "Console" { + if n == "" || n == "Services" { continue } diff --git a/tools/e2e-output.txt b/tools/e2e-output.txt index fc316d31..7292b6ae 100644 --- a/tools/e2e-output.txt +++ b/tools/e2e-output.txt @@ -193,7 +193,7 @@ windows_exporter_collector_timeout{collector="udp"} 0 # TYPE windows_logical_disk_write_seconds_total counter # HELP windows_logical_disk_writes_total The number of write operations on the disk (LogicalDisk.DiskWritesPerSec) # TYPE windows_logical_disk_writes_total counter -# HELP windows_logon_session_logon_timestamp_seconds timestamp of the logon session in seconds. +# HELP windows_logon_session_logon_timestamp_seconds Deprecated. Use windows_terminal_services_session_info instead. # TYPE windows_logon_session_logon_timestamp_seconds gauge # HELP windows_memory_available_bytes The amount of physical memory immediately available for allocation to a process or for system use. It is equal to the sum of memory assigned to the standby (cached), free and zero page lists (AvailableBytes) # TYPE windows_memory_available_bytes gauge @@ -311,7 +311,7 @@ windows_exporter_collector_timeout{collector="udp"} 0 # TYPE windows_os_time gauge # HELP windows_os_timezone Deprecated: Use windows_time_timezone instead. # TYPE windows_os_timezone gauge -# HELP windows_os_users Deprecated: Use `count(windows_logon_logon_type)` instead. +# HELP windows_os_users Deprecated: Use `sum(windows_terminal_services_session_info{state="active"})` instead. # TYPE windows_os_users gauge # HELP windows_os_virtual_memory_bytes Deprecated: Use `windows_memory_commit_limit` instead. # TYPE windows_os_virtual_memory_bytes gauge