Skip to content

Commit

Permalink
#73 Fix misleading error message
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenRover committed Sep 5, 2024
1 parent 0e4a84f commit ff62430
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
20 changes: 4 additions & 16 deletions exporter/exporter.describe.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
package exporter

import (
"solace_exporter/semp"
"strings"

"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"solace_exporter/semp"
)

// Describe describes all the metrics ever exported by the Solace exporter. It
// implements prometheus.Collector.
func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
for _, dataSource := range *e.dataSource {
if metricDescItems, ok := semp.MetricDesc[dataSource.Name]; ok {
for _, m := range metricDescItems {
ch <- m.AsPrometheusDesc()
}
} else {
permittedNames := make([]string, 0, len(semp.MetricDesc))
for index := range semp.MetricDesc {
permittedNames = append(permittedNames, index)
}
_ = level.Error(e.logger).Log("msg", "Unexpected data source name: "+dataSource.Name, "permitted", strings.Join(permittedNames, ","))
for _, metricDescItems := range semp.MetricDesc {
for _, m := range metricDescItems {
ch <- m.AsPrometheusDesc()
}

}
}
2 changes: 1 addition & 1 deletion semp/getClientSlowSubscriberSemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (e *Semp) GetClientSlowSubscriberSemp1(ch chan<- PrometheusMetric, vpnFilte

for _, client := range target.RPC.Show.Client.PrimaryVirtualRouter.Client {
clientIp := strings.Split(client.ClientAddress, ":")[0]
ch <- e.NewMetric(MetricDesc["ClientSlowSubscriber"]["client_slow_subscriber"], prometheus.GaugeValue, slowSubscriber, client.MsgVpnName, client.ClientName, clientIp)
ch <- e.NewMetric(MetricDesc["ClientSlowSubscriber"]["client_slow_subscriber"], prometheus.GaugeValue, slowSubscriber, client.MsgVpnName, client.ClientName, clientIp, "")
}
body.Close()
}
Expand Down
2 changes: 1 addition & 1 deletion semp/getClientStatsSemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (e *Semp) GetClientStatsSemp1(ch chan<- PrometheusMetric, itemFilter string
ch <- e.NewMetric(MetricDesc["ClientStats"]["client_tx_bytes_total"], prometheus.CounterValue, client.Stats.DataTxByteCount, client.MsgVpnName, client.ClientName, client.ClientUsername)
ch <- e.NewMetric(MetricDesc["ClientStats"]["client_rx_discarded_msgs_total"], prometheus.CounterValue, client.Stats.IngressDiscards.DiscardedRxMsgCount, client.MsgVpnName, client.ClientName, client.ClientUsername)
ch <- e.NewMetric(MetricDesc["ClientStats"]["client_tx_discarded_msgs_total"], prometheus.CounterValue, client.Stats.EgressDiscards.DiscardedTxMsgCount, client.MsgVpnName, client.ClientName, client.ClientUsername)
ch <- e.NewMetric(MetricDesc["ClientStats"]["client_slow_subscriber"], prometheus.GaugeValue, encodeMetricBool(client.SlowSubscriber), client.MsgVpnName, client.ClientName, client.ClientUsername)
ch <- e.NewMetric(MetricDesc["ClientStats"]["client_slow_subscriber"], prometheus.GaugeValue, encodeMetricBool(client.SlowSubscriber), client.MsgVpnName, client.ClientName, "", client.ClientUsername)
}
body.Close()
}
Expand Down
5 changes: 3 additions & 2 deletions semp/metricDesc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var (
variableLabelsReplication = []string{"mate_name"}
variableLabelsVpn = []string{"vpn_name"}
variableLabelsClientInfo = []string{"vpn_name", "client_name", "client_address"}
variableLabelsClientSlowSub = []string{"vpn_name", "client_name", "client_address", "client_username"}
variableLabelsVpnClient = []string{"vpn_name", "client_name"}
variableLabelsVpnClientUser = []string{"vpn_name", "client_name", "client_username"}
variableLabelsVpnClientDetail = []string{"vpn_name", "client_name", "client_username", "client_profile", "acl_profile"}
Expand Down Expand Up @@ -303,7 +304,7 @@ var MetricDesc = map[string]Descriptions{
},
//SEMPv1: show client <client-name> message-vpn <vpn-name> connected
"ClientSlowSubscriber": {
"client_slow_subscriber": NewSemDesc("client_slow_subscriber", NoSempV2Ready, "Is client a slow subscriber? (0=not slow, 1=slow).", variableLabelsClientInfo),
"client_slow_subscriber": NewSemDesc("client_slow_subscriber", NoSempV2Ready, "Is client a slow subscriber? (0=not slow, 1=slow).", variableLabelsClientSlowSub),
},
"ClientStats": {
"client_rx_msgs_total": NewSemDesc("client_rx_msgs_total", NoSempV2Ready, "Number of received messages.", variableLabelsVpnClientUser),
Expand All @@ -312,7 +313,7 @@ var MetricDesc = map[string]Descriptions{
"client_tx_bytes_total": NewSemDesc("client_tx_bytes_total", NoSempV2Ready, "Number of transmitted bytes.", variableLabelsVpnClientUser),
"client_rx_discarded_msgs_total": NewSemDesc("client_rx_discarded_msgs_total", NoSempV2Ready, "Number of discarded received messages.", variableLabelsVpnClientUser),
"client_tx_discarded_msgs_total": NewSemDesc("client_tx_discarded_msgs_total", NoSempV2Ready, "Number of discarded transmitted messages.", variableLabelsVpnClientUser),
"client_slow_subscriber": NewSemDesc("client_slow_subscriber", NoSempV2Ready, "Is client a slow subscriber? (0=not slow, 1=slow).", variableLabelsVpnClientUser),
"client_slow_subscriber": NewSemDesc("client_slow_subscriber", NoSempV2Ready, "Is client a slow subscriber? (0=not slow, 1=slow).", variableLabelsClientSlowSub),
},
"ClientMessageSpoolStats": {
"client_flows_ingress": NewSemDesc("client_flows_ingress", NoSempV2Ready, "Number of ingress flows, created/openend by this client.", variableLabelsVpnClientDetail),
Expand Down

0 comments on commit ff62430

Please sign in to comment.