Skip to content

Commit

Permalink
[PLINT-366] Adding glance image up and size metrics (#17454)
Browse files Browse the repository at this point in the history
* adding metric openstack.glance.image.up

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

* adding metric openstack.glance.image.bytes

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

* adding image id as a tag

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

* lint

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

* removing openstack.glance.image.bytes

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

* adding openstack.glance.image.size

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

* removing redundant disable glance metrics test

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

* implementing suggestions

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

* addressing more comments

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>

---------

Signed-off-by: rahulkaukuntla <rahul.kaukuntla@datadoghq.com>
  • Loading branch information
rahulkaukuntla committed Apr 29, 2024
1 parent 98df298 commit 24f62e7
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from datadog_checks.openstack_controller.components.component import Component
from datadog_checks.openstack_controller.metrics import (
GLANCE_IMAGE_COUNT,
GLANCE_IMAGE_METRICS,
GLANCE_IMAGE_PREFIX,
GLANCE_IMAGE_TAGS,
GLANCE_METRICS_PREFIX,
GLANCE_RESPONSE_TIME,
GLANCE_SERVICE_CHECK,
get_metrics_and_tags,
Expand Down Expand Up @@ -40,8 +41,14 @@ def _report_images(self, config, tags):
image = get_metrics_and_tags(
item,
tags=GLANCE_IMAGE_TAGS,
prefix=GLANCE_METRICS_PREFIX,
metrics=[GLANCE_IMAGE_COUNT],
prefix=GLANCE_IMAGE_PREFIX,
metrics=GLANCE_IMAGE_METRICS,
lambda_name=lambda key: 'up' if key == 'status' else key,
lambda_value=lambda key, value, item=item: (
item['status'] == 'active' if key == 'status' else value
),
)
self.check.log.debug("image: %s", image)
self.check.gauge(GLANCE_IMAGE_COUNT, 1, tags=tags + image['tags'])
for metric, value in image['metrics'].items():
self.check.gauge(metric, value, tags=tags + image['tags'])
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,14 @@
GLANCE_METRICS_PREFIX = "openstack.glance"
GLANCE_SERVICE_CHECK = f"{GLANCE_METRICS_PREFIX}.api.up"
GLANCE_RESPONSE_TIME = f"{GLANCE_METRICS_PREFIX}.response_time"
GLANCE_IMAGE_COUNT = f"{GLANCE_METRICS_PREFIX}.image.count"
GLANCE_IMAGE_PREFIX = f"{GLANCE_METRICS_PREFIX}.image"
GLANCE_IMAGE_COUNT = f"{GLANCE_IMAGE_PREFIX}.count"
GLANCE_IMAGE_METRICS = {
f"{GLANCE_IMAGE_PREFIX}.up": {},
f"{GLANCE_IMAGE_PREFIX}.size": {},
}
GLANCE_IMAGE_TAGS = {
'id': 'image_id',
'name': 'image_name',
'status': 'status',
'container_format': 'container_format',
Expand Down
2 changes: 2 additions & 0 deletions openstack_controller/metadata.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
metric_name,metric_type,interval,unit_name,per_unit_name,description,orientation,integration,short_name,curated_metric
openstack.cinder.response_time,gauge,,millisecond,,Duration that an HTTP request takes to complete when making a request to cinder endpoint,0,openstack_controller,cinder response time,
openstack.glance.image.count,gauge,,,,Number of public virtual machine images,0,openstack_controller,glance image ct,
openstack.glance.image.size,gauge,,,,Size of image file in bytes,0,openstack_controller,glance image size,
openstack.glance.image.up,gauge,,,,Whether a glance image is up,0,openstack_controller,glance image up,
openstack.glance.response_time,gauge,,millisecond,,Duration that an HTTP request takes to complete when making a request to glance endpoint,0,openstack_controller,glance response time,
openstack.ironic.conductor.count,gauge,,,,Number of ironic conductors,0,openstack_controller,ironic conductor ct,
openstack.ironic.conductor.up,gauge,,,,Whether an ironic conductor is up,0,openstack_controller,ironic conductor up,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"images": [
{
"hw_rng_model": "virtio",
"owner_specified.openstack.md5": "",
"owner_specified.openstack.object": "images/cirros-0.5.2-x86_64-disk",
"owner_specified.openstack.object": "images/cirros-1.5.2-x86_64-disk",
"owner_specified.openstack.sha256": "",
"name": "cirros-0.5.2-x86_64-disk",
"owner_specified.openstack.md5": "",
"hw_rng_model": "virtio",
"name": "cirros-1.5.2-x86_64-disk",
"disk_format": "qcow2",
"container_format": "bare",
"visibility": "public",
"size": 16300544,
"virtual_size": 117440512,
"size": 46310543,
"virtual_size": 217940522,
"status": "active",
"checksum": "b874c39491a2377b8490f5f1e89761a4",
"checksum": "b873c39491a1377c8490f5f1e89261a9",
"protected": false,
"min_ram": 0,
"min_disk": 0,
"owner": "c09ccb52462d49c89595d2194a367198",
"owner": "c09ccb52463d49c89595d2194a367298",
"os_hidden": false,
"os_hash_algo": "sha512",
"os_hash_value": "6b813aa46bb90b4da216a4d19376593fa3f4fc7e617f03a92b7fe11e9a3981cbe8f0959dbebe36225e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e869",
"os_hash_value": "7b813aa46bb90b4da216a4d19376593fa3f3fc7e617f03a92b7fe11e9a3981cbe9f0959dbebe36225e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e861",
"id": "a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc",
"created_at": "2023-10-18T15:03:09Z",
"updated_at": "2023-10-18T15:03:10Z",
"created_at": "2023-10-28T15:03:09Z",
"updated_at": "2023-10-28T15:03:10Z",
"tags": [],
"self": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc",
"file": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc/file",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
{
"images": [
{
"name": "cirros-1.5.2-x86_64-disk",
"owner_specified.openstack.object": "images/cirros-0.5.2-x86_64-disk",
"owner_specified.openstack.sha256": "",
"owner_specified.openstack.md5": "",
"hw_rng_model": "virtio",
"name": "cirros-0.5.2-x86_64-disk",
"disk_format": "qcow2",
"container_format": "bare",
"visibility": "public",
"size": 16338944,
"size": 16300544,
"virtual_size": 117440512,
"status": "active",
"checksum": "1d3062cd89af34e419f7100277f38b2b",
"checksum": "b874c39491a2377b8490f5f1e89761a4",
"protected": false,
"min_ram": 0,
"min_disk": 0,
"owner": "29b43a58176646e3870a9ea0b60fb7ad",
"owner": "c09ccb52462d49c89595d2194a367198",
"os_hidden": false,
"os_hash_algo": "sha512",
"os_hash_value": "553d220ed58cfee7dafe003c446a9f197ab5edf8ffc09396c74187cf83873c877e7ae041cb80f3b91489acf687183adcd689b53b38e3ddd22e627e7f98a09c46",
"os_hash_value": "6b813aa46bb90b4da216a4d19376593fa3f4fc7e617f03a92b7fe11e9a3981cbe8f0959dbebe36225e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e869",
"id": "28c293db-48c5-4c8b-a711-09b2c11fa8e5",
"created_at": "2024-02-28T20:31:08Z",
"updated_at": "2024-02-28T20:31:09Z",
"created_at": "2023-10-18T15:03:09Z",
"updated_at": "2023-10-18T15:03:10Z",
"tags": [],
"self": "/v2/images/28c293db-48c5-4c8b-a711-09b2c11fa8e5",
"file": "/v2/images/28c293db-48c5-4c8b-a711-09b2c11fa8e5/file",
"self": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc",
"file": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc/file",
"schema": "/v2/schemas/image"
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
{
"images": [
{
"owner_specified.openstack.object": "images/cirros-1.5.2-x86_64-disk",
"owner_specified.openstack.sha256": "",
"owner_specified.openstack.md5": "",
"hw_rng_model": "virtio",
"name": "cirros-1.5.2-x86_64-disk",
"disk_format": "qcow2",
"container_format": "bare",
"visibility": "public",
"size": 16338944,
"virtual_size": 117440512,
"size": 46310543,
"virtual_size": 217940522,
"status": "active",
"checksum": "1d3062cd89af34e419f7100277f38b2b",
"checksum": "b873c39491a1377c8490f5f1e89261a9",
"protected": false,
"min_ram": 0,
"min_disk": 0,
"owner": "29b43a58176646e3870a9ea0b60fb7ad",
"owner": "c09ccb52463d49c89595d2194a367298",
"os_hidden": false,
"os_hash_algo": "sha512",
"os_hash_value": "553d220ed58cfee7dafe003c446a9f197ab5edf8ffc09396c74187cf83873c877e7ae041cb80f3b91489acf687183adcd689b53b38e3ddd22e627e7f98a09c46",
"id": "28c293db-48c5-4c8b-a711-09b2c11fa8e5",
"created_at": "2024-02-28T20:31:08Z",
"updated_at": "2024-02-28T20:31:09Z",
"os_hash_value": "7b813aa46bb90b4da216a4d19376593fa3f3fc7e617f03a92b7fe11e9a3981cbe9f0959dbebe36225e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e861",
"id": "a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc",
"created_at": "2023-10-28T15:03:09Z",
"updated_at": "2023-10-28T15:03:10Z",
"tags": [],
"self": "/v2/images/28c293db-48c5-4c8b-a711-09b2c11fa8e5",
"file": "/v2/images/28c293db-48c5-4c8b-a711-09b2c11fa8e5/file",
"self": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc",
"file": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc/file",
"schema": "/v2/schemas/image"
},
{
Expand All @@ -44,7 +48,7 @@
"os_hidden": false,
"os_hash_algo": "sha512",
"os_hash_value": "6b813aa46bb90b4da216a4d19376593fa3f4fc7e617f03a92b7fe11e9a3981cbe8f0959dbebe36225e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e869",
"id": "a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc",
"id": "28c293db-48c5-4c8b-a711-09b2c11fa8e5",
"created_at": "2023-10-18T15:03:09Z",
"updated_at": "2023-10-18T15:03:10Z",
"tags": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,34 @@
"self": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc",
"file": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc/file",
"schema": "/v2/schemas/image"
},
{
"owner_specified.openstack.object": "images/cirros-0.5.2-x86_64-disk",
"owner_specified.openstack.sha256": "",
"owner_specified.openstack.md5": "",
"hw_rng_model": "virtio",
"name": "cirros-0.5.2-x86_64-disk",
"disk_format": "qcow2",
"container_format": "bare",
"visibility": "public",
"size": 16300544,
"virtual_size": 117440512,
"status": "active",
"checksum": "b874c39491a2377b8490f5f1e89761a4",
"protected": false,
"min_ram": 0,
"min_disk": 0,
"owner": "c09ccb52462d49c89595d2194a367198",
"os_hidden": false,
"os_hash_algo": "sha512",
"os_hash_value": "6b813aa46bb90b4da216a4d19376593fa3f4fc7e617f03a92b7fe11e9a3981cbe8f0959dbebe36225e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e869",
"id": "28c293db-48c5-4c8b-a711-09b2c11fa8e5",
"created_at": "2023-10-18T15:03:09Z",
"updated_at": "2023-10-18T15:03:10Z",
"tags": [],
"self": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc",
"file": "/v2/images/a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc/file",
"schema": "/v2/schemas/image"
}
],
"first": "/v2/images",
Expand Down
66 changes: 66 additions & 0 deletions openstack_controller/tests/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4555,9 +4555,75 @@
'hostname': '',
'tags': [
'container_format:bare',
'image_id:a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc',
'image_name:cirros-1.5.2-x86_64-disk',
'status:active',
'keystone_server:http://127.0.0.1:8080/identity',
],
},
{
'name': 'openstack.glance.image.size',
'count': 1,
'value': 46310543,
'hostname': '',
'tags': [
'container_format:bare',
'image_id:a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc',
'image_name:cirros-1.5.2-x86_64-disk',
'status:active',
'keystone_server:http://127.0.0.1:8080/identity',
],
},
{
'name': 'openstack.glance.image.up',
'count': 1,
'value': 1,
'hostname': '',
'tags': [
'container_format:bare',
'image_id:a4dcf3f7-e4d6-45d5-be2b-a939f2bbedfc',
'image_name:cirros-1.5.2-x86_64-disk',
'status:active',
'keystone_server:http://127.0.0.1:8080/identity',
],
},
{
'name': 'openstack.glance.image.count',
'count': 1,
'value': 1,
'hostname': '',
'tags': [
'container_format:bare',
'image_id:28c293db-48c5-4c8b-a711-09b2c11fa8e5',
'image_name:cirros-0.5.2-x86_64-disk',
'status:active',
'keystone_server:http://127.0.0.1:8080/identity',
],
},
{
'name': 'openstack.glance.image.size',
'count': 1,
'value': 16300544,
'hostname': '',
'tags': [
'container_format:bare',
'image_id:28c293db-48c5-4c8b-a711-09b2c11fa8e5',
'image_name:cirros-0.5.2-x86_64-disk',
'status:active',
'keystone_server:http://127.0.0.1:8080/identity',
],
},
{
'name': 'openstack.glance.image.up',
'count': 1,
'value': 1,
'hostname': '',
'tags': [
'container_format:bare',
'image_id:28c293db-48c5-4c8b-a711-09b2c11fa8e5',
'image_name:cirros-0.5.2-x86_64-disk',
'status:active',
'keystone_server:http://127.0.0.1:8080/identity',
],
},
]

0 comments on commit 24f62e7

Please sign in to comment.