mirror of
https://github.com/prometheus/prometheus.git
synced 2026-04-25 08:07:06 -04:00
Deprecate Hetzner Cloud server datacenter labels (#17850)
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Compliance testing (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Compliance testing (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
[hcloud.Server.Datacenter] is deprecated and will be removed after 1 July 2026. Use [hcloud.Server.Location] instead. See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters Changes to Hetzner meta labels: - `__meta_hetzner_datacenter` - is deprecated for the role `robot` but kept for backward compatibility. Using `__meta_hetzner_robot_datacenter` is preferred. - is deprecated for the role `hcloud` and will stop working after the 1 July 2026. - `__meta_hetzner_hcloud_datacenter_location` label - is deprecated but kept for backward compatibility, the same data is available in the [`hcloud.Server.Location`](https://pkg.go.dev/github.com/hetznercloud/hcloud-go/v2/hcloud#Server) struct. - using `__meta_hetzner_hcloud_location` is preferred. - `__meta_hetzner_hcloud_datacenter_location_network_zone` - is deprecated but kept for backward compatibility, the same data is available in the [`hcloud.Server.Location`](https://pkg.go.dev/github.com/hetznercloud/hcloud-go/v2/hcloud#Server) struct. - using `__meta_hetzner_hcloud_location_network_zone` is preferred. - `__meta_hetzner_hcloud_location` - replacement label for `__meta_hetzner_hcloud_datacenter_location` - `__meta_hetzner_hcloud_location_network_zone` - replacement label for `__meta_hetzner_hcloud_datacenter_location_network_zone` - `__meta_hetzner_robot_datacenter` - replacement label for `__meta_hetzner_datacenter` with the role `robot`. Signed-off-by: Jonas Lammler <jonas.lammler@hetzner-cloud.de>
This commit is contained in:
parent
2ba3046c80
commit
a9d90952ba
7 changed files with 84 additions and 29 deletions
|
|
@ -38,8 +38,10 @@ const (
|
|||
hetznerLabelHcloudImageOSVersion = hetznerHcloudLabelPrefix + "image_os_version"
|
||||
hetznerLabelHcloudImageOSFlavor = hetznerHcloudLabelPrefix + "image_os_flavor"
|
||||
hetznerLabelHcloudPrivateIPv4 = hetznerHcloudLabelPrefix + "private_ipv4_"
|
||||
hetznerLabelHcloudDatacenterLocation = hetznerHcloudLabelPrefix + "datacenter_location"
|
||||
hetznerLabelHcloudDatacenterLocationNetworkZone = hetznerHcloudLabelPrefix + "datacenter_location_network_zone"
|
||||
hetznerLabelHcloudLocation = hetznerHcloudLabelPrefix + "location"
|
||||
hetznerLabelHcloudLocationNetworkZone = hetznerHcloudLabelPrefix + "location_network_zone"
|
||||
hetznerLabelHcloudDatacenterLocation = hetznerHcloudLabelPrefix + "datacenter_location" // Label name kept for backward compatibility
|
||||
hetznerLabelHcloudDatacenterLocationNetworkZone = hetznerHcloudLabelPrefix + "datacenter_location_network_zone" // Label name kept for backward compatibility
|
||||
hetznerLabelHcloudCPUCores = hetznerHcloudLabelPrefix + "cpu_cores"
|
||||
hetznerLabelHcloudCPUType = hetznerHcloudLabelPrefix + "cpu_type"
|
||||
hetznerLabelHcloudMemoryGB = hetznerHcloudLabelPrefix + "memory_size_gb"
|
||||
|
|
@ -98,13 +100,14 @@ func (d *hcloudDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group, er
|
|||
hetznerLabelRole: model.LabelValue(HetznerRoleHcloud),
|
||||
hetznerLabelServerID: model.LabelValue(strconv.FormatInt(server.ID, 10)),
|
||||
hetznerLabelServerName: model.LabelValue(server.Name),
|
||||
hetznerLabelDatacenter: model.LabelValue(server.Datacenter.Name), //nolint:staticcheck // server.Datacenter is deprecated but kept for backwards compatibility until the next minor release
|
||||
hetznerLabelPublicIPv4: model.LabelValue(server.PublicNet.IPv4.IP.String()),
|
||||
hetznerLabelPublicIPv6Network: model.LabelValue(server.PublicNet.IPv6.Network.String()),
|
||||
hetznerLabelServerStatus: model.LabelValue(server.Status),
|
||||
|
||||
hetznerLabelHcloudDatacenterLocation: model.LabelValue(server.Datacenter.Location.Name), //nolint:staticcheck // server.Datacenter is deprecated but kept for backwards compatibility until the next minor release
|
||||
hetznerLabelHcloudDatacenterLocationNetworkZone: model.LabelValue(server.Datacenter.Location.NetworkZone), //nolint:staticcheck // server.Datacenter is deprecated but kept for backwards compatibility until the next minor release
|
||||
hetznerLabelHcloudLocation: model.LabelValue(server.Location.Name),
|
||||
hetznerLabelHcloudLocationNetworkZone: model.LabelValue(server.Location.NetworkZone),
|
||||
hetznerLabelHcloudDatacenterLocation: model.LabelValue(server.Location.Name), // Label name kept for backward compatibility
|
||||
hetznerLabelHcloudDatacenterLocationNetworkZone: model.LabelValue(server.Location.NetworkZone), // Label name kept for backward compatibility
|
||||
hetznerLabelHcloudType: model.LabelValue(server.ServerType.Name),
|
||||
hetznerLabelHcloudCPUCores: model.LabelValue(strconv.Itoa(server.ServerType.Cores)),
|
||||
hetznerLabelHcloudCPUType: model.LabelValue(server.ServerType.CPUType),
|
||||
|
|
@ -114,6 +117,12 @@ func (d *hcloudDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group, er
|
|||
model.AddressLabel: model.LabelValue(net.JoinHostPort(server.PublicNet.IPv4.IP.String(), strconv.FormatUint(uint64(d.port), 10))),
|
||||
}
|
||||
|
||||
// [hcloud.Server.Datacenter] is deprecated and will be removed after 1 July 2026.
|
||||
// See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters
|
||||
if server.Datacenter != nil { // nolint: staticcheck
|
||||
labels[hetznerLabelDatacenter] = model.LabelValue(server.Datacenter.Name) // nolint: staticcheck
|
||||
}
|
||||
|
||||
if server.Image != nil {
|
||||
labels[hetznerLabelHcloudImageName] = model.LabelValue(server.Image.Name)
|
||||
labels[hetznerLabelHcloudImageDescription] = model.LabelValue(server.Image.Description)
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ func TestHCloudSDRefresh(t *testing.T) {
|
|||
"__meta_hetzner_hcloud_image_description": model.LabelValue("Ubuntu 20.04 Standard 64 bit"),
|
||||
"__meta_hetzner_hcloud_image_os_flavor": model.LabelValue("ubuntu"),
|
||||
"__meta_hetzner_hcloud_image_os_version": model.LabelValue("20.04"),
|
||||
"__meta_hetzner_hcloud_location": model.LabelValue("fsn1"),
|
||||
"__meta_hetzner_hcloud_location_network_zone": model.LabelValue("eu-central"),
|
||||
"__meta_hetzner_hcloud_datacenter_location": model.LabelValue("fsn1"),
|
||||
"__meta_hetzner_hcloud_datacenter_location_network_zone": model.LabelValue("eu-central"),
|
||||
"__meta_hetzner_hcloud_cpu_cores": model.LabelValue("1"),
|
||||
|
|
@ -93,6 +95,8 @@ func TestHCloudSDRefresh(t *testing.T) {
|
|||
"__meta_hetzner_hcloud_image_description": model.LabelValue("Ubuntu 20.04 Standard 64 bit"),
|
||||
"__meta_hetzner_hcloud_image_os_flavor": model.LabelValue("ubuntu"),
|
||||
"__meta_hetzner_hcloud_image_os_version": model.LabelValue("20.04"),
|
||||
"__meta_hetzner_hcloud_location": model.LabelValue("fsn1"),
|
||||
"__meta_hetzner_hcloud_location_network_zone": model.LabelValue("eu-central"),
|
||||
"__meta_hetzner_hcloud_datacenter_location": model.LabelValue("fsn1"),
|
||||
"__meta_hetzner_hcloud_datacenter_location_network_zone": model.LabelValue("eu-central"),
|
||||
"__meta_hetzner_hcloud_cpu_cores": model.LabelValue("2"),
|
||||
|
|
@ -114,6 +118,8 @@ func TestHCloudSDRefresh(t *testing.T) {
|
|||
"__meta_hetzner_datacenter": model.LabelValue("fsn1-dc14"),
|
||||
"__meta_hetzner_public_ipv4": model.LabelValue("1.2.3.6"),
|
||||
"__meta_hetzner_public_ipv6_network": model.LabelValue("2001:db7::/64"),
|
||||
"__meta_hetzner_hcloud_location": model.LabelValue("fsn1"),
|
||||
"__meta_hetzner_hcloud_location_network_zone": model.LabelValue("eu-central"),
|
||||
"__meta_hetzner_hcloud_datacenter_location": model.LabelValue("fsn1"),
|
||||
"__meta_hetzner_hcloud_datacenter_location_network_zone": model.LabelValue("eu-central"),
|
||||
"__meta_hetzner_hcloud_cpu_cores": model.LabelValue("2"),
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const (
|
|||
hetznerLabelServerID = hetznerLabelPrefix + "server_id"
|
||||
hetznerLabelServerName = hetznerLabelPrefix + "server_name"
|
||||
hetznerLabelServerStatus = hetznerLabelPrefix + "server_status"
|
||||
hetznerLabelDatacenter = hetznerLabelPrefix + "datacenter"
|
||||
hetznerLabelDatacenter = hetznerLabelPrefix + "datacenter" // Label name kept for backward compatibility
|
||||
hetznerLabelPublicIPv4 = hetznerLabelPrefix + "public_ipv4"
|
||||
hetznerLabelPublicIPv6Network = hetznerLabelPrefix + "public_ipv6_network"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -124,6 +124,16 @@ func (m *SDMock) HandleHcloudServers() {
|
|||
"storage_type": "local",
|
||||
"cpu_type": "shared"
|
||||
},
|
||||
"location": {
|
||||
"id": 1,
|
||||
"name": "fsn1",
|
||||
"description": "Falkenstein DC Park 1",
|
||||
"country": "DE",
|
||||
"city": "Falkenstein",
|
||||
"latitude": 50.47612,
|
||||
"longitude": 12.370071,
|
||||
"network_zone": "eu-central"
|
||||
},
|
||||
"datacenter": {
|
||||
"id": 1,
|
||||
"name": "fsn1-dc8",
|
||||
|
|
@ -244,6 +254,16 @@ func (m *SDMock) HandleHcloudServers() {
|
|||
"storage_type": "local",
|
||||
"cpu_type": "shared"
|
||||
},
|
||||
"location": {
|
||||
"id": 1,
|
||||
"name": "fsn1",
|
||||
"description": "Falkenstein DC Park 1",
|
||||
"country": "DE",
|
||||
"city": "Falkenstein",
|
||||
"latitude": 50.47612,
|
||||
"longitude": 12.370071,
|
||||
"network_zone": "eu-central"
|
||||
},
|
||||
"datacenter": {
|
||||
"id": 2,
|
||||
"name": "fsn1-dc14",
|
||||
|
|
@ -365,6 +385,16 @@ func (m *SDMock) HandleHcloudServers() {
|
|||
"storage_type": "local",
|
||||
"cpu_type": "shared"
|
||||
},
|
||||
"location": {
|
||||
"id": 1,
|
||||
"name": "fsn1",
|
||||
"description": "Falkenstein DC Park 1",
|
||||
"country": "DE",
|
||||
"city": "Falkenstein",
|
||||
"latitude": 50.47612,
|
||||
"longitude": 12.370071,
|
||||
"network_zone": "eu-central"
|
||||
},
|
||||
"datacenter": {
|
||||
"id": 2,
|
||||
"name": "fsn1-dc14",
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
hetznerRobotLabelPrefix = hetznerLabelPrefix + "robot_"
|
||||
hetznerLabelRobotProduct = hetznerRobotLabelPrefix + "product"
|
||||
hetznerLabelRobotCancelled = hetznerRobotLabelPrefix + "cancelled"
|
||||
hetznerRobotLabelPrefix = hetznerLabelPrefix + "robot_"
|
||||
hetznerLabelRobotDatacenter = hetznerRobotLabelPrefix + "datacenter"
|
||||
hetznerLabelRobotProduct = hetznerRobotLabelPrefix + "product"
|
||||
hetznerLabelRobotCancelled = hetznerRobotLabelPrefix + "cancelled"
|
||||
)
|
||||
|
||||
var userAgent = version.PrometheusUserAgent()
|
||||
|
|
@ -105,14 +106,15 @@ func (d *robotDiscovery) refresh(context.Context) ([]*targetgroup.Group, error)
|
|||
targets := make([]model.LabelSet, len(servers))
|
||||
for i, server := range servers {
|
||||
labels := model.LabelSet{
|
||||
hetznerLabelRole: model.LabelValue(HetznerRoleRobot),
|
||||
hetznerLabelServerID: model.LabelValue(strconv.Itoa(server.Server.ServerNumber)),
|
||||
hetznerLabelServerName: model.LabelValue(server.Server.ServerName),
|
||||
hetznerLabelDatacenter: model.LabelValue(strings.ToLower(server.Server.Dc)),
|
||||
hetznerLabelPublicIPv4: model.LabelValue(server.Server.ServerIP),
|
||||
hetznerLabelServerStatus: model.LabelValue(server.Server.Status),
|
||||
hetznerLabelRobotProduct: model.LabelValue(server.Server.Product),
|
||||
hetznerLabelRobotCancelled: model.LabelValue(strconv.FormatBool(server.Server.Canceled)),
|
||||
hetznerLabelRole: model.LabelValue(HetznerRoleRobot),
|
||||
hetznerLabelServerID: model.LabelValue(strconv.Itoa(server.Server.ServerNumber)),
|
||||
hetznerLabelServerName: model.LabelValue(server.Server.ServerName),
|
||||
hetznerLabelDatacenter: model.LabelValue(strings.ToLower(server.Server.Dc)), // Label name kept for backward compatibility
|
||||
hetznerLabelPublicIPv4: model.LabelValue(server.Server.ServerIP),
|
||||
hetznerLabelServerStatus: model.LabelValue(server.Server.Status),
|
||||
hetznerLabelRobotDatacenter: model.LabelValue(strings.ToLower(server.Server.Dc)),
|
||||
hetznerLabelRobotProduct: model.LabelValue(server.Server.Product),
|
||||
hetznerLabelRobotCancelled: model.LabelValue(strconv.FormatBool(server.Server.Canceled)),
|
||||
|
||||
model.AddressLabel: model.LabelValue(net.JoinHostPort(server.Server.ServerIP, strconv.FormatUint(uint64(d.port), 10))),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,19 +64,21 @@ func TestRobotSDRefresh(t *testing.T) {
|
|||
"__meta_hetzner_public_ipv4": model.LabelValue("123.123.123.123"),
|
||||
"__meta_hetzner_public_ipv6_network": model.LabelValue("2a01:4f8:111:4221::/64"),
|
||||
"__meta_hetzner_datacenter": model.LabelValue("nbg1-dc1"),
|
||||
"__meta_hetzner_robot_datacenter": model.LabelValue("nbg1-dc1"),
|
||||
"__meta_hetzner_robot_product": model.LabelValue("DS 3000"),
|
||||
"__meta_hetzner_robot_cancelled": model.LabelValue("false"),
|
||||
},
|
||||
{
|
||||
"__address__": model.LabelValue("123.123.123.124:80"),
|
||||
"__meta_hetzner_role": model.LabelValue("robot"),
|
||||
"__meta_hetzner_server_id": model.LabelValue("421"),
|
||||
"__meta_hetzner_server_name": model.LabelValue("server2"),
|
||||
"__meta_hetzner_server_status": model.LabelValue("in process"),
|
||||
"__meta_hetzner_public_ipv4": model.LabelValue("123.123.123.124"),
|
||||
"__meta_hetzner_datacenter": model.LabelValue("fsn1-dc10"),
|
||||
"__meta_hetzner_robot_product": model.LabelValue("X5"),
|
||||
"__meta_hetzner_robot_cancelled": model.LabelValue("true"),
|
||||
"__address__": model.LabelValue("123.123.123.124:80"),
|
||||
"__meta_hetzner_role": model.LabelValue("robot"),
|
||||
"__meta_hetzner_server_id": model.LabelValue("421"),
|
||||
"__meta_hetzner_server_name": model.LabelValue("server2"),
|
||||
"__meta_hetzner_server_status": model.LabelValue("in process"),
|
||||
"__meta_hetzner_public_ipv4": model.LabelValue("123.123.123.124"),
|
||||
"__meta_hetzner_datacenter": model.LabelValue("fsn1-dc10"),
|
||||
"__meta_hetzner_robot_datacenter": model.LabelValue("fsn1-dc10"),
|
||||
"__meta_hetzner_robot_product": model.LabelValue("X5"),
|
||||
"__meta_hetzner_robot_cancelled": model.LabelValue("true"),
|
||||
},
|
||||
} {
|
||||
t.Run(fmt.Sprintf("item %d", i), func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -2238,7 +2238,10 @@ The following meta labels are available on all targets during [relabeling](#rela
|
|||
* `__meta_hetzner_server_status`: the status of the server
|
||||
* `__meta_hetzner_public_ipv4`: the public ipv4 address of the server
|
||||
* `__meta_hetzner_public_ipv6_network`: the public ipv6 network (/64) of the server
|
||||
* `__meta_hetzner_datacenter`: the datacenter of the server
|
||||
|
||||
Note that the `__meta_hetzner_datacenter` label is deprecated for both roles `robot` and `hcloud`:
|
||||
- For the `robot` role, the replacement label is `__meta_hetzner_robot_datacenter`.
|
||||
- For the `hcloud` role, the label will be removed after 1 July 2026. For more details, see the [changelog](https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters).
|
||||
|
||||
The labels below are only available for targets with `role` set to `hcloud`:
|
||||
|
||||
|
|
@ -2246,8 +2249,10 @@ The labels below are only available for targets with `role` set to `hcloud`:
|
|||
* `__meta_hetzner_hcloud_image_description`: the description of the server image
|
||||
* `__meta_hetzner_hcloud_image_os_flavor`: the OS flavor of the server image
|
||||
* `__meta_hetzner_hcloud_image_os_version`: the OS version of the server image
|
||||
* `__meta_hetzner_hcloud_datacenter_location`: the location of the server
|
||||
* `__meta_hetzner_hcloud_datacenter_location_network_zone`: the network zone of the server
|
||||
* `__meta_hetzner_hcloud_location`: the location of the server
|
||||
* `__meta_hetzner_hcloud_location_network_zone`: the network zone of the server
|
||||
* `__meta_hetzner_hcloud_datacenter_location`: the location of the server (deprecated in favor of `__meta_hetzner_hcloud_location`)
|
||||
* `__meta_hetzner_hcloud_datacenter_location_network_zone`: the network zone of the server (deprecated in favor of `__meta_hetzner_hcloud_location_network_zone`)
|
||||
* `__meta_hetzner_hcloud_server_type`: the type of the server
|
||||
* `__meta_hetzner_hcloud_cpu_cores`: the CPU cores count of the server
|
||||
* `__meta_hetzner_hcloud_cpu_type`: the CPU type of the server (shared or dedicated)
|
||||
|
|
@ -2259,6 +2264,7 @@ The labels below are only available for targets with `role` set to `hcloud`:
|
|||
|
||||
The labels below are only available for targets with `role` set to `robot`:
|
||||
|
||||
* `__meta_hetzner_robot_datacenter`: the datacenter of the server
|
||||
* `__meta_hetzner_robot_product`: the product of the server
|
||||
* `__meta_hetzner_robot_cancelled`: the server cancellation status
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue