Skip to content

Commit 05c8c25

Browse files
ofekmgarabed
authored andcommitted
Add options for global exclusion patterns (#7648)
* Add options for global exclusion patterns * address
1 parent 8034744 commit 05c8c25

3 files changed

Lines changed: 66 additions & 6 deletions

File tree

disk/assets/configuration/spec.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ files:
44
example_name: conf.yaml.default
55
options:
66
- template: init_config
7+
options:
8+
- name: file_system_global_blacklist
9+
description: |
10+
Instruct the check to always add these patterns to `file_system_blacklist`.
11+
value:
12+
example:
13+
- iso9660$
14+
type: array
15+
items:
16+
type: string
17+
- name: device_global_blacklist
18+
description: |
19+
Instruct the check to always add these patterns to `device_blacklist`.
20+
value:
21+
example: []
22+
type: array
23+
items:
24+
type: string
25+
- name: mount_point_global_blacklist
26+
description: |
27+
Instruct the check to always add these patterns to `mount_point_blacklist`.
28+
value:
29+
example: []
30+
type: array
31+
items:
32+
type: string
733
- template: instances
834
options:
935
- name: use_mount
@@ -23,7 +49,7 @@ files:
2349
- name: file_system_whitelist
2450
description: |
2551
Instruct the check to only collect from matching file systems.
26-
52+
2753
Character casing is ignored. For convenience, the regular expressions
2854
start matching from the beginning and therefore to match anywhere you
2955
must prepend `.*`. For exact matches append `$`.

disk/datadog_checks/disk/data/conf.yaml.default

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
## All options defined here are available to all instances.
22
#
3-
# init_config: {}
3+
init_config:
4+
5+
## @param file_system_global_blacklist - list of strings - optional
6+
## Instruct the check to always add these patterns to `file_system_blacklist`.
7+
#
8+
# file_system_global_blacklist:
9+
# - iso9660$
10+
11+
## @param device_global_blacklist - list of strings - optional
12+
## Instruct the check to always add these patterns to `device_blacklist`.
13+
#
14+
# device_global_blacklist: []
15+
16+
## @param mount_point_global_blacklist - list of strings - optional
17+
## Instruct the check to always add these patterns to `mount_point_blacklist`.
18+
#
19+
# mount_point_global_blacklist: []
420

521
## Every instance is scheduled independent of the others.
622
#

disk/datadog_checks/disk/disk.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,13 @@ def collect_latency_metrics(self):
292292
self.log.debug('Latency metrics not collected for %s: %s', disk_name, e)
293293

294294
def _compile_pattern_filters(self, instance):
295-
# Force exclusion of CDROM (iso9660)
296-
file_system_blacklist_extras = ['iso9660$']
297-
device_blacklist_extras = []
298-
mount_point_blacklist_extras = []
295+
file_system_blacklist_extras = self.init_config.get(
296+
'file_system_global_blacklist', self.get_default_file_system_blacklist()
297+
)
298+
device_blacklist_extras = self.init_config.get('device_global_blacklist', self.get_default_device_blacklist())
299+
mount_point_blacklist_extras = self.init_config.get(
300+
'mount_point_global_blacklist', self.get_default_mount_mount_blacklist()
301+
)
299302

300303
deprecation_message = '`%s` is deprecated and will be removed in a future release. Please use `%s` instead.'
301304

@@ -421,3 +424,18 @@ def _get_devices_label_from_blkid_cache(self):
421424
)
422425

423426
return devices_label
427+
428+
@staticmethod
429+
def get_default_file_system_blacklist():
430+
return [
431+
# CDROM
432+
'iso9660$',
433+
]
434+
435+
@staticmethod
436+
def get_default_device_blacklist():
437+
return []
438+
439+
@staticmethod
440+
def get_default_mount_mount_blacklist():
441+
return []

0 commit comments

Comments
 (0)