Skip to content

Add per_user services filter to windows_service#24088

Merged
steveny91 merged 5 commits into
masterfrom
branden.clark/windows-service-exclude-per-user
Jun 25, 2026
Merged

Add per_user services filter to windows_service#24088
steveny91 merged 5 commits into
masterfrom
branden.clark/windows-service-exclude-per-user

Conversation

@clarkb7

@clarkb7 clarkb7 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a per_user boolean criterion to the windows_service services filter, mirroring the existing trigger_start criterion. A filter item can match services by whether they are Windows per-user service instances (named <template>_<LUID>, e.g. OneSyncSvc_443f50). To exclude per-user services from collection, configure per_user: false to collect only non-per-user services:

services:
  - per_user: false

per_user composes with name, startup_type, and trigger_start in any filter item. When group_per_user_services is enabled alongside a per_user: false filter, a warning is logged since excluded services are never collected and cannot be grouped.

Motivation

Per-user services are often pure noise on monitored hosts, and each carries a per-session/per-host LUID suffix that inflates windows_service tag cardinality. This complements the group_per_user_services option (parent PR) by letting users drop per-user services from collection entirely rather than grouping them.

Stacked on #24087 — this PR targets branden.clark/windows-service-group-per-user and should be reviewed/merged after it.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@clarkb7 clarkb7 added team/windows-products qa/required QA is required for this PR and will generate a QA card labels Jun 17, 2026
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 95.27% (+7.27%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a1ef409 | Docs | Datadog PR Page | Give us feedback!

@clarkb7
clarkb7 force-pushed the branden.clark/windows-service-exclude-per-user branch from 840d15d to 72af051 Compare June 17, 2026 16:50
Base automatically changed from branden.clark/windows-service-group-per-user to master June 24, 2026 21:30
clarkb7 added 5 commits June 24, 2026 17:38
Add a per_user (true/false) match criterion to the services filter,
mirroring trigger_start, to select services by whether they are Windows
per-user service instances. Configure per_user: false to exclude per-user
services from collection. Warn when grouping is enabled alongside a
per_user: false filter, since excluded services cannot be grouped.
Use the existing ServiceAssertion / assert_service_check_and_metrics
helpers in the per_user tests for consistency with the rest of the suite;
this also asserts the uptime/state/restarts metrics, not just the service
check.
Pass the enumeration's ServiceType into ServiceView and have ServiceFilter.match
read service_view.service_type, consistent with how it reads the other service
properties, rather than threading service_type through match() as an argument.
Read service_type from the service config when it was not provided to the
constructor, caching like the other ServiceView properties, and include it
in __str__.
@steveny91
steveny91 added this pull request to the merge queue Jun 25, 2026
Merged via the queue into master with commit 3ca0f7d Jun 25, 2026
79 of 89 checks passed
@steveny91
steveny91 deleted the branden.clark/windows-service-exclude-per-user branch June 25, 2026 16:26
@dd-octo-sts dd-octo-sts Bot added this to the 7.82.0 milestone Jun 25, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The backport to 7.80.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-7.80.x 7.80.x
# Navigate to the new working tree
cd .worktrees/backport-7.80.x
# Create a new branch
git switch --create backport-24088-to-7.80.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 3ca0f7de0a36adad7275e9761b189bda21c41524
# Push it to GitHub
git push --set-upstream origin backport-24088-to-7.80.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.80.x

Then, create a pull request where the base branch is 7.80.x and the compare/head branch is backport-24088-to-7.80.x.

@dd-octo-sts

dd-octo-sts Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The backport to 7.81.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-7.81.x 7.81.x
# Navigate to the new working tree
cd .worktrees/backport-7.81.x
# Create a new branch
git switch --create backport-24088-to-7.81.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 3ca0f7de0a36adad7275e9761b189bda21c41524
# Push it to GitHub
git push --set-upstream origin backport-24088-to-7.81.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.81.x

Then, create a pull request where the base branch is 7.81.x and the compare/head branch is backport-24088-to-7.81.x.

steveny91 pushed a commit that referenced this pull request Jun 25, 2026
* Add per_user services filter criterion to windows_service

Add a per_user (true/false) match criterion to the services filter,
mirroring trigger_start, to select services by whether they are Windows
per-user service instances. Configure per_user: false to exclude per-user
services from collection. Warn when grouping is enabled alongside a
per_user: false filter, since excluded services cannot be grouped.

* Add changelog entry

* Reuse ServiceAssertion in per_user tests

Use the existing ServiceAssertion / assert_service_check_and_metrics
helpers in the per_user tests for consistency with the rest of the suite;
this also asserts the uptime/state/restarts metrics, not just the service
check.

* Read service_type from ServiceView instead of a match() parameter

Pass the enumeration's ServiceType into ServiceView and have ServiceFilter.match
read service_view.service_type, consistent with how it reads the other service
properties, rather than threading service_type through match() as an argument.

* Make ServiceView.service_type lazy with config fallback

Read service_type from the service config when it was not provided to the
constructor, caching like the other ServiceView properties, and include it
in __str__.

(cherry picked from commit 3ca0f7d)

Co-authored-by: Branden Clark <branden.clark@datadoghq.com>
@dd-octo-sts

dd-octo-sts Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

Kyle-Neale pushed a commit that referenced this pull request Jun 26, 2026
* Add per_user services filter criterion to windows_service

Add a per_user (true/false) match criterion to the services filter,
mirroring trigger_start, to select services by whether they are Windows
per-user service instances. Configure per_user: false to exclude per-user
services from collection. Warn when grouping is enabled alongside a
per_user: false filter, since excluded services cannot be grouped.

* Add changelog entry

* Reuse ServiceAssertion in per_user tests

Use the existing ServiceAssertion / assert_service_check_and_metrics
helpers in the per_user tests for consistency with the rest of the suite;
this also asserts the uptime/state/restarts metrics, not just the service
check.

* Read service_type from ServiceView instead of a match() parameter

Pass the enumeration's ServiceType into ServiceView and have ServiceFilter.match
read service_view.service_type, consistent with how it reads the other service
properties, rather than threading service_type through match() as an argument.

* Make ServiceView.service_type lazy with config fallback

Read service_type from the service config when it was not provided to the
constructor, caching like the other ServiceView properties, and include it
in __str__.

(cherry picked from commit 3ca0f7d)

Co-authored-by: Branden Clark <branden.clark@datadoghq.com>
@chatgpt-codex-connector chatgpt-codex-connector Bot mentioned this pull request Jun 26, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants