mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 04:05:40 +01:00
Merge pull request #14078 from ninjadq/fix_self_registration_metric
Fix metric label related things
This commit is contained in:
commit
ebe05919be
@ -41,28 +41,28 @@ var (
|
|||||||
valueType: prometheus.GaugeValue,
|
valueType: prometheus.GaugeValue,
|
||||||
}
|
}
|
||||||
projectUsage = typedDesc{
|
projectUsage = typedDesc{
|
||||||
desc: newDescWithLables("", "project_usage_byte", "The used resource of a project", "project_id"),
|
desc: newDescWithLables("", "project_usage_byte", "The used resource of a project", "project_name"),
|
||||||
valueType: prometheus.GaugeValue,
|
valueType: prometheus.GaugeValue,
|
||||||
}
|
}
|
||||||
projectQuote = typedDesc{
|
projectQuote = typedDesc{
|
||||||
desc: newDescWithLables("", "project_quota_byte", "The quota of a project", "project_id"),
|
desc: newDescWithLables("", "project_quota_byte", "The quota of a project", "project_name"),
|
||||||
valueType: prometheus.GaugeValue,
|
valueType: prometheus.GaugeValue,
|
||||||
}
|
}
|
||||||
projectRepoTotal = typedDesc{
|
projectRepoTotal = typedDesc{
|
||||||
desc: newDescWithLables("", "project_repo_total", "Total project repos number", "project_id", "public"),
|
desc: newDescWithLables("", "project_repo_total", "Total project repos number", "project_name", "public"),
|
||||||
valueType: prometheus.GaugeValue,
|
valueType: prometheus.GaugeValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
projectMemberTotal = typedDesc{
|
projectMemberTotal = typedDesc{
|
||||||
desc: newDescWithLables("", "project_member_total", "Total members number of a project", "project_id"),
|
desc: newDescWithLables("", "project_member_total", "Total members number of a project", "project_name"),
|
||||||
valueType: prometheus.GaugeValue,
|
valueType: prometheus.GaugeValue,
|
||||||
}
|
}
|
||||||
artifactPullTotal = typedDesc{
|
artifactPullTotal = typedDesc{
|
||||||
desc: newDescWithLables("", "image_pulled", "The pull number of an image", "project_id"),
|
desc: newDescWithLables("", "artifact_pulled", "The pull number of an artifact", "project_name"),
|
||||||
valueType: prometheus.GaugeValue,
|
valueType: prometheus.GaugeValue,
|
||||||
}
|
}
|
||||||
projectArtifactTotal = typedDesc{
|
projectArtifactTotal = typedDesc{
|
||||||
desc: newDescWithLables("", "project_artifact_total", "Total project images number", "project_id", "public", "image_type"),
|
desc: newDescWithLables("", "project_artifact_total", "Total project artifacts number", "project_name", "public", "artifact_type"),
|
||||||
valueType: prometheus.GaugeValue,
|
valueType: prometheus.GaugeValue,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -2,6 +2,7 @@ package exporter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/goharbor/harbor/src/lib/log"
|
"github.com/goharbor/harbor/src/lib/log"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@ -66,7 +67,7 @@ func (hc *SystemInfoCollector) getSysInfo() []prometheus.Metric {
|
|||||||
result = append(result, harborSysInfo.MustNewConstMetric(1,
|
result = append(result, harborSysInfo.MustNewConstMetric(1,
|
||||||
sysInfoResponse.AuthMode,
|
sysInfoResponse.AuthMode,
|
||||||
sysInfoResponse.HarborVersion,
|
sysInfoResponse.HarborVersion,
|
||||||
sysInfoResponse.SelfRegistration))
|
strconv.FormatBool(sysInfoResponse.SelfRegistration)))
|
||||||
if CacheEnabled() {
|
if CacheEnabled() {
|
||||||
CachePut(systemInfoCollectorName, result)
|
CachePut(systemInfoCollectorName, result)
|
||||||
}
|
}
|
||||||
@ -76,5 +77,5 @@ func (hc *SystemInfoCollector) getSysInfo() []prometheus.Metric {
|
|||||||
type responseSysInfo struct {
|
type responseSysInfo struct {
|
||||||
AuthMode string `json:"auth_mode"`
|
AuthMode string `json:"auth_mode"`
|
||||||
HarborVersion string `json:"harbor_version"`
|
HarborVersion string `json:"harbor_version"`
|
||||||
SelfRegistration string `json:"self_registration"`
|
SelfRegistration bool `json:"self_registration"`
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class TestMetricsExist(unittest.TestCase):
|
|||||||
'core': golang_basic_metrics + ["harbor_core_http_request_total", "harbor_core_http_request_duration_seconds",
|
'core': golang_basic_metrics + ["harbor_core_http_request_total", "harbor_core_http_request_duration_seconds",
|
||||||
"harbor_core_http_inflight_requests"],
|
"harbor_core_http_inflight_requests"],
|
||||||
'registry': golang_basic_metrics + ["registry_http_in_flight_requests"],
|
'registry': golang_basic_metrics + ["registry_http_in_flight_requests"],
|
||||||
'exporter': golang_basic_metrics + ["harbor_image_pulled",
|
'exporter': golang_basic_metrics + ["artifact_pulled",
|
||||||
"harbor_project_artifact_total", "harbor_project_member_total", "harbor_project_quota_byte",
|
"harbor_project_artifact_total", "harbor_project_member_total", "harbor_project_quota_byte",
|
||||||
"harbor_project_repo_total", "harbor_project_total"
|
"harbor_project_repo_total", "harbor_project_total"
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user