Skip to content

Commit a2415de

Browse files
POIFischbacherMian28223claude
authored
Add status metric for Windows services and update tests (#25290)
* Add status metric for Windows services and update tests * add changelog file * rephrase metadata description * Sort windows_service metadata.csv Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Update description for windows_service.status metric to clarify status values --------- Co-authored-by: Ian Bucad <ian.bucad@datadoghq.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a9b9e42 commit a2415de

4 files changed

Lines changed: 10 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adding `windows_service.status` metric for service state representation.

‎windows_service/datadog_checks/windows_service/windows_service.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ def check(self, instance):
416416
tags.append('service:{}'.format(reported_name))
417417

418418
self.service_check(self.SERVICE_CHECK_NAME, status, tags=tags)
419+
self.gauge('windows_service.status', status, tags=tags)
419420
self.log.debug('service state for %s %s', service_name, status)
420421
self.gauge('windows_service.uptime', service_uptime, tags=tags)
421422
# Send 1 for windows_service.state so the user can sum by the windows_service_state tag
@@ -443,6 +444,7 @@ def check(self, instance):
443444
tags.append('service:{}'.format(service))
444445

445446
self.service_check(self.SERVICE_CHECK_NAME, status, tags=tags)
447+
self.gauge('windows_service.status', status, tags=tags)
446448
self.log.debug('service state for %s %s', service, status)
447449
self.gauge('windows_service.uptime', 0, tags=tags)
448450
self.gauge('windows_service.state', 1, tags=tags)

‎windows_service/metadata.csv‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
metric_name,metric_type,interval,unit_name,per_unit_name,description,orientation,integration,short_name,curated_metric,sample_tags
22
windows_service.restarts,count,,event,,The number of restarts of the host process of the Windows service,0,windows_service,restarts,,
33
windows_service.state,gauge,,service,,Sum by state to count the number of services in each state,0,windows_service,state,,
4+
windows_service.status,gauge,,,,"The status of the Windows service: 0 = running, 1 = pending or paused, 2 = stopped, 3 = unknown or not found. Uses the same values as the windows_service.state service check.",0,windows_service,status,,
45
windows_service.uptime,gauge,,second,,The uptime (in seconds) of the host process of the Windows service,0,windows_service,uptime,,

‎windows_service/tests/test_windows_service.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ def assert_service_check_and_metrics(aggregator, services):
3131
tags=service.tags,
3232
count=service.count,
3333
)
34+
aggregator.assert_metric(
35+
'windows_service.status',
36+
tags=service.tags,
37+
value=service.check_status,
38+
count=service.count,
39+
)
3440
aggregator.assert_metric(
3541
'windows_service.uptime',
3642
tags=service.tags,

0 commit comments

Comments
 (0)