Skip to content

Commit

Permalink
[#1323] Rename the label
Browse files Browse the repository at this point in the history
  • Loading branch information
fivitti committed May 27, 2024
1 parent c279b4b commit e113613
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
32 changes: 16 additions & 16 deletions backend/agent/promkeaexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions backend/agent/promkeaexporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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",
},
)

Expand Down

0 comments on commit e113613

Please sign in to comment.