fix prometheus URL used by cscli (#520)

This commit is contained in:
AlteredCoder 2020-12-07 17:35:30 +01:00 committed by GitHub
parent 674630f7b1
commit 0ed92b20a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 9 deletions

View file

@ -257,10 +257,18 @@ func InspectItem(name string, objecitemType string) {
log.Fatalf("unable to marshal item : %s", err)
}
fmt.Printf("%s", string(buff))
fmt.Printf("\nCurrent metrics : \n\n")
ShowMetrics(hubItem)
if csConfig.Prometheus.Enabled {
if csConfig.Prometheus.ListenAddr == "" || csConfig.Prometheus.ListenPort == 0 {
log.Warningf("No prometheus address or port specified in '%s', can't show metrics", *csConfig.Self)
return
}
if prometheusURL == "" {
log.Debugf("No prometheus URL provided using: %s:%d", csConfig.Prometheus.ListenAddr, csConfig.Prometheus.ListenPort)
prometheusURL = fmt.Sprintf("http://%s:%d/metrics", csConfig.Prometheus.ListenAddr, csConfig.Prometheus.ListenPort)
}
fmt.Printf("\nCurrent metrics : \n\n")
ShowMetrics(hubItem)
}
}
func ShowMetrics(hubItem *cwhub.Item) {