Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[disk] Fix tag_by_label when used together with use_mount #10418

Merged
merged 2 commits into from
Oct 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions disk/datadog_checks/disk/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def check(self, _):
if self._tag_by_label and Platform.is_linux():
self.devices_label = self._get_devices_label()

self._valid_disks = {}
for part in psutil.disk_partitions(all=self._include_all_devices):
# we check all exclude conditions
if self.exclude_disk(part):
Expand Down Expand Up @@ -148,8 +147,6 @@ def check(self, _):
self.log.info('Excluding device %s with total disk size %s', part.device, disk_usage.total)
continue

# For later, latency metrics
self._valid_disks[part.device] = (part.fstype, part.mountpoint)
self.log.debug('Passed: %s', part.device)

device_name = part.mountpoint if self._use_mount else part.device
Expand All @@ -162,8 +159,10 @@ def check(self, _):
if regex.match(device_name):
tags.extend(device_tags)

if self.devices_label.get(device_name):
tags.extend(self.devices_label.get(device_name))
# apply device labels as tags (from blkid or lsblk).
# we want to use the real device name and not the device_name (which can be the mountpoint)
if self.devices_label.get(part.device):
tags.extend(self.devices_label.get(part.device))

# legacy check names c: vs psutil name C:\\
if Platform.is_win32():
Expand Down