Merge pull request #14040 from ninjadq/metric_improvement

Metric improvement
This commit is contained in:
Qian Deng 2021-01-22 17:13:57 +08:00 committed by GitHub
commit 045e1d9abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 13 deletions

View File

@ -17,9 +17,15 @@ RUN tdnf install -y tzdata shadow >> /dev/null \
&& mkdir /harbor/
COPY --from=build /out/harbor_exporter /harbor/harbor_exporter
RUN chown harbor:harbor /harbor/harbor_exporter && chmod u+x /harbor/harbor_exporter
COPY ./make/photon/exporter/entrypoint.sh ./make/photon/common/install_cert.sh /harbor/
RUN chown -R harbor:harbor /etc/pki/tls/certs \
&& chown -R harbor:harbor /harbor/ \
&& chmod u+x /harbor/entrypoint.sh \
&& chmod u+x /harbor/install_cert.sh \
&& chmod u+x /harbor/harbor_exporter
WORKDIR /harbor
USER harbor
ENTRYPOINT ["/harbor/harbor_exporter"]
ENTRYPOINT ["/harbor/entrypoint.sh"]

View File

@ -0,0 +1,7 @@
#!/bin/sh
set -e
/harbor/install_cert.sh
/harbor/harbor_exporter

View File

@ -547,6 +547,10 @@ services:
{% if external_database == False %}
- postgresql
{% endif %}
volumes:
- type: bind
source: ./common/config/shared/trust-certificates
target: /harbor_cust_cert
logging:
driver: "syslog"
options:

View File

@ -17,10 +17,8 @@ var (
harborSysInfo = typedDesc{
desc: newDescWithLables("", "system_info", "Information of Harbor system",
"auth_mode",
"registry_url",
"external_url",
"harbor_version",
"registry_storage_provider"),
"self_registration"),
valueType: prometheus.GaugeValue,
}
)
@ -67,10 +65,8 @@ func (hc *SystemInfoCollector) getSysInfo() []prometheus.Metric {
json.NewDecoder(res.Body).Decode(&sysInfoResponse)
result = append(result, harborSysInfo.MustNewConstMetric(1,
sysInfoResponse.AuthMode,
sysInfoResponse.RegistryURL,
sysInfoResponse.ExternalURL,
sysInfoResponse.HarborVersion,
sysInfoResponse.StorageProvider))
sysInfoResponse.SelfRegistration))
if CacheEnabled() {
CachePut(systemInfoCollectorName, result)
}
@ -78,9 +74,7 @@ func (hc *SystemInfoCollector) getSysInfo() []prometheus.Metric {
}
type responseSysInfo struct {
AuthMode string `json:"auth_mode"`
RegistryURL string `json:"registry_url"`
ExternalURL string `json:"external_url"`
HarborVersion string `json:"harbor_version"`
StorageProvider string `json:"registry_storage_provider_name"`
AuthMode string `json:"auth_mode"`
HarborVersion string `json:"harbor_version"`
SelfRegistration string `json:"self_registration"`
}