diff --git a/backend/agent/promkeaexporter.go b/backend/agent/promkeaexporter.go index 3a3c29438..385a98a01 100644 --- a/backend/agent/promkeaexporter.go +++ b/backend/agent/promkeaexporter.go @@ -521,37 +521,37 @@ func NewPromKeaExporter(host string, port int, interval time.Duration, enablePer Subsystem: "dhcp4", Name: "addresses_assigned_total", Help: "Assigned addresses", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr4StatsMap["declined-addresses"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp4", Name: "addresses_declined_total", Help: "Declined counts", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr4StatsMap["reclaimed-declined-addresses"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp4", Name: "addresses_declined_reclaimed_total", Help: "Declined addresses that were reclaimed", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr4StatsMap["reclaimed-leases"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp4", Name: "addresses_reclaimed_total", Help: "Expired addresses that were reclaimed", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr4StatsMap["total-addresses"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp4", Name: "addresses_total", Help: "Size of subnet address pool", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr4StatsMap["cumulative-assigned-addresses"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp4", Name: "cumulative_addresses_assigned_total", Help: "Cumulative number of assigned addresses since server startup", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) // addresses dhcp6 adr6StatsMap := make(map[string]*prometheus.GaugeVec) @@ -560,55 +560,55 @@ func NewPromKeaExporter(host string, port int, interval time.Duration, enablePer Subsystem: "dhcp6", Name: "na_total", Help: "'Size of non-temporary address pool", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr6StatsMap["assigned-nas"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp6", Name: "na_assigned_total", Help: "Assigned non-temporary addresses (IA_NA)", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr6StatsMap["total-pds"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp6", Name: "pd_total", Help: "Size of prefix delegation pool", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr6StatsMap["assigned-pds"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp6", Name: "pd_assigned_total", Help: "Assigned prefix delegations (IA_PD)", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr6StatsMap["reclaimed-leases"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp6", Name: "addresses_reclaimed_total", Help: "Expired addresses that were reclaimed", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr6StatsMap["declined-addresses"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp6", Name: "addresses_declined_total", Help: "Declined counts", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr6StatsMap["reclaimed-declined-addresses"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp6", Name: "addresses_declined_reclaimed_total", Help: "Declined addresses that were reclaimed", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr6StatsMap["cumulative-assigned-nas"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp6", Name: "cumulative_nas_assigned_total", Help: "Cumulative number of assigned NA addresses since server startup", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) adr6StatsMap["cumulative-assigned-pds"] = factory.NewGaugeVec(prometheus.GaugeOpts{ Namespace: AppTypeKea, Subsystem: "dhcp6", Name: "cumulative_pds_assigned_total", Help: "Cumulative number of assigned PD prefixes since server startup", - }, []string{"subnet", "id", "prefix"}) + }, []string{"subnet", "subnet_id", "prefix"}) pke.Adr4StatsMap = adr4StatsMap pke.Adr6StatsMap = adr6StatsMap @@ -756,7 +756,7 @@ func (pke *PromKeaExporter) setDaemonStats(dhcpStatMap *map[string]*prometheus.G subnetIDRaw := matches[1] metricName := matches[2] - labels := prometheus.Labels{"id": subnetIDRaw, "prefix": ""} + labels := prometheus.Labels{"subnet_id": subnetIDRaw, "prefix": ""} subnetID, err := strconv.Atoi(subnetIDRaw) legacyLabel := subnetIDRaw // Subnet ID or prefix if available. if err == nil { diff --git a/backend/agent/promkeaexporter_test.go b/backend/agent/promkeaexporter_test.go index fe2b4cb2b..f4ac0cd6f 100644 --- a/backend/agent/promkeaexporter_test.go +++ b/backend/agent/promkeaexporter_test.go @@ -87,9 +87,9 @@ func TestPromKeaExporterStart(t *testing.T) { // check if assigned-addresses is 13 metric, _ := pke.Adr4StatsMap["assigned-addresses"].GetMetricWith( prometheus.Labels{ - "subnet": "7", - "id": "7", - "prefix": "", + "subnet": "7", + "subnet_id": "7", + "prefix": "", }, ) require.Equal(t, 13.0, testutil.ToFloat64(metric)) @@ -289,9 +289,9 @@ func TestSubnetPrefixInPrometheusMetrics(t *testing.T) { metric, _ := pke.Adr4StatsMap["assigned-addresses"].GetMetricWith( prometheus.Labels{ - "id": "7", - "prefix": "10.0.0.0/8", - "subnet": "10.0.0.0/8", + "subnet_id": "7", + "prefix": "10.0.0.0/8", + "subnet": "10.0.0.0/8", }, )