mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promscrape/discovery/hetzner: fix golangci-lint warnings after 03a97dc678
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5550
This commit is contained in:
parent
c69d5041bb
commit
0196902b2e
4 changed files with 11 additions and 6 deletions
|
@ -26,6 +26,7 @@ type HcloudServer struct {
|
||||||
Labels map[string]string `json:"labels"`
|
Labels map[string]string `json:"labels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Datacenter represents the Hetzner datacenter.
|
||||||
type Datacenter struct {
|
type Datacenter struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Location DatacenterLocation `json:"location"`
|
Location DatacenterLocation `json:"location"`
|
||||||
|
@ -71,7 +72,7 @@ type IPv6 struct {
|
||||||
type ServerType struct {
|
type ServerType struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Cores int `json:"cores"`
|
Cores int `json:"cores"`
|
||||||
CpuType string `json:"cpu_type"`
|
CPUType string `json:"cpu_type"`
|
||||||
Memory float32 `json:"memory"`
|
Memory float32 `json:"memory"`
|
||||||
Disk int `json:"disk"`
|
Disk int `json:"disk"`
|
||||||
}
|
}
|
||||||
|
@ -82,6 +83,7 @@ type HcloudNetwork struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HcloudNetworksList represents the hetzner cloud networks list.
|
||||||
type HcloudNetworksList struct {
|
type HcloudNetworksList struct {
|
||||||
Networks []HcloudNetwork `json:"networks"`
|
Networks []HcloudNetwork `json:"networks"`
|
||||||
}
|
}
|
||||||
|
@ -167,7 +169,7 @@ func (server *HcloudServer) appendTargetLabels(ms []*promutils.Labels, port int,
|
||||||
m.Add("__meta_hetzner_hcloud_datacenter_location_network_zone", server.Datacenter.Location.NetworkZone)
|
m.Add("__meta_hetzner_hcloud_datacenter_location_network_zone", server.Datacenter.Location.NetworkZone)
|
||||||
m.Add("__meta_hetzner_hcloud_server_type", server.ServerType.Name)
|
m.Add("__meta_hetzner_hcloud_server_type", server.ServerType.Name)
|
||||||
m.Add("__meta_hetzner_hcloud_cpu_cores", fmt.Sprintf("%d", server.ServerType.Cores))
|
m.Add("__meta_hetzner_hcloud_cpu_cores", fmt.Sprintf("%d", server.ServerType.Cores))
|
||||||
m.Add("__meta_hetzner_hcloud_cpu_type", server.ServerType.CpuType)
|
m.Add("__meta_hetzner_hcloud_cpu_type", server.ServerType.CPUType)
|
||||||
m.Add("__meta_hetzner_hcloud_memory_size_gb", fmt.Sprintf("%d", int(server.ServerType.Memory)))
|
m.Add("__meta_hetzner_hcloud_memory_size_gb", fmt.Sprintf("%d", int(server.ServerType.Memory)))
|
||||||
m.Add("__meta_hetzner_hcloud_disk_size_gb", fmt.Sprintf("%d", server.ServerType.Disk))
|
m.Add("__meta_hetzner_hcloud_disk_size_gb", fmt.Sprintf("%d", server.ServerType.Disk))
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ func TestParseHcloudServerListResponse(t *testing.T) {
|
||||||
ServerType: ServerType{
|
ServerType: ServerType{
|
||||||
Name: "cx11",
|
Name: "cx11",
|
||||||
Cores: 1,
|
Cores: 1,
|
||||||
CpuType: "shared",
|
CPUType: "shared",
|
||||||
Memory: 1.0,
|
Memory: 1.0,
|
||||||
Disk: 25,
|
Disk: 25,
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,13 +9,15 @@ import (
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promauth"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promauth"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/proxy"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/proxy"
|
||||||
) //
|
)
|
||||||
|
|
||||||
// SDCheckInterval defines interval for targets refresh.
|
// SDCheckInterval defines interval for targets refresh.
|
||||||
var SDCheckInterval = flag.Duration("promscrape.hetznerSDCheckInterval", time.Minute, "Interval for checking for changes in hetzner. "+
|
var SDCheckInterval = flag.Duration("promscrape.hetznerSDCheckInterval", time.Minute, "Interval for checking for changes in hetzner. "+
|
||||||
"This works only if hetzner_sd_configs is configured in '-promscrape.config' file. "+
|
"This works only if hetzner_sd_configs is configured in '-promscrape.config' file. "+
|
||||||
"See https://docs.victoriametrics.com/sd_configs.html#hetzner_sd_configs for details")
|
"See https://docs.victoriametrics.com/sd_configs.html#hetzner_sd_configs for details")
|
||||||
|
|
||||||
|
// SDConfig represents service discovery config for Hetzner.
|
||||||
|
//
|
||||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#hetzner_sd_config
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#hetzner_sd_config
|
||||||
type SDConfig struct {
|
type SDConfig struct {
|
||||||
Role string `yaml:"role,omitempty"`
|
Role string `yaml:"role,omitempty"`
|
||||||
|
|
|
@ -14,11 +14,12 @@ type robotServersList struct {
|
||||||
Servers []RobotServerResponse
|
Servers []RobotServerResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RobotServerResponse represents hetzner robot server response.
|
||||||
type RobotServerResponse struct {
|
type RobotServerResponse struct {
|
||||||
Server RobotServer `json:"server"`
|
Server RobotServer `json:"server"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HcloudServer represents the structure of hetzner robot server data.
|
// RobotServer represents the structure of hetzner robot server data.
|
||||||
type RobotServer struct {
|
type RobotServer struct {
|
||||||
ServerIP string `json:"server_ip"`
|
ServerIP string `json:"server_ip"`
|
||||||
ServerIPV6 string `json:"server_ipv6_net"`
|
ServerIPV6 string `json:"server_ipv6_net"`
|
||||||
|
@ -31,7 +32,7 @@ type RobotServer struct {
|
||||||
Subnet []RobotSubnet `json:"subnet"`
|
Subnet []RobotSubnet `json:"subnet"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HcloudServer represents the structure of hetzner robot subnet data.
|
// RobotSubnet represents the structure of hetzner robot subnet data.
|
||||||
type RobotSubnet struct {
|
type RobotSubnet struct {
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
Mask string `json:"mask"`
|
Mask string `json:"mask"`
|
||||||
|
|
Loading…
Reference in a new issue