Skip to content

Commit

Permalink
add maximum and current ingress, egress and endpoint metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
fowlerp-qlik authored and GreenRover committed Sep 18, 2023
1 parent 0f2cc78 commit 37905e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion semp/getVpnSpoolSemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ func (e *Semp) GetVpnSpoolSemp1(ch chan<- prometheus.Metric, vpnFilter string) (
SpooledMsgCount float64 `xml:"current-messages-spooled"`
SpoolUsageCurrentMb float64 `xml:"current-spool-usage-mb"`
SpoolUsageMaxMb float64 `xml:"maximum-spool-usage-mb"`
CurrentEndpoints float64 `xml:"current-queues-and-topic-endpoints"`
MaximumEndpoints float64 `xml:"maximum-queues-and-topic-endpoints"`
CurrentEgressFlows float64 `xml:"current-egress-flows"`
MaximumEgressFlows float64 `xml:"maximum-egress-flows"`
CurrentIngressFlows float64 `xml:"current-ingress-flows"`
MaximumIngressFlows float64 `xml:"maximum-ingress-flows"`
} `xml:"vpn"`
} `xml:"message-vpn"`
} `xml:"message-spool"`
Expand All @@ -29,7 +35,7 @@ func (e *Semp) GetVpnSpoolSemp1(ch chan<- prometheus.Metric, vpnFilter string) (
} `xml:"execute-result"`
}

command := "<rpc><show><message-spool><vpn-name>" + vpnFilter + "</vpn-name></message-spool></show></rpc>"
command := "<rpc><show><message-spool><vpn-name>" + vpnFilter + "</vpn-name><detail/></message-spool></show></rpc>"
body, err := e.postHTTP(e.brokerURI+"/SEMP", "application/xml", command)
if err != nil {
_ = level.Error(e.logger).Log("msg", "Can't scrape VpnSemp1", "err", err, "broker", e.brokerURI)
Expand All @@ -48,10 +54,17 @@ func (e *Semp) GetVpnSpoolSemp1(ch chan<- prometheus.Metric, vpnFilter string) (
return 0, errors.New("unexpected result: see log")
}


for _, vpn := range target.RPC.Show.MessageSpool.MessageVpn.Vpn {
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_quota_bytes"], prometheus.GaugeValue, vpn.SpoolUsageMaxMb*1024*1024, vpn.Name)
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_usage_bytes"], prometheus.GaugeValue, vpn.SpoolUsageCurrentMb*1024*1024, vpn.Name)
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_usage_msgs"], prometheus.GaugeValue, vpn.SpooledMsgCount, vpn.Name)
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_current_endpoints"], prometheus.GaugeValue, vpn.CurrentEndpoints, vpn.Name)
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_maximum_endpoints"], prometheus.GaugeValue, vpn.MaximumEndpoints, vpn.Name)
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_current_egress_flows"], prometheus.GaugeValue, vpn.CurrentEgressFlows, vpn.Name)
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_maximum_egress_flows"], prometheus.GaugeValue, vpn.MaximumEgressFlows, vpn.Name)
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_current_ingress_flows"], prometheus.GaugeValue, vpn.CurrentIngressFlows, vpn.Name)
ch <- prometheus.MustNewConstMetric(MetricDesc["VpnSpool"]["vpn_spool_maximum_ingress_flows"], prometheus.GaugeValue, vpn.MaximumIngressFlows, vpn.Name)
}

return 1, nil
Expand Down
6 changes: 6 additions & 0 deletions semp/metricDesc.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ var MetricDesc = map[string]Metrics{
"vpn_spool_quota_bytes": prometheus.NewDesc(namespace+"_"+"vpn_spool_quota_bytes", "Spool configured max disk usage.", variableLabelsVpn, nil),
"vpn_spool_usage_bytes": prometheus.NewDesc(namespace+"_"+"vpn_spool_usage_bytes", "Spool total persisted usage.", variableLabelsVpn, nil),
"vpn_spool_usage_msgs": prometheus.NewDesc(namespace+"_"+"vpn_spool_usage_msgs", "Spool total number of persisted messages.", variableLabelsVpn, nil),
"vpn_spool_current_endpoints": prometheus.NewDesc(namespace+"_"+"vpn_spool_current_endpoints", "Spool current number of endpoints.", variableLabelsVpn, nil),
"vpn_spool_maximum_endpoints": prometheus.NewDesc(namespace+"_"+"vpn_spool_maximum_endpoints", "Spool maximum number of endpoints.", variableLabelsVpn, nil),
"vpn_spool_current_egress_flows": prometheus.NewDesc(namespace+"_"+"vpn_spool_current_egress_flows", "Spool current number of egress flows.", variableLabelsVpn, nil),
"vpn_spool_maximum_egress_flows": prometheus.NewDesc(namespace+"_"+"vpn_spool_maximum_egress_flows", "Spool maximum number of egress flows.", variableLabelsVpn, nil),
"vpn_spool_current_ingress_flows": prometheus.NewDesc(namespace+"_"+"vpn_spool_current_ingress_flows", "Spool current number of ingress flows.", variableLabelsVpn, nil),
"vpn_spool_maximum_ingress_flows": prometheus.NewDesc(namespace+"_"+"vpn_spool_maximum_ingress_flows", "Spool maximum number of ingress flows.", variableLabelsVpn, nil),
},
//SEMPv1: show client <client-name> message-vpn <vpn-name> connected
"Client": {
Expand Down

0 comments on commit 37905e1

Please sign in to comment.