mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
fix duplicate metrics issue
This commit is contained in:
parent
0eeca0987a
commit
44f1c4dd94
@ -25,7 +25,7 @@ import (
|
||||
const (
|
||||
errNotDirectCall = "Opts for STABLE metric was not directly passed to new metric function"
|
||||
errPositionalArguments = "Positional arguments are not supported"
|
||||
errStabilityLevel = "StabilityLevel should be passed STABLE, ALPHA or removed"
|
||||
errStabilityLevel = "StabilityLevel should be passed STABLE, BETA, ALPHA or removed"
|
||||
errInvalidNewMetricCall = "Invalid new metric call, please ensure code compiles"
|
||||
errNonStringAttribute = "Non string attribute is not supported"
|
||||
errBadVariableAttribute = "Metric attribute was not correctly set. Please use only global consts in same file"
|
||||
|
@ -55,7 +55,7 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "USAGE: %s <DIR or FILE or '-'> [...]\n", os.Args[0])
|
||||
os.Exit(64)
|
||||
}
|
||||
|
||||
stableMetricNames := map[string]struct{}{}
|
||||
stableMetrics := []metric{}
|
||||
errors := []error{}
|
||||
|
||||
@ -66,7 +66,12 @@ func main() {
|
||||
continue
|
||||
}
|
||||
ms, es := searchPathForStableMetrics(arg)
|
||||
stableMetrics = append(stableMetrics, ms...)
|
||||
for _, m := range ms {
|
||||
if _, ok := stableMetricNames[m.Name]; !ok {
|
||||
stableMetrics = append(stableMetrics, m)
|
||||
}
|
||||
stableMetricNames[m.Name] = struct{}{}
|
||||
}
|
||||
errors = append(errors, es...)
|
||||
}
|
||||
if addStdin {
|
||||
|
@ -132,6 +132,27 @@ var (
|
||||
},
|
||||
testLabels,
|
||||
)
|
||||
// healthcheck is a Prometheus Gauge metrics used for recording the results of a k8s healthcheck.
|
||||
healthcheck = metrics.NewGaugeVec(
|
||||
&metrics.GaugeOpts{
|
||||
Namespace: "kubernetes",
|
||||
Name: "healthcheck",
|
||||
Help: "This metric records the result of a single healthcheck.",
|
||||
StabilityLevel: metrics.BETA,
|
||||
},
|
||||
[]string{"name", "type"},
|
||||
)
|
||||
|
||||
// healthchecksTotal is a Prometheus Counter metrics used for counting the results of a k8s healthcheck.
|
||||
healthchecksTotal = metrics.NewCounterVec(
|
||||
&metrics.CounterOpts{
|
||||
Namespace: "kubernetes",
|
||||
Name: "healthchecks_total",
|
||||
Help: "This metric records the results of all healthcheck.",
|
||||
StabilityLevel: metrics.BETA,
|
||||
},
|
||||
[]string{"name", "type", "status"},
|
||||
)
|
||||
// PodWorkerDuration is a Histogram that tracks the duration (in seconds) in takes to sync a single pod.
|
||||
// Broken down by the operation type.
|
||||
SummaryMaxAge = metrics.NewSummary(
|
||||
@ -567,6 +588,8 @@ func Register(collectors ...metrics.StableCollector) {
|
||||
legacyregistry.MustRegister(NodeName)
|
||||
legacyregistry.MustRegister(PodWorkerDuration)
|
||||
legacyregistry.MustRegister(PodStartDuration)
|
||||
legacyregistry.MustRegister(healthcheck)
|
||||
legacyregistry.MustRegister(healthchecksTotal)
|
||||
legacyregistry.MustRegister(CgroupManagerDuration)
|
||||
legacyregistry.MustRegister(PodWorkerStartDuration)
|
||||
legacyregistry.MustRegister(ContainersPerPodCount)
|
||||
|
@ -417,23 +417,6 @@
|
||||
labels:
|
||||
- name
|
||||
- type
|
||||
- name: healthcheck
|
||||
namespace: kubernetes
|
||||
help: This metric records the result of a single healthcheck.
|
||||
type: Gauge
|
||||
stabilityLevel: BETA
|
||||
labels:
|
||||
- name
|
||||
- type
|
||||
- name: healthchecks_total
|
||||
namespace: kubernetes
|
||||
help: This metric records the results of all healthcheck.
|
||||
type: Counter
|
||||
stabilityLevel: BETA
|
||||
labels:
|
||||
- name
|
||||
- status
|
||||
- type
|
||||
- name: healthchecks_total
|
||||
namespace: kubernetes
|
||||
help: This metric records the results of all healthcheck.
|
||||
|
@ -192,6 +192,23 @@
|
||||
labels:
|
||||
- namespace
|
||||
- persistentvolumeclaim
|
||||
- name: healthcheck
|
||||
namespace: kubernetes
|
||||
help: This metric records the result of a single healthcheck.
|
||||
type: Gauge
|
||||
stabilityLevel: BETA
|
||||
labels:
|
||||
- name
|
||||
- type
|
||||
- name: healthchecks_total
|
||||
namespace: kubernetes
|
||||
help: This metric records the results of all healthcheck.
|
||||
type: Counter
|
||||
stabilityLevel: BETA
|
||||
labels:
|
||||
- name
|
||||
- status
|
||||
- type
|
||||
- name: priority_level_seat_utilization
|
||||
subsystem: subsystem
|
||||
namespace: namespace
|
||||
|
Loading…
Reference in New Issue
Block a user