diff --git a/exporter/exporter.describe.go b/exporter/exporter.describe.go index 667685a..4d3d781 100644 --- a/exporter/exporter.describe.go +++ b/exporter/exporter.describe.go @@ -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() } - } } diff --git a/semp/getClientSlowSubscriberSemp1.go b/semp/getClientSlowSubscriberSemp1.go index bc7595a..d282480 100644 --- a/semp/getClientSlowSubscriberSemp1.go +++ b/semp/getClientSlowSubscriberSemp1.go @@ -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() } diff --git a/semp/getClientStatsSemp1.go b/semp/getClientStatsSemp1.go index e47de88..5f9f396 100644 --- a/semp/getClientStatsSemp1.go +++ b/semp/getClientStatsSemp1.go @@ -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() } diff --git a/semp/metricDesc.go b/semp/metricDesc.go index dbc412b..da7a62f 100644 --- a/semp/metricDesc.go +++ b/semp/metricDesc.go @@ -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"} @@ -303,7 +304,7 @@ var MetricDesc = map[string]Descriptions{ }, //SEMPv1: show client message-vpn 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), @@ -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),