mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-26 13:11:11 -08:00
Merge pull request #12502 from supertassu/taavi/os-flavor-id
discovery/openstack: Include instance image ID in labels
This commit is contained in:
commit
4235d9f558
|
@ -36,6 +36,7 @@ const (
|
|||
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"
|
||||
|
@ -144,12 +145,18 @@ func (i *InstanceDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group,
|
|||
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)
|
||||
|
|
|
@ -73,6 +73,7 @@ func TestOpenstackSDInstanceRefresh(t *testing.T) {
|
|||
"__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"),
|
||||
|
@ -85,6 +86,7 @@ func TestOpenstackSDInstanceRefresh(t *testing.T) {
|
|||
"__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"),
|
||||
|
|
|
@ -1276,6 +1276,7 @@ The following meta labels are available on targets during [relabeling](#relabel_
|
|||
* `__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.
|
||||
|
|
Loading…
Reference in a new issue