Skip to content

Commit

Permalink
#61 adds new config sync metric
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenRover committed Jan 11, 2024
1 parent a042a81 commit f11ea6f
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 49 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ not starting with the word "internal"
| GlobalStats | no | no | no | dont harm broker | show stats client | software, appliance |
| Spool | no | no | no | dont harm broker | show message-spool | software, appliance |
| Redundancy (only for HA broker) | no | no | no | dont harm broker | show redundancy | software, appliance |
| ConfigSync (only for HA broker) | no | no | no | dont harm broker | show config-sync | software, appliance |
| ConfigSyncRouter (only for HA broker) | no | no | no | dont harm broker | show config-sync database router | software, appliance |
| Replication (only for DR broker) | no | no | no | dont harm broker | show replication stats | software, appliance |
| Vpn | yes | no | no | dont harm broker | show message-vpn vpnFilter | software, appliance |
Expand Down
3 changes: 3 additions & 0 deletions docker/solace_prometheus_exporter.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Version=*|*
Health=*|*
Spool=*|*
Redundancy=*|*
ConfigSync=*|*
ConfigSyncRouter=*|*
Vpn=*|*
VpnReplication=*|*
Expand All @@ -33,6 +34,7 @@ VpnSpool=*|*
Version=*|*
Spool=*|*
Redundancy=*|*
ConfigSync=*|*
ConfigSyncRouter=*|*
Vpn=*|*
VpnReplication=*|*
Expand All @@ -52,6 +54,7 @@ Version=*|*
Health=*|*
Spool=*|*
Redundancy=*|*
ConfigSync=*|*
ConfigSyncRouter=*|*

[endpoint.solace-broker-std-appliance]
Expand Down
2 changes: 2 additions & 0 deletions exporter/exporter.collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func (e *Exporter) CollectPrometheusMetric(ch chan<- semp.PrometheusMetric) {
up, err = e.semp.GetReplicationStatsSemp1(ch)
case "ConfigSyncRouter", "ConfigSyncRouterV1":
up, err = e.semp.GetConfigSyncRouterSemp1(ch)
case "ConfigSync", "ConfigSyncV1":
up, err = e.semp.GetConfigSyncSemp1(ch)
case "Vpn", "VpnV1":
up, err = e.semp.GetVpnSemp1(ch, dataSource.VpnFilter)
case "VpnReplication", "VpnReplicationV1":
Expand Down
2 changes: 1 addition & 1 deletion semp/getConfigSyncRouterSemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (e *Semp) GetConfigSyncRouterSemp1(ch chan<- PrometheusMetric) (ok float64,
var target Data
err = decoder.Decode(&target)
if err != nil {
_ = level.Error(e.logger).Log("msg", "Can't decode Xml ConfigSyncSemp1", "err", err, "broker", e.brokerURI)
_ = level.Error(e.logger).Log("msg", "Can't decode Xml ConfigSyncRouterSemp1", "err", err, "broker", e.brokerURI)
return 0, err
}
if target.ExecuteResult.Result != "ok" {
Expand Down
51 changes: 51 additions & 0 deletions semp/getConfigSyncSemp1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package semp

import (
"encoding/xml"
"errors"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
)

// Config Sync Status for Broker and Vpn
func (e *Semp) GetConfigSyncSemp1(ch chan<- PrometheusMetric) (ok float64, err error) {
type Data struct {
RPC struct {
Show struct {
ConfigSync struct {
Status struct {
AdminStatus string `xml:"admin-status"`
OperStatus string `xml:"oper-status"`
} `xml:"status"`
} `xml:"config-sync"`
} `xml:"show"`
} `xml:"rpc"`
ExecuteResult struct {
Result string `xml:"code,attr"`
} `xml:"execute-result"`
}

command := "<rpc><show><config-sync></config-sync></show></rpc>"
body, err := e.postHTTP(e.brokerURI+"/SEMP", "application/xml", command, "ConfigSyncSemp1", 1)
if err != nil {
_ = level.Error(e.logger).Log("msg", "Can't scrape VpnSemp1", "err", err, "broker", e.brokerURI)
return 0, err
}
defer body.Close()
decoder := xml.NewDecoder(body)
var target Data
err = decoder.Decode(&target)
if err != nil {
_ = level.Error(e.logger).Log("msg", "Can't decode Xml ConfigSyncSemp1", "err", err, "broker", e.brokerURI)
return 0, err
}
if target.ExecuteResult.Result != "ok" {
_ = level.Error(e.logger).Log("msg", "unexpected result", "command", command, "result", target.ExecuteResult.Result, "broker", e.brokerURI)
return 0, errors.New("unexpected result: see log")
}

ch <- e.NewMetric(MetricDesc["ConfigSync"]["configsync_admin_state"], prometheus.GaugeValue, encodeMetricMulti(target.RPC.Show.ConfigSync.Status.AdminStatus, []string{"Shutdown", "Enabled"}))
ch <- e.NewMetric(MetricDesc["ConfigSync"]["configsync_oper_state"], prometheus.GaugeValue, encodeMetricMulti(target.RPC.Show.ConfigSync.Status.OperStatus, []string{"Down", "Up", "Shutting Down"}))

return 1, nil
}
4 changes: 4 additions & 0 deletions semp/metricDesc.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ var MetricDesc = map[string]Descriptions{
"vpn_replication_config_state": NewSemDesc("vpn_replication_config_state", NoSempV2Ready, "Replication Config Status (0-standby, 1-active, 2-n/a)", variableLabelsVpn),
"vpn_replication_transaction_replication_mode": NewSemDesc("vpn_replication_transaction_replication_mode", NoSempV2Ready, "Replication Transaction Replication Mode (0-async, 1-sync)", variableLabelsVpn),
},
"ConfigSync": {
"configsync_admin_state": NewSemDesc("configsync_admin_state", NoSempV2Ready, "Config Sync Admin Status (0-Shutdown, 1-Enabled)", nil),
"configsync_oper_state": NewSemDesc("configsync_operational_state", NoSempV2Ready, "Config Sync Current Status (0-Down, 1-Up, 2-Shutting Down)", nil),
},
"ConfigSyncVpn": {
"configsync_table_type": NewSemDesc("configsync_table_type", NoSempV2Ready, "Config Sync Resource Type (0-Router, 1-Vpn, 2-Unknown, 3-None, 4-All)", variableLabelsConfigSyncTable),
"configsync_table_timeinstateseconds": NewSemDesc("configsync_table_timeinstateseconds", NoSempV2Ready, "Config Sync Time in State", variableLabelsConfigSyncTable),
Expand Down
1 change: 1 addition & 0 deletions solace_prometheus_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func main() {
<tr><td>GlobalStats</td><td>no</td><td>no</td><td>dont harm broker</td></tr>
<tr><td>Spool</td><td>no</td><td>no</td><td>dont harm broker</td></tr>
<tr><td>Redundancy (only for HA broker)</td><td>no</td><td>no</td><td>dont harm broker</td></tr>
<tr><td>ConfigSync (only for HA broker)</td><td>no</td><td>no</td><td>dont harm broker</td></tr>
<tr><td>ConfigSyncRouter (only for HA broker)</td><td>no</td><td>no</td><td>dont harm broker</td></tr>
<tr><td>ReplicationStats (only for DR replication broker)</td><td>no</td><td>no</td><td>dont harm broker</td></tr>
<tr><td>Vpn</td><td>yes</td><td>no</td><td>dont harm broker</td></tr>
Expand Down
56 changes: 8 additions & 48 deletions solace_prometheus_exporter.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ certificate=cert.pem
privateKey=key.pem

# Base URI on which to scrape Solace broker.
scrapeUri=http://localhost:8080
scrapeUri=https://mr-connection-j6em7yuyi7k.messaging.solace.cloud:943

# Basic Auth username for http scrape requests to Solace broker.
username=admin
username=AaaBbbCcc-view

# Basic Auth password for http scrape requests to Solace broker.
password=admin
password=d2nblrf3ga64u764evmh97k34p

# If SempV2 APIs are used, the asterix is not a valid option for vpn any more.
# There for the `defaultVpn` will be used if an asterix is given as vpn name.
Expand All @@ -35,54 +35,14 @@ sslVerify=false

# 0s means disabled. When set an interval, all well configured endpoints will fetched async.
# This may help you to deal with slower broker or extreme amount of results.
prefetchInterval=30s
prefetchInterval=0s

# Maximum connections to the configured broker. Keep in mind solace advices us to use max 10 semp connects per seconds.
# Dont increase this value if your broker may have more thant 100 clients, queues, ...
parallelSempConnections=1

[endpoint.solace-std]
Version=*|*
Health=*|*
Spool=*|*
Redundancy=*|*
ConfigSyncRouter=*|*
Vpn=*|*
VpnReplication=*|*
ConfigSyncVpn=*|*
Bridge=*|*
VpnSpool=*|*
[endpoint.solace-v1-test]
QueueStats = AaaBbbCcc|*

[endpoint.solace-det]
ClientStats=*|*
VpnStats=*|*
BridgeStats=*|*
QueueStats=*|*
QueueDetails=*|*

[endpoint.solace-broker-std]
Version=*|*
Health=*|*
Spool=*|*
Redundancy=*|*
ConfigSyncRouter=*|*

[endpoint.solace-vpn-std]
Vpn=*|*
VpnReplication=*|*
ConfigSyncVpn=*|*
Bridge=*|*
VpnSpool=*|*

[endpoint.solace-vpn-stats]
ClientStats=*|*
VpnStats=*|*
BridgeStats=*|*
QueueStats=*|*

[endpoint.solace-vpn-det]
QueueDetails=*|*

[endpoint.my-sample]
QueueStats.0=*|internal/tms/iad/warnap*
QueueStats.1=*|bridge_*
;[endpoint.solace-v2-test]
;QueueStatsV2 = AaaBbbCcc|queueName!=not/interesting*|solace_queue_msg_shutdown_discarded,solace_queue_msg_max_redelivered_discarded

0 comments on commit f11ea6f

Please sign in to comment.