Skip to content

Commit

Permalink
Include the account in the detailed connection
Browse files Browse the repository at this point in the history
Prior to this change, there was no account information included in
the connz_detailed information. This change adds the account in the
output so that users can identify connections by account.
  • Loading branch information
jarretlavallee authored and piotrpio committed Jun 24, 2024
1 parent 1d5251b commit 27f5585
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions collector/connz.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ func createConnzCollector(system string) *connzCollector {

func createConnzDetailedCollector(system string) *connzCollector {
connzCollector := createConnzCollector(system)
detailLabels := []string{"server_id", "cid", "kind", "type", "ip", "port", "name", "name_tag", "lang",
"version", "tls_version", "tls_cipher_suite"}
detailLabels := []string{"server_id", "cid", "kind", "type", "ip", "port", "name", "name_tag",
"account", "lang", "version", "tls_version", "tls_cipher_suite"}
connzCollector.pendingBytes = prometheus.NewDesc(
prometheus.BuildFQName(system, connzEndpoint, "pending_bytes"),
"pending_bytes",
Expand Down Expand Up @@ -254,7 +254,7 @@ func (nc *connzCollector) Collect(ch chan<- prometheus.Metric) {
outMsgs += conn.OutMsgs
if nc.detailed {
detailLabelValues := []string{server.ID, conn.Cid, conn.Kind, conn.Type, conn.IP, conn.Port,
conn.Name, conn.NameTag, conn.Lang, conn.Version, conn.TLSVersion, conn.TLSCipherSuite}
conn.Name, conn.NameTag, conn.Account, conn.Lang, conn.Version, conn.TLSVersion, conn.TLSCipherSuite}
ch <- prometheus.MustNewConstMetric(nc.pendingBytes, prometheus.GaugeValue, conn.PendingBytes, detailLabelValues...)
ch <- prometheus.MustNewConstMetric(nc.subscriptions, prometheus.GaugeValue, conn.Subscriptions,
detailLabelValues...)
Expand Down Expand Up @@ -313,6 +313,7 @@ type ConnzConnection struct {
Subscriptions float64 `json:"subscriptions"`
Name string `json:"name"`
NameTag string `json:"name_tag"`
Account string `json:"account"`
Lang string `json:"lang"`
Version string `json:"version"`
TLSVersion string `json:"tls_version"`
Expand Down Expand Up @@ -386,6 +387,9 @@ func (c *ConnzConnection) UnmarshalJSON(data []byte) error {
if val, exists := connection["name_tag"]; exists {
c.NameTag = val.(string)
}
if val, exists := connection["account"]; exists {
c.Account = val.(string)
}
if val, exists := connection["lang"]; exists {
c.Lang = val.(string)
}
Expand Down

0 comments on commit 27f5585

Please sign in to comment.