Skip to content

Commit 38fb8bd

Browse files
davidioinbriantu
andauthored
Active Directory Performance Metrics (DataDog#20894)
* First Poc draft of netlogon metrics * Perfmon metrics added * Added new readme, metadata, and corrected linting issues * Partially working tester * Harden and optimize check with thread safety, cache updates and updated read me * Removed code duplication between Active Directory and Windows Service integrations * Revert changes to datadog_checks_base files from c0edd4c * New readme and ddev validate * validated models * windows py updates * Validation changes to AD folder * Enumerated windows services in windows.py * Initial cleanup * Clean up logic * Fix tests * Clean up metrics + remove changelogs * Override check method + don't raise exception * Fix lint errors * Fix metadata * Just check if service exists * Update readme * Update conftest comment * Fix changelog * Remove mock instances * Clean up unit tests * Add periods to DHCP counters --------- Co-authored-by: briantu <brian.tu@datadoghq.com>
1 parent ba39cd2 commit 38fb8bd

9 files changed

Lines changed: 244 additions & 49 deletions

File tree

active_directory/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,37 @@ If installing the Datadog Agent on a domain environment, see [the installation r
3232

3333
See [metadata.csv][8] for a list of metrics provided by this integration.
3434

35+
The integration collects metrics from the following Windows performance objects:
36+
37+
- **NTDS**: Core Active Directory metrics including replication, LDAP operations, and directory service threads
38+
- **Netlogon**: Authentication performance metrics including semaphore statistics for monitoring authentication bottlenecks
39+
- **Security System-Wide Statistics**: Authentication protocol usage metrics (NTLM vs Kerberos)
40+
- **DHCP Server**: DHCP failover and binding update metrics (when DHCP Server role is installed)
41+
- **DFS Replicated Folders**: DFS replication health, conflicts, and staging metrics (when DFSR role is installed)
42+
- Note: Metrics are tagged with `instance` containing the DFS replication group name
43+
44+
#### Netlogon Metrics
45+
46+
The Netlogon metrics help monitor authentication performance and identify bottlenecks in domain controller authentication processing:
47+
48+
- `active_directory.netlogon.semaphore_waiters`: Number of threads waiting for the authentication semaphore
49+
- `active_directory.netlogon.semaphore_holders`: Number of threads currently holding the semaphore
50+
- `active_directory.netlogon.semaphore_acquires`: Total number of semaphore acquisitions
51+
- `active_directory.netlogon.semaphore_timeouts`: Number of timeouts waiting for the semaphore
52+
- `active_directory.netlogon.semaphore_hold_time`: Average time (in seconds) the semaphore is held
53+
54+
These metrics are particularly useful for monitoring authentication load from network access control (NAC) devices, Wi-Fi authentication, and other authentication-heavy scenarios.
55+
56+
##### Use Cases
57+
58+
The Netlogon and Security metrics help address several monitoring scenarios:
59+
60+
- **Monitor authentication bottlenecks**: Identify when authentication requests are queuing up, particularly from Cisco ISE NAC devices or high-volume Wi-Fi authentication
61+
- **Track authentication processing times**: Use `semaphore_hold_time` to determine if authentication is taking too long
62+
- **Identify MaxConcurrentApi tuning needs**: High `semaphore_waiters` values indicate the need to adjust the MaxConcurrentApi registry setting
63+
- **Monitor authentication protocol usage**: Track the ratio of NTLM vs Kerberos authentications to ensure proper protocol usage
64+
- **Detect authentication timeouts and failures**: Rising `semaphore_timeouts` indicate authentication infrastructure issues
65+
3566
### Events
3667

3768
The Active Directory check does not include any events.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add Netlogon, Security, DHCP Server, DFSR metrics and expand NTDS metrics.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# (C) Datadog, Inc. 2025-present
2+
# All rights reserved
3+
# Licensed under a 3-clause BSD style license (see LICENSE)
4+
5+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
11
# (C) Datadog, Inc. 2021-present
22
# All rights reserved
33
# Licensed under a 3-clause BSD style license (see LICENSE)
4+
5+
6+
import win32serviceutil
7+
48
from datadog_checks.base.checks.windows.perf_counters.base import PerfCountersBaseCheckWithLegacySupport
59

610
from .metrics import METRICS_CONFIG
711

12+
SERVICE_METRIC_MAP = {
13+
'NTDS': ['NTDS'],
14+
'Netlogon': ['Netlogon', 'Security System-Wide Statistics'],
15+
'DHCPServer': ['DHCP Server'],
16+
'DFSR': ['DFS Replicated Folders'],
17+
}
18+
19+
20+
def _service_exists(service_name):
21+
try:
22+
win32serviceutil.QueryServiceStatus(service_name)
23+
except Exception:
24+
return False
25+
return True
26+
27+
28+
def _get_existing_services():
29+
return {service for service in SERVICE_METRIC_MAP.keys() if _service_exists(service)}
30+
831

932
class ActiveDirectoryCheckV2(PerfCountersBaseCheckWithLegacySupport):
1033
__NAMESPACE__ = 'active_directory'
1134

1235
def get_default_config(self):
13-
return {'metrics': METRICS_CONFIG}
36+
"""Build metrics configuration based on service availability."""
37+
filtered_metrics_config = {}
38+
existing_services = _get_existing_services()
39+
40+
for service in existing_services:
41+
for metric in SERVICE_METRIC_MAP[service]:
42+
filtered_metrics_config[metric] = METRICS_CONFIG[metric]
43+
44+
return {'metrics': filtered_metrics_config}

active_directory/datadog_checks/active_directory/metrics.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,52 @@
5050
'LDAP Bind Time': {'metric_name': 'ldap.bind_time'},
5151
'LDAP Successful Binds/sec': {'metric_name': 'ldap.successful_binds_persec'},
5252
'LDAP Searches/sec': {'metric_name': 'ldap.searches_persec'},
53+
'LDAP Writes/sec': {'metric_name': 'ldap.writes_persec', 'type': 'rate'},
54+
'LDAP Active Threads': {'metric_name': 'ldap.active_threads'},
55+
'DS Client Binds/sec': {'metric_name': 'ds.client_binds_persec', 'type': 'rate'},
56+
}
57+
],
58+
},
59+
'Netlogon': {
60+
'name': 'netlogon',
61+
'counters': [
62+
{
63+
'Semaphore Waiters': 'semaphore_waiters',
64+
'Semaphore Holders': 'semaphore_holders',
65+
'Semaphore Acquires': {'name': 'semaphore_acquires', 'type': 'count'},
66+
'Semaphore Timeouts': {'name': 'semaphore_timeouts', 'type': 'count'},
67+
'Average Semaphore Hold Time': 'semaphore_hold_time',
68+
}
69+
],
70+
},
71+
'Security System-Wide Statistics': {
72+
'name': 'security',
73+
'counters': [
74+
{
75+
'NTLM Authentications': {'name': 'ntlm_authentications', 'type': 'rate'},
76+
'Kerberos Authentications': {'name': 'kerberos_authentications', 'type': 'rate'},
77+
}
78+
],
79+
},
80+
'DHCP Server': {
81+
'name': 'dhcp',
82+
'counters': [
83+
{
84+
'Failover: BndUpd Dropped.': {'name': 'failover.binding_updates_dropped', 'type': 'count'},
85+
'Failover: BndUpd pending in outbound queue.': 'failover.binding_updates_pending',
86+
'Failover: BndUpd received/sec.': {'name': 'failover.binding_updates_received', 'type': 'rate'},
87+
'Failover: BndUpd sent/sec.': {'name': 'failover.binding_updates_sent', 'type': 'rate'},
88+
}
89+
],
90+
},
91+
'DFS Replicated Folders': {
92+
'name': 'dfsr',
93+
'counters': [
94+
{
95+
'Conflict Space In Use': {'name': 'conflict_space_in_use', 'unit': 'byte'},
96+
'Deleted Space In Use': {'name': 'deleted_space_in_use', 'unit': 'byte'},
97+
'File Installs Retried': {'name': 'file_installs_retried', 'type': 'count'},
98+
'Staging Space In Use': {'name': 'staging_space_in_use', 'unit': 'byte'},
5399
}
54100
],
55101
},

0 commit comments

Comments
 (0)