Fix missing metrics cscli (#1809)
This commit is contained in:
parent
7359586f1c
commit
7144dca68a
|
@ -47,7 +47,6 @@ func metricsToTable(t *table.Table, stats map[string]map[string]int, keys []stri
|
|||
if t == nil {
|
||||
return 0, fmt.Errorf("nil table")
|
||||
}
|
||||
|
||||
// sort keys to keep consistent order when printing
|
||||
sortedKeys := []string{}
|
||||
for k := range stats {
|
||||
|
@ -77,6 +76,7 @@ func metricsToTable(t *table.Table, stats map[string]map[string]int, keys []stri
|
|||
}
|
||||
}
|
||||
t.AddRow(row...)
|
||||
numRows++
|
||||
}
|
||||
return numRows, nil
|
||||
}
|
||||
|
|
|
@ -256,19 +256,24 @@ func InspectItem(name string, objecitemType string) {
|
|||
return
|
||||
}
|
||||
|
||||
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.FilePath)
|
||||
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)
|
||||
//This is technically wrong to do this, as the prometheus section contains a listen address, not an URL to query prometheus
|
||||
//But for ease of use, we will use the listen address as the prometheus URL because it will be 127.0.0.1 in the default case
|
||||
listenAddr := csConfig.Prometheus.ListenAddr
|
||||
if listenAddr == "" {
|
||||
listenAddr = "127.0.0.1"
|
||||
}
|
||||
listenPort := csConfig.Prometheus.ListenPort
|
||||
if listenPort == 0 {
|
||||
listenPort = 6060
|
||||
}
|
||||
prometheusURL = fmt.Sprintf("http://%s:%d/metrics", listenAddr, listenPort)
|
||||
log.Debugf("No prometheus URL provided using: %s", prometheusURL)
|
||||
}
|
||||
|
||||
fmt.Printf("\nCurrent metrics : \n")
|
||||
ShowMetrics(hubItem)
|
||||
}
|
||||
}
|
||||
|
||||
func manageCliDecisionAlerts(ip *string, ipRange *string, scope *string, value *string) error {
|
||||
|
||||
|
|
Loading…
Reference in a new issue