mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
Merge pull request #8590 from roidelapluie/scaleway-more-labels
Scaleway SD: Add more labels to the instance role
This commit is contained in:
commit
228d23f377
|
@ -34,17 +34,28 @@ import (
|
||||||
const (
|
const (
|
||||||
instanceLabelPrefix = metaLabelPrefix + "instance_"
|
instanceLabelPrefix = metaLabelPrefix + "instance_"
|
||||||
|
|
||||||
|
instanceBootTypeLabel = instanceLabelPrefix + "boot_type"
|
||||||
|
instanceHostnameLabel = instanceLabelPrefix + "hostname"
|
||||||
instanceIDLabel = instanceLabelPrefix + "id"
|
instanceIDLabel = instanceLabelPrefix + "id"
|
||||||
instancePrivateIPv4 = instanceLabelPrefix + "private_ipv4"
|
instanceImageArchLabel = instanceLabelPrefix + "image_arch"
|
||||||
instancePublicIPv4 = instanceLabelPrefix + "public_ipv4"
|
instanceImageIDLabel = instanceLabelPrefix + "image_id"
|
||||||
instancePublicIPv6 = instanceLabelPrefix + "public_ipv6"
|
|
||||||
instanceImageNameLabel = instanceLabelPrefix + "image_name"
|
instanceImageNameLabel = instanceLabelPrefix + "image_name"
|
||||||
|
instanceLocationClusterID = instanceLabelPrefix + "location_cluster_id"
|
||||||
|
instanceLocationHypervisorID = instanceLabelPrefix + "location_hypervisor_id"
|
||||||
|
instanceLocationNodeID = instanceLabelPrefix + "location_node_id"
|
||||||
instanceNameLabel = instanceLabelPrefix + "name"
|
instanceNameLabel = instanceLabelPrefix + "name"
|
||||||
|
instanceOrganizationLabel = instanceLabelPrefix + "organization_id"
|
||||||
|
instancePrivateIPv4Label = instanceLabelPrefix + "private_ipv4"
|
||||||
instanceProjectLabel = instanceLabelPrefix + "project_id"
|
instanceProjectLabel = instanceLabelPrefix + "project_id"
|
||||||
|
instancePublicIPv4Label = instanceLabelPrefix + "public_ipv4"
|
||||||
|
instancePublicIPv6Label = instanceLabelPrefix + "public_ipv6"
|
||||||
|
instanceSecurityGroupIDLabel = instanceLabelPrefix + "security_group_id"
|
||||||
|
instanceSecurityGroupNameLabel = instanceLabelPrefix + "security_group_name"
|
||||||
instanceStateLabel = instanceLabelPrefix + "status"
|
instanceStateLabel = instanceLabelPrefix + "status"
|
||||||
instanceTagsLabel = instanceLabelPrefix + "tags"
|
instanceTagsLabel = instanceLabelPrefix + "tags"
|
||||||
instanceTypeLabel = instanceLabelPrefix + "type"
|
instanceTypeLabel = instanceLabelPrefix + "type"
|
||||||
instanceZoneLabel = instanceLabelPrefix + "zone"
|
instanceZoneLabel = instanceLabelPrefix + "zone"
|
||||||
|
instanceRegionLabel = instanceLabelPrefix + "region"
|
||||||
)
|
)
|
||||||
|
|
||||||
type instanceDiscovery struct {
|
type instanceDiscovery struct {
|
||||||
|
@ -116,15 +127,29 @@ func (d *instanceDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group,
|
||||||
var targets []model.LabelSet
|
var targets []model.LabelSet
|
||||||
for _, server := range servers.Servers {
|
for _, server := range servers.Servers {
|
||||||
labels := model.LabelSet{
|
labels := model.LabelSet{
|
||||||
|
instanceBootTypeLabel: model.LabelValue(server.BootType),
|
||||||
|
instanceHostnameLabel: model.LabelValue(server.Hostname),
|
||||||
instanceIDLabel: model.LabelValue(server.ID),
|
instanceIDLabel: model.LabelValue(server.ID),
|
||||||
|
instanceImageArchLabel: model.LabelValue(server.Image.Arch),
|
||||||
|
instanceImageIDLabel: model.LabelValue(server.Image.ID),
|
||||||
instanceImageNameLabel: model.LabelValue(server.Image.Name),
|
instanceImageNameLabel: model.LabelValue(server.Image.Name),
|
||||||
|
instanceLocationClusterID: model.LabelValue(server.Location.ClusterID),
|
||||||
|
instanceLocationHypervisorID: model.LabelValue(server.Location.HypervisorID),
|
||||||
|
instanceLocationNodeID: model.LabelValue(server.Location.NodeID),
|
||||||
instanceNameLabel: model.LabelValue(server.Name),
|
instanceNameLabel: model.LabelValue(server.Name),
|
||||||
|
instanceOrganizationLabel: model.LabelValue(server.Organization),
|
||||||
instanceProjectLabel: model.LabelValue(server.Project),
|
instanceProjectLabel: model.LabelValue(server.Project),
|
||||||
|
instanceSecurityGroupIDLabel: model.LabelValue(server.SecurityGroup.ID),
|
||||||
|
instanceSecurityGroupNameLabel: model.LabelValue(server.SecurityGroup.Name),
|
||||||
instanceStateLabel: model.LabelValue(server.State),
|
instanceStateLabel: model.LabelValue(server.State),
|
||||||
instanceTypeLabel: model.LabelValue(server.CommercialType),
|
instanceTypeLabel: model.LabelValue(server.CommercialType),
|
||||||
instanceZoneLabel: model.LabelValue(server.Zone.String()),
|
instanceZoneLabel: model.LabelValue(server.Zone.String()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if region, err := server.Zone.Region(); err == nil {
|
||||||
|
labels[instanceRegionLabel] = model.LabelValue(region.String())
|
||||||
|
}
|
||||||
|
|
||||||
if len(server.Tags) > 0 {
|
if len(server.Tags) > 0 {
|
||||||
// We surround the separated list with the separator as well. This way regular expressions
|
// We surround the separated list with the separator as well. This way regular expressions
|
||||||
// in relabeling rules don't have to consider tag positions.
|
// in relabeling rules don't have to consider tag positions.
|
||||||
|
@ -133,15 +158,15 @@ func (d *instanceDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group,
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.IPv6 != nil {
|
if server.IPv6 != nil {
|
||||||
labels[instancePublicIPv6] = model.LabelValue(server.IPv6.Address.String())
|
labels[instancePublicIPv6Label] = model.LabelValue(server.IPv6.Address.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.PublicIP != nil {
|
if server.PublicIP != nil {
|
||||||
labels[instancePublicIPv4] = model.LabelValue(server.PublicIP.Address.String())
|
labels[instancePublicIPv4Label] = model.LabelValue(server.PublicIP.Address.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.PrivateIP != nil {
|
if server.PrivateIP != nil {
|
||||||
labels[instancePrivateIPv4] = model.LabelValue(*server.PrivateIP)
|
labels[instancePrivateIPv4Label] = model.LabelValue(*server.PrivateIP)
|
||||||
|
|
||||||
addr := net.JoinHostPort(*server.PrivateIP, strconv.FormatUint(uint64(d.port), 10))
|
addr := net.JoinHostPort(*server.PrivateIP, strconv.FormatUint(uint64(d.port), 10))
|
||||||
labels[model.AddressLabel] = model.LabelValue(addr)
|
labels[model.AddressLabel] = model.LabelValue(addr)
|
||||||
|
|
|
@ -64,25 +64,47 @@ api_url: %s
|
||||||
for i, lbls := range []model.LabelSet{
|
for i, lbls := range []model.LabelSet{
|
||||||
{
|
{
|
||||||
"__address__": "10.70.60.57:80",
|
"__address__": "10.70.60.57:80",
|
||||||
|
"__meta_scaleway_instance_boot_type": "local",
|
||||||
|
"__meta_scaleway_instance_hostname": "scw-nervous-shirley",
|
||||||
"__meta_scaleway_instance_id": "93c18a61-b681-49d0-a1cc-62b43883ae89",
|
"__meta_scaleway_instance_id": "93c18a61-b681-49d0-a1cc-62b43883ae89",
|
||||||
|
"__meta_scaleway_instance_image_arch": "x86_64",
|
||||||
|
"__meta_scaleway_instance_image_id": "45a86b35-eca6-4055-9b34-ca69845da146",
|
||||||
"__meta_scaleway_instance_image_name": "Ubuntu 18.04 Bionic Beaver",
|
"__meta_scaleway_instance_image_name": "Ubuntu 18.04 Bionic Beaver",
|
||||||
|
"__meta_scaleway_instance_location_cluster_id": "40",
|
||||||
|
"__meta_scaleway_instance_location_hypervisor_id": "1601",
|
||||||
|
"__meta_scaleway_instance_location_node_id": "29",
|
||||||
"__meta_scaleway_instance_name": "scw-nervous-shirley",
|
"__meta_scaleway_instance_name": "scw-nervous-shirley",
|
||||||
|
"__meta_scaleway_instance_organization_id": "cb334986-b054-4725-9d3a-40850fdc6015",
|
||||||
"__meta_scaleway_instance_private_ipv4": "10.70.60.57",
|
"__meta_scaleway_instance_private_ipv4": "10.70.60.57",
|
||||||
"__meta_scaleway_instance_project_id": "cb334986-b054-4725-9d5a-30850fdc6015",
|
"__meta_scaleway_instance_project_id": "cb334986-b054-4725-9d5a-30850fdc6015",
|
||||||
"__meta_scaleway_instance_public_ipv6": "2001:bc8:630:1e1c::1",
|
"__meta_scaleway_instance_public_ipv6": "2001:bc8:630:1e1c::1",
|
||||||
|
"__meta_scaleway_instance_region": "fr-par",
|
||||||
|
"__meta_scaleway_instance_security_group_id": "a6a794b7-c05b-4b20-b9fe-e17a9bb85cf0",
|
||||||
|
"__meta_scaleway_instance_security_group_name": "Default security group",
|
||||||
"__meta_scaleway_instance_status": "running",
|
"__meta_scaleway_instance_status": "running",
|
||||||
"__meta_scaleway_instance_type": "DEV1-S",
|
"__meta_scaleway_instance_type": "DEV1-S",
|
||||||
"__meta_scaleway_instance_zone": "fr-par-1",
|
"__meta_scaleway_instance_zone": "fr-par-1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__address__": "10.193.162.9:80",
|
"__address__": "10.193.162.9:80",
|
||||||
|
"__meta_scaleway_instance_boot_type": "local",
|
||||||
|
"__meta_scaleway_instance_hostname": "scw-quizzical-feistel",
|
||||||
"__meta_scaleway_instance_id": "5b6198b4-c677-41b5-9c05-04557264ae1f",
|
"__meta_scaleway_instance_id": "5b6198b4-c677-41b5-9c05-04557264ae1f",
|
||||||
|
"__meta_scaleway_instance_image_arch": "x86_64",
|
||||||
|
"__meta_scaleway_instance_image_id": "71733b74-260f-4d0d-8f18-f37dcfa56d6f",
|
||||||
"__meta_scaleway_instance_image_name": "Debian Buster",
|
"__meta_scaleway_instance_image_name": "Debian Buster",
|
||||||
|
"__meta_scaleway_instance_location_cluster_id": "4",
|
||||||
|
"__meta_scaleway_instance_location_hypervisor_id": "201",
|
||||||
|
"__meta_scaleway_instance_location_node_id": "5",
|
||||||
"__meta_scaleway_instance_name": "scw-quizzical-feistel",
|
"__meta_scaleway_instance_name": "scw-quizzical-feistel",
|
||||||
|
"__meta_scaleway_instance_organization_id": "cb334986-b054-4725-9d3a-40850fdc6015",
|
||||||
"__meta_scaleway_instance_private_ipv4": "10.193.162.9",
|
"__meta_scaleway_instance_private_ipv4": "10.193.162.9",
|
||||||
"__meta_scaleway_instance_project_id": "cb334986-b054-4725-9d5a-30850fdc6015",
|
"__meta_scaleway_instance_project_id": "cb334986-b054-4725-9d5a-30850fdc6015",
|
||||||
"__meta_scaleway_instance_public_ipv4": "151.115.45.127",
|
"__meta_scaleway_instance_public_ipv4": "151.115.45.127",
|
||||||
"__meta_scaleway_instance_public_ipv6": "2001:bc8:1e00:6204::1",
|
"__meta_scaleway_instance_public_ipv6": "2001:bc8:1e00:6204::1",
|
||||||
|
"__meta_scaleway_instance_region": "fr-par",
|
||||||
|
"__meta_scaleway_instance_security_group_id": "d35dd210-8392-44dc-8854-121e419a0f56",
|
||||||
|
"__meta_scaleway_instance_security_group_name": "Default security group",
|
||||||
"__meta_scaleway_instance_status": "running",
|
"__meta_scaleway_instance_status": "running",
|
||||||
"__meta_scaleway_instance_type": "DEV1-S",
|
"__meta_scaleway_instance_type": "DEV1-S",
|
||||||
"__meta_scaleway_instance_zone": "fr-par-1",
|
"__meta_scaleway_instance_zone": "fr-par-1",
|
||||||
|
|
|
@ -1535,17 +1535,29 @@ The following meta labels are available on targets during [relabeling](#relabel_
|
||||||
|
|
||||||
#### Instance role
|
#### Instance role
|
||||||
|
|
||||||
* `__meta_scaleway_instance_id`: the id of the instance
|
|
||||||
* `__meta_scaleway_instance_private_ipv4`: the private ipv4 address of the instance
|
* `__meta_scaleway_instance_boot_type`: the boot type of the server
|
||||||
* `__meta_scaleway_instance_public_ipv4`: the public ipv4 address of the instance
|
* `__meta_scaleway_instance_hostname`: the hostname of the server
|
||||||
* `__meta_scaleway_instance_public_ipv6`: the public ipv6 address of the instance
|
* `__meta_scaleway_instance_id`: the ID of the server
|
||||||
* `__meta_scaleway_instance_image_name`: name of the server image
|
* `__meta_scaleway_instance_image_arch`: the arch of the server image
|
||||||
|
* `__meta_scaleway_instance_image_id`: the ID of the server image
|
||||||
|
* `__meta_scaleway_instance_image_name`: the name of the server image
|
||||||
|
* `__meta_scaleway_instance_location_cluster_id`: the cluster ID of the server location
|
||||||
|
* `__meta_scaleway_instance_location_hypervisor_id`: the hypervisor ID of the server location
|
||||||
|
* `__meta_scaleway_instance_location_node_id`: the node ID of the server location
|
||||||
* `__meta_scaleway_instance_name`: name of the server
|
* `__meta_scaleway_instance_name`: name of the server
|
||||||
|
* `__meta_scaleway_instance_organization_id`: the organization of the server
|
||||||
|
* `__meta_scaleway_instance_private_ipv4`: the private IPv4 address of the server
|
||||||
* `__meta_scaleway_instance_project_id`: project id of the server
|
* `__meta_scaleway_instance_project_id`: project id of the server
|
||||||
|
* `__meta_scaleway_instance_public_ipv4`: the public IPv4 address of the server
|
||||||
|
* `__meta_scaleway_instance_public_ipv6`: the public IPv6 address of the server
|
||||||
|
* `__meta_scaleway_instance_region`: the region of the server
|
||||||
|
* `__meta_scaleway_instance_security_group_id`: the ID of the security group of the server
|
||||||
|
* `__meta_scaleway_instance_security_group_name`: the name of the security group of the server
|
||||||
* `__meta_scaleway_instance_status`: status of the server
|
* `__meta_scaleway_instance_status`: status of the server
|
||||||
* `__meta_scaleway_instance_tags`: the list of tags of the target joined by the tag separator
|
* `__meta_scaleway_instance_tags`: the list of tags of the server joined by the tag separator
|
||||||
* `__meta_scaleway_instance_type`: commercial type of the server
|
* `__meta_scaleway_instance_type`: commercial type of the server
|
||||||
* `__meta_scaleway_instance_zone`: zone of the instance (ex: `fr-par-1`, complete list on <https://developers.scaleway.com/en/>)
|
* `__meta_scaleway_instance_zone`: the zone of the server (ex: `fr-par-1`, complete list [here](https://developers.scaleway.com/en/products/instance/api/#introduction))
|
||||||
|
|
||||||
This role uses the private IPv4 address by default. This can be
|
This role uses the private IPv4 address by default. This can be
|
||||||
changed with relabelling, as demonstrated in [the Prometheus scaleway-sd
|
changed with relabelling, as demonstrated in [the Prometheus scaleway-sd
|
||||||
|
@ -1553,18 +1565,17 @@ configuration file](/documentation/examples/prometheus-scaleway.yml).
|
||||||
|
|
||||||
#### Baremetal role
|
#### Baremetal role
|
||||||
|
|
||||||
* `__meta_scaleway_baremetal_id`: the id of the server
|
* `__meta_scaleway_baremetal_id`: the ID of the server
|
||||||
* `__meta_scaleway_baremetal_public_ipv4`: the public ipv4 address of the server
|
* `__meta_scaleway_baremetal_public_ipv4`: the public IPv4 address of the server
|
||||||
* `__meta_scaleway_baremetal_public_ipv6`: the public ipv6 address of the server
|
* `__meta_scaleway_baremetal_public_ipv6`: the public IPv6 address of the server
|
||||||
* `__meta_scaleway_baremetal_ipaddress_order`: zero-based order of the address in the server
|
* `__meta_scaleway_baremetal_name`: the name of the server
|
||||||
* `__meta_scaleway_baremetal_name`: name of the server
|
* `__meta_scaleway_baremetal_os_name`: the name of the operating system of the server
|
||||||
* `__meta_scaleway_baremetal_os_name`: name of the os used
|
* `__meta_scaleway_baremetal_os_version`: the version of the operating system of the server
|
||||||
* `__meta_scaleway_baremetal_os_version`: version of the os used
|
* `__meta_scaleway_baremetal_project_id`: the project ID of the server
|
||||||
* `__meta_scaleway_baremetal_project_id`: project id of the server
|
* `__meta_scaleway_baremetal_status`: the status of the server
|
||||||
* `__meta_scaleway_baremetal_status`: status of the server
|
* `__meta_scaleway_baremetal_tags`: the list of tags of the server joined by the tag separator
|
||||||
* `__meta_scaleway_baremetal_tags`: tag list of the server
|
* `__meta_scaleway_baremetal_type`: the commercial type of the server
|
||||||
* `__meta_scaleway_baremetal_type`: commercial type of the server
|
* `__meta_scaleway_baremetal_zone`: the zone of the server (ex: `fr-par-1`, complete list [here](https://developers.scaleway.com/en/products/instance/api/#introduction))
|
||||||
* `__meta_scaleway_baremetal_zone`: zone of the server (ex: `fr-par-1`, complete list on <https://developers.scaleway.com/en/>)
|
|
||||||
|
|
||||||
This role uses the public IPv4 address by default. This can be
|
This role uses the public IPv4 address by default. This can be
|
||||||
changed with relabelling, as demonstrated in [the Prometheus scaleway-sd
|
changed with relabelling, as demonstrated in [the Prometheus scaleway-sd
|
||||||
|
|
Loading…
Reference in a new issue