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

Add OSD metadata tags #14201

Merged
merged 6 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions ceph/datadog_checks/ceph/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _collect_raw(self, ceph_cmd, ceph_cluster, instance):
ceph_args = '{} --cluster {}'.format(ceph_args, ceph_cluster)

raw = {}
for cmd in ('mon_status', 'status', 'df detail', 'osd pool stats', 'osd perf', 'health detail'):
for cmd in ('mon_status', 'status', 'df detail', 'osd pool stats', 'osd perf', 'health detail', 'osd metadata'):
try:
args = '{} {} -fjson'.format(ceph_args, cmd)
output, _, _ = get_subprocess_output(args.split(), self.log)
Expand Down Expand Up @@ -109,9 +109,20 @@ def _publish(self, raw, func, keyspec, tags):
def _extract_metrics(self, raw, tags):
try:
raw_osd_perf = raw.get('osd_perf', {}).get('osdstats', raw.get('osd_perf'))
osd_tags = {
metadata['id']: [
'ceph_osd_objectstore:%s' % metadata["osd_objectstore"],
'ceph_osd_device:%s' % metadata["devices"],
'ceph_osd_device_id:%s' % metadata["device_ids"],
'ceph_osd_device_class:%s' % metadata["default_device_class"],
'ceph_version:%s' % metadata["ceph_version_short"],
'ceph_release:%s' % metadata["ceph_release"],
]
for metadata in raw.get('osd_metadata', [])
}

for osdperf in raw_osd_perf['osd_perf_infos']:
local_tags = tags + ['ceph_osd:osd%s' % osdperf['id']]
local_tags = tags + ['ceph_osd:osd%s' % osdperf["id"]] + osd_tags.get(osdperf['id'], [])
self._publish(osdperf, self.gauge, ['perf_stats', 'apply_latency_ms'], local_tags)
self._publish(osdperf, self.gauge, ['perf_stats', 'commit_latency_ms'], local_tags)
except (KeyError, TypeError):
Expand Down
136 changes: 135 additions & 1 deletion ceph/tests/fixtures/raw.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,139 @@
"ceph2",
"ceph3"
]
}
},
"osd_metadata": [
{
"id": 0,
"arch": "aarch64",
"back_addr": "[v2:172.17.0.3:6802/215,v1:172.17.0.3:6803/215]",
"back_iface": "eth0",
"bluefs": "1",
"bluefs_dedicated_db": "0",
"bluefs_dedicated_wal": "0",
"bluefs_single_shared_device": "1",
"bluestore_bdev_access_mode": "file",
"bluestore_bdev_block_size": "4096",
"bluestore_bdev_driver": "KernelDevice",
"bluestore_bdev_path": "/var/lib/ceph/osd/ceph-0/block",
"bluestore_bdev_rotational": "1",
"bluestore_bdev_size": "107374182400",
"bluestore_bdev_support_discard": "0",
"bluestore_bdev_type": "hdd",
"ceph_release": "octopus",
"ceph_version": "ceph version 15.2.8 (bdf3eebcd22d7d0b3dd4d5501bee5bac354d5b55) octopus (stable)",
"ceph_version_short": "15.2.8",
"default_device_class": "hdd",
"device_ids": "disk0",
"device_paths": "/dev/sda",
"devices": "/dev/sda",
"distro": "centos",
"distro_description": "CentOS Linux 8",
"distro_version": "8",
"front_addr": "[v2:172.17.0.3:6800/215,v1:172.17.0.3:6801/215]",
"front_iface": "eth0",
"hb_back_addr": "[v2:172.17.0.3:6806/215,v1:172.17.0.3:6807/215]",
"hb_front_addr": "[v2:172.17.0.3:6804/215,v1:172.17.0.3:6805/215]",
"hostname": "9f8cbfd06535",
"journal_rotational": "1",
"kernel_description": "#1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022",
"kernel_version": "5.15.49-linuxkit",
"mem_swap_kb": "1048572",
"mem_total_kb": "8038896",
"network_numa_unknown_ifaces": "eth0",
"os": "Linux",
"osd_data": "/var/lib/ceph/osd/ceph-0",
"osd_objectstore": "bluestore",
"osdspec_affinity": "",
"rotational": "1"
},
{
"id": 1,
"arch": "aarch64",
"back_addr": "[v2:172.17.0.3:6802/215,v1:172.17.0.3:6803/215]",
"back_iface": "eth0",
"bluefs": "1",
"bluefs_dedicated_db": "0",
"bluefs_dedicated_wal": "0",
"bluefs_single_shared_device": "1",
"bluestore_bdev_access_mode": "file",
"bluestore_bdev_block_size": "4096",
"bluestore_bdev_driver": "KernelDevice",
"bluestore_bdev_path": "/var/lib/ceph/osd/ceph-0/block",
"bluestore_bdev_rotational": "1",
"bluestore_bdev_size": "107374182400",
"bluestore_bdev_support_discard": "0",
"bluestore_bdev_type": "hdd",
"ceph_release": "octopus",
"ceph_version": "ceph version 15.2.8 (bdf3eebcd22d7d0b3dd4d5501bee5bac354d5b55) octopus (stable)",
"ceph_version_short": "15.2.8",
"default_device_class": "hdd",
"device_ids": "disk1",
"device_paths": "/dev/sdb",
"devices": "/dev/sdb",
"distro": "centos",
"distro_description": "CentOS Linux 8",
"distro_version": "8",
"front_addr": "[v2:172.17.0.3:6800/215,v1:172.17.0.3:6801/215]",
"front_iface": "eth0",
"hb_back_addr": "[v2:172.17.0.3:6806/215,v1:172.17.0.3:6807/215]",
"hb_front_addr": "[v2:172.17.0.3:6804/215,v1:172.17.0.3:6805/215]",
"hostname": "9f8cbfd06535",
"journal_rotational": "1",
"kernel_description": "#1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022",
"kernel_version": "5.15.49-linuxkit",
"mem_swap_kb": "1048572",
"mem_total_kb": "8038896",
"network_numa_unknown_ifaces": "eth0",
"os": "Linux",
"osd_data": "/var/lib/ceph/osd/ceph-0",
"osd_objectstore": "bluestore",
"osdspec_affinity": "",
"rotational": "1"
},
{
"id": 2,
"arch": "aarch64",
"back_addr": "[v2:172.17.0.3:6802/215,v1:172.17.0.3:6803/215]",
"back_iface": "eth0",
"bluefs": "1",
"bluefs_dedicated_db": "0",
"bluefs_dedicated_wal": "0",
"bluefs_single_shared_device": "1",
"bluestore_bdev_access_mode": "file",
"bluestore_bdev_block_size": "4096",
"bluestore_bdev_driver": "KernelDevice",
"bluestore_bdev_path": "/var/lib/ceph/osd/ceph-0/block",
"bluestore_bdev_rotational": "1",
"bluestore_bdev_size": "107374182400",
"bluestore_bdev_support_discard": "0",
"bluestore_bdev_type": "hdd",
"ceph_release": "octopus",
"ceph_version": "ceph version 15.2.8 (bdf3eebcd22d7d0b3dd4d5501bee5bac354d5b55) octopus (stable)",
"ceph_version_short": "15.2.8",
"default_device_class": "hdd",
"device_ids": "disk2",
"device_paths": "/dev/sdc",
"devices": "/dev/sdc",
"distro": "centos",
"distro_description": "CentOS Linux 8",
"distro_version": "8",
"front_addr": "[v2:172.17.0.3:6800/215,v1:172.17.0.3:6801/215]",
"front_iface": "eth0",
"hb_back_addr": "[v2:172.17.0.3:6806/215,v1:172.17.0.3:6807/215]",
"hb_front_addr": "[v2:172.17.0.3:6804/215,v1:172.17.0.3:6805/215]",
"hostname": "9f8cbfd06535",
"journal_rotational": "1",
"kernel_description": "#1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022",
"kernel_version": "5.15.49-linuxkit",
"mem_swap_kb": "1048572",
"mem_total_kb": "8038896",
"network_numa_unknown_ifaces": "eth0",
"os": "Linux",
"osd_data": "/var/lib/ceph/osd/ceph-0",
"osd_objectstore": "bluestore",
"osdspec_affinity": "",
"rotational": "1"
}
]
}
136 changes: 135 additions & 1 deletion ceph/tests/fixtures/raw2.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,139 @@
"ceph2",
"ceph3"
]
}
},
"osd_metadata": [
{
"id": 0,
"arch": "aarch64",
"back_addr": "[v2:172.17.0.3:6802/215,v1:172.17.0.3:6803/215]",
"back_iface": "eth0",
"bluefs": "1",
"bluefs_dedicated_db": "0",
"bluefs_dedicated_wal": "0",
"bluefs_single_shared_device": "1",
"bluestore_bdev_access_mode": "file",
"bluestore_bdev_block_size": "4096",
"bluestore_bdev_driver": "KernelDevice",
"bluestore_bdev_path": "/var/lib/ceph/osd/ceph-0/block",
"bluestore_bdev_rotational": "1",
"bluestore_bdev_size": "107374182400",
"bluestore_bdev_support_discard": "0",
"bluestore_bdev_type": "hdd",
"ceph_release": "octopus",
"ceph_version": "ceph version 15.2.8 (bdf3eebcd22d7d0b3dd4d5501bee5bac354d5b55) octopus (stable)",
"ceph_version_short": "15.2.8",
"default_device_class": "hdd",
"device_ids": "disk0",
"device_paths": "/dev/sda",
"devices": "/dev/sda",
"distro": "centos",
"distro_description": "CentOS Linux 8",
"distro_version": "8",
"front_addr": "[v2:172.17.0.3:6800/215,v1:172.17.0.3:6801/215]",
"front_iface": "eth0",
"hb_back_addr": "[v2:172.17.0.3:6806/215,v1:172.17.0.3:6807/215]",
"hb_front_addr": "[v2:172.17.0.3:6804/215,v1:172.17.0.3:6805/215]",
"hostname": "9f8cbfd06535",
"journal_rotational": "1",
"kernel_description": "#1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022",
"kernel_version": "5.15.49-linuxkit",
"mem_swap_kb": "1048572",
"mem_total_kb": "8038896",
"network_numa_unknown_ifaces": "eth0",
"os": "Linux",
"osd_data": "/var/lib/ceph/osd/ceph-0",
"osd_objectstore": "bluestore",
"osdspec_affinity": "",
"rotational": "1"
},
{
"id": 1,
"arch": "aarch64",
"back_addr": "[v2:172.17.0.3:6802/215,v1:172.17.0.3:6803/215]",
"back_iface": "eth0",
"bluefs": "1",
"bluefs_dedicated_db": "0",
"bluefs_dedicated_wal": "0",
"bluefs_single_shared_device": "1",
"bluestore_bdev_access_mode": "file",
"bluestore_bdev_block_size": "4096",
"bluestore_bdev_driver": "KernelDevice",
"bluestore_bdev_path": "/var/lib/ceph/osd/ceph-0/block",
"bluestore_bdev_rotational": "1",
"bluestore_bdev_size": "107374182400",
"bluestore_bdev_support_discard": "0",
"bluestore_bdev_type": "hdd",
"ceph_release": "octopus",
"ceph_version": "ceph version 15.2.8 (bdf3eebcd22d7d0b3dd4d5501bee5bac354d5b55) octopus (stable)",
"ceph_version_short": "15.2.8",
"default_device_class": "hdd",
"device_ids": "disk1",
"device_paths": "/dev/sdb",
"devices": "/dev/sdb",
"distro": "centos",
"distro_description": "CentOS Linux 8",
"distro_version": "8",
"front_addr": "[v2:172.17.0.3:6800/215,v1:172.17.0.3:6801/215]",
"front_iface": "eth0",
"hb_back_addr": "[v2:172.17.0.3:6806/215,v1:172.17.0.3:6807/215]",
"hb_front_addr": "[v2:172.17.0.3:6804/215,v1:172.17.0.3:6805/215]",
"hostname": "9f8cbfd06535",
"journal_rotational": "1",
"kernel_description": "#1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022",
"kernel_version": "5.15.49-linuxkit",
"mem_swap_kb": "1048572",
"mem_total_kb": "8038896",
"network_numa_unknown_ifaces": "eth0",
"os": "Linux",
"osd_data": "/var/lib/ceph/osd/ceph-0",
"osd_objectstore": "bluestore",
"osdspec_affinity": "",
"rotational": "1"
},
{
"id": 2,
"arch": "aarch64",
"back_addr": "[v2:172.17.0.3:6802/215,v1:172.17.0.3:6803/215]",
"back_iface": "eth0",
"bluefs": "1",
"bluefs_dedicated_db": "0",
"bluefs_dedicated_wal": "0",
"bluefs_single_shared_device": "1",
"bluestore_bdev_access_mode": "file",
"bluestore_bdev_block_size": "4096",
"bluestore_bdev_driver": "KernelDevice",
"bluestore_bdev_path": "/var/lib/ceph/osd/ceph-0/block",
"bluestore_bdev_rotational": "1",
"bluestore_bdev_size": "107374182400",
"bluestore_bdev_support_discard": "0",
"bluestore_bdev_type": "hdd",
"ceph_release": "octopus",
"ceph_version": "ceph version 15.2.8 (bdf3eebcd22d7d0b3dd4d5501bee5bac354d5b55) octopus (stable)",
"ceph_version_short": "15.2.8",
"default_device_class": "hdd",
"device_ids": "disk2",
"device_paths": "/dev/sdc",
"devices": "/dev/sdc",
"distro": "centos",
"distro_description": "CentOS Linux 8",
"distro_version": "8",
"front_addr": "[v2:172.17.0.3:6800/215,v1:172.17.0.3:6801/215]",
"front_iface": "eth0",
"hb_back_addr": "[v2:172.17.0.3:6806/215,v1:172.17.0.3:6807/215]",
"hb_front_addr": "[v2:172.17.0.3:6804/215,v1:172.17.0.3:6805/215]",
"hostname": "9f8cbfd06535",
"journal_rotational": "1",
"kernel_description": "#1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022",
"kernel_version": "5.15.49-linuxkit",
"mem_swap_kb": "1048572",
"mem_total_kb": "8038896",
"network_numa_unknown_ifaces": "eth0",
"os": "Linux",
"osd_data": "/var/lib/ceph/osd/ceph-0",
"osd_objectstore": "bluestore",
"osdspec_affinity": "",
"rotational": "1"
}
]
}
31 changes: 29 additions & 2 deletions ceph/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@

EXPECTED_TAGS = ['ceph_fsid:e0efcf84-e8ed-4916-8ce1-9c70242d390a', 'ceph_mon_state:peon', 'optional:tag1']

OSD_SPECIFIC_TAGS = {
'osd0': [
'ceph_osd_device:/dev/sda',
'ceph_osd_device_class:hdd',
'ceph_osd_device_id:disk0',
'ceph_osd_objectstore:bluestore',
'ceph_release:octopus',
'ceph_version:15.2.8',
],
'osd1': [
'ceph_osd_device:/dev/sdb',
'ceph_osd_device_class:hdd',
'ceph_osd_device_id:disk1',
'ceph_osd_objectstore:bluestore',
'ceph_release:octopus',
'ceph_version:15.2.8',
],
'osd2': [
'ceph_osd_device:/dev/sdc',
'ceph_osd_device_class:hdd',
'ceph_osd_device_id:disk2',
'ceph_osd_objectstore:bluestore',
'ceph_release:octopus',
'ceph_version:15.2.8',
],
}

pytestmark = pytest.mark.unit


Expand Down Expand Up @@ -96,7 +123,7 @@ def test_tagged_metrics(_, aggregator):
ceph_check.check({})

for osd in ['osd0', 'osd1', 'osd2']:
expected_tags = EXPECTED_TAGS + ['ceph_osd:%s' % osd]
expected_tags = EXPECTED_TAGS + ['ceph_osd:%s' % osd] + OSD_SPECIFIC_TAGS[osd]

for metric in ['ceph.commit_latency_ms', 'ceph.apply_latency_ms']:
aggregator.assert_metric(metric, count=1, tags=expected_tags)
Expand All @@ -115,7 +142,7 @@ def test_osd_perf_with_osdstats(_, aggregator):
ceph_check.check({})

for osd in ['osd0', 'osd1', 'osd2']:
expected_tags = EXPECTED_TAGS + ['ceph_osd:%s' % osd]
expected_tags = EXPECTED_TAGS + ['ceph_osd:%s' % osd] + OSD_SPECIFIC_TAGS[osd]

for metric in ['ceph.commit_latency_ms', 'ceph.apply_latency_ms']:
aggregator.assert_metric(metric, count=1, tags=expected_tags)
Expand Down