diff -Nru prometheus-2.24.1+ds/debian/changelog prometheus-2.24.1+ds/debian/changelog --- prometheus-2.24.1+ds/debian/changelog 2021-05-27 13:13:41.000000000 +0300 +++ prometheus-2.24.1+ds/debian/changelog 2023-07-09 16:38:43.000000000 +0300 @@ -1,3 +1,10 @@ +prometheus (2.24.1+ds-1+wmf2) bullseye-wikimedia; urgency=medium + + * Cherry-pick a patch from the upstream repository to add support + for filtering OpenStack service discovery targets by the image ID. + + -- Taavi Väänänen Sun, 09 Jul 2023 16:38:43 +0300 + prometheus (2.24.1+ds-1+wmf1) wikimedia-bullseye; urgency=medium * Enable k8s support and its vendoring diff -Nru prometheus-2.24.1+ds/debian/patches/openstack-label.patch prometheus-2.24.1+ds/debian/patches/openstack-label.patch --- prometheus-2.24.1+ds/debian/patches/openstack-label.patch 1970-01-01 02:00:00.000000000 +0200 +++ prometheus-2.24.1+ds/debian/patches/openstack-label.patch 2023-07-05 10:35:25.000000000 +0300 @@ -0,0 +1,83 @@ +From 0f4c27e2bf4ba28707f96df18486165688341e79 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Taavi=20V=C3=A4=C3=A4n=C3=A4nen?= +Date: Fri, 30 Jun 2023 23:12:24 +0300 +Subject: [PATCH] discovery/openstack: Include instance image ID in labels +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Adds a new label to include the ID of the image that an instance is +using. This can be used for example to filter a job to only include +instances using a certain image as that image includes some exporter. + +Sometimes the image information isn't available, such as when the image +is private and the user doesn't have the roles required to see it. In +those cases we just don't set the label, as the rest of the information +from the discovery provider can still be used. + +Signed-off-by: Taavi Väänänen +--- + discovery/openstack/instance.go | 11 +++++++++-- + discovery/openstack/instance_test.go | 2 ++ + docs/configuration/configuration.md | 1 + + 3 files changed, 12 insertions(+), 2 deletions(-) + +--- a/discovery/openstack/instance.go ++++ b/discovery/openstack/instance.go +@@ -37,6 +37,7 @@ + openstackLabelAddressPool = openstackLabelPrefix + "address_pool" + openstackLabelInstanceFlavor = openstackLabelPrefix + "instance_flavor" + openstackLabelInstanceID = openstackLabelPrefix + "instance_id" ++ openstackLabelInstanceImage = openstackLabelPrefix + "instance_image" + openstackLabelInstanceName = openstackLabelPrefix + "instance_name" + openstackLabelInstanceStatus = openstackLabelPrefix + "instance_status" + openstackLabelPrivateIP = openstackLabelPrefix + "private_ip" +@@ -142,12 +143,18 @@ + openstackLabelUserID: model.LabelValue(s.UserID), + } + +- id, ok := s.Flavor["id"].(string) ++ flavorId, ok := s.Flavor["id"].(string) + if !ok { + level.Warn(i.logger).Log("msg", "Invalid type for flavor id, expected string") + continue + } +- labels[openstackLabelInstanceFlavor] = model.LabelValue(id) ++ labels[openstackLabelInstanceFlavor] = model.LabelValue(flavorId) ++ ++ imageId, ok := s.Image["id"].(string) ++ if ok { ++ labels[openstackLabelInstanceImage] = model.LabelValue(imageId) ++ } ++ + for k, v := range s.Metadata { + name := strutil.SanitizeLabelName(k) + labels[openstackLabelTagPrefix+model.LabelName(name)] = model.LabelValue(v) +--- a/discovery/openstack/instance_test.go ++++ b/discovery/openstack/instance_test.go +@@ -74,6 +74,7 @@ + "__address__": model.LabelValue("10.0.0.32:0"), + "__meta_openstack_instance_flavor": model.LabelValue("1"), + "__meta_openstack_instance_id": model.LabelValue("ef079b0c-e610-4dfb-b1aa-b49f07ac48e5"), ++ "__meta_openstack_instance_image": model.LabelValue("f90f6034-2570-4974-8351-6b49732ef2eb"), + "__meta_openstack_instance_status": model.LabelValue("ACTIVE"), + "__meta_openstack_instance_name": model.LabelValue("herp"), + "__meta_openstack_private_ip": model.LabelValue("10.0.0.32"), +@@ -86,6 +87,7 @@ + "__address__": model.LabelValue("10.0.0.31:0"), + "__meta_openstack_instance_flavor": model.LabelValue("1"), + "__meta_openstack_instance_id": model.LabelValue("9e5476bd-a4ec-4653-93d6-72c93aa682ba"), ++ "__meta_openstack_instance_image": model.LabelValue("f90f6034-2570-4974-8351-6b49732ef2eb"), + "__meta_openstack_instance_status": model.LabelValue("ACTIVE"), + "__meta_openstack_instance_name": model.LabelValue("derp"), + "__meta_openstack_private_ip": model.LabelValue("10.0.0.31"), +--- a/docs/configuration/configuration.md ++++ b/docs/configuration/configuration.md +@@ -748,6 +748,7 @@ + * `__meta_openstack_address_pool`: the pool of the private IP. + * `__meta_openstack_instance_flavor`: the flavor of the OpenStack instance. + * `__meta_openstack_instance_id`: the OpenStack instance ID. ++* `__meta_openstack_instance_image`: the ID of the image the OpenStack instance is using. + * `__meta_openstack_instance_name`: the OpenStack instance name. + * `__meta_openstack_instance_status`: the status of the OpenStack instance. + * `__meta_openstack_private_ip`: the private IP of the OpenStack instance. diff -Nru prometheus-2.24.1+ds/debian/patches/series prometheus-2.24.1+ds/debian/patches/series --- prometheus-2.24.1+ds/debian/patches/series 2021-05-27 13:13:41.000000000 +0300 +++ prometheus-2.24.1+ds/debian/patches/series 2023-07-09 16:38:41.000000000 +0300 @@ -12,3 +12,4 @@ add_vendor_k8s_io.patch add_vendor_k8s_deps.patch add_evanphx_json_patch.patch +openstack-label.patch