diff --git a/internal/pkg/statprocessors/sp_host_systeminfo.go b/internal/pkg/statprocessors/sp_host_systeminfo.go index 104c6c0e..26e7bbe5 100644 --- a/internal/pkg/statprocessors/sp_host_systeminfo.go +++ b/internal/pkg/statprocessors/sp_host_systeminfo.go @@ -121,8 +121,6 @@ func getNetworkInfo() []AerospikeStat { arrReceiveStats, arrTransferStats := dataprovider.GetSystemProvider().GetNetDevStats() // netdev receive - clusterName := ClusterName - service := Service for _, stats := range arrReceiveStats { deviceName := stats["device_name"] statName := "receive_bytes_total" @@ -132,7 +130,7 @@ func getNetworkInfo() []AerospikeStat { continue } - labelValues := []string{clusterName, service, deviceName} + labelValues := []string{ClusterName, Service, deviceName} allowed := isMetricAllowed(commons.CTX_SYSINFO_NETWORK_STATS, statName) sysMetric := NewAerospikeStat(commons.CTX_SYSINFO_NETWORK_STATS, statName, allowed) @@ -154,7 +152,7 @@ func getNetworkInfo() []AerospikeStat { continue } - labelValues := []string{clusterName, service, deviceName} + labelValues := []string{ClusterName, Service, deviceName} allowed := isMetricAllowed(commons.CTX_SYSINFO_NETWORK_STATS, statName) sysMetric := NewAerospikeStat(commons.CTX_SYSINFO_NETWORK_STATS, statName, allowed) sysMetric.Labels = networkLabels diff --git a/internal/pkg/statprocessors/sp_node_stats.go b/internal/pkg/statprocessors/sp_node_stats.go index 884b05de..6282a912 100644 --- a/internal/pkg/statprocessors/sp_node_stats.go +++ b/internal/pkg/statprocessors/sp_node_stats.go @@ -42,17 +42,14 @@ func (sw *NodeStatsProcessor) Refresh(infoKeys []string, rawMetrics map[string]s log.Tracef("node-configs:%s", nodeConfigs) log.Tracef("node-stats:%s", nodeStats) - clusterName := ClusterName - service := Service - // we are sending configs and stats in same refresh call, as both are being sent to prom, instead of doing prom-push in 2 functions // handle configs var allMetricsToSend = []AerospikeStat{} - lCfgMetricsToSend := sw.handleRefresh(nodeConfigs, clusterName, service) + lCfgMetricsToSend := sw.handleRefresh(nodeConfigs) // handle stats - lStatMetricsToSend := sw.handleRefresh(nodeStats, clusterName, service) + lStatMetricsToSend := sw.handleRefresh(nodeStats) // merge both array into single allMetricsToSend = append(allMetricsToSend, lCfgMetricsToSend...) @@ -61,7 +58,7 @@ func (sw *NodeStatsProcessor) Refresh(infoKeys []string, rawMetrics map[string]s return allMetricsToSend, nil } -func (sw *NodeStatsProcessor) handleRefresh(nodeRawMetrics string, clusterName string, service string) []AerospikeStat { +func (sw *NodeStatsProcessor) handleRefresh(nodeRawMetrics string) []AerospikeStat { stats := commons.ParseStats(nodeRawMetrics, ";") @@ -81,7 +78,7 @@ func (sw *NodeStatsProcessor) handleRefresh(nodeRawMetrics string, clusterName s } labels := []string{commons.METRIC_LABEL_CLUSTER_NAME, commons.METRIC_LABEL_SERVICE} - labelValues := []string{clusterName, service} + labelValues := []string{ClusterName, Service} // pushToPrometheus(asMetric, pv, labels, labelsValues) asMetric.updateValues(pv, labels, labelValues) diff --git a/internal/pkg/statprocessors/sp_sets.go b/internal/pkg/statprocessors/sp_sets.go index a677bb11..562cad65 100644 --- a/internal/pkg/statprocessors/sp_sets.go +++ b/internal/pkg/statprocessors/sp_sets.go @@ -41,9 +41,6 @@ func (sw *SetsStatsProcessor) Refresh(infoKeys []string, rawMetrics map[string]s var allMetricsToSend = []AerospikeStat{} for i := range setStats { - clusterName := ClusterName - service := Service - stats := commons.ParseStats(setStats[i], ":") for stat, value := range stats { pv, err := commons.TryConvert(value) @@ -59,7 +56,7 @@ func (sw *SetsStatsProcessor) Refresh(infoKeys []string, rawMetrics map[string]s } labels := []string{commons.METRIC_LABEL_CLUSTER_NAME, commons.METRIC_LABEL_SERVICE, commons.METRIC_LABEL_NS, commons.METRIC_LABEL_SET} - labelValues := []string{clusterName, service, stats["ns"], stats["set"]} + labelValues := []string{ClusterName, Service, stats["ns"], stats["set"]} // pushToPrometheus(asMetric, pv, labels, labelsValues, ch) asMetric.updateValues(pv, labels, labelValues) diff --git a/internal/pkg/statprocessors/sp_sindex.go b/internal/pkg/statprocessors/sp_sindex.go index 1734ac8d..f680c47c 100644 --- a/internal/pkg/statprocessors/sp_sindex.go +++ b/internal/pkg/statprocessors/sp_sindex.go @@ -72,9 +72,6 @@ func (siw *SindexStatsProcessor) Refresh(infoKeys []string, rawMetrics map[strin sindexName := sindexInfoKeySplit[1] log.Tracef("sindex-stats:%s:%s:%s", nsName, sindexName, rawMetrics[sindex]) - clusterName := ClusterName - service := Service - stats := commons.ParseStats(rawMetrics[sindex], ";") for stat, value := range stats { pv, err := commons.TryConvert(value) @@ -90,7 +87,7 @@ func (siw *SindexStatsProcessor) Refresh(infoKeys []string, rawMetrics map[strin } labels := []string{commons.METRIC_LABEL_CLUSTER_NAME, commons.METRIC_LABEL_SERVICE, commons.METRIC_LABEL_NS, commons.METRIC_LABEL_SINDEX} - labelValues := []string{clusterName, service, nsName, sindexName} + labelValues := []string{ClusterName, Service, nsName, sindexName} asMetric.updateValues(pv, labels, labelValues) allMetricsToSend = append(allMetricsToSend, asMetric) diff --git a/internal/pkg/statprocessors/sp_users.go b/internal/pkg/statprocessors/sp_users.go index 05485cff..8fb774cc 100644 --- a/internal/pkg/statprocessors/sp_users.go +++ b/internal/pkg/statprocessors/sp_users.go @@ -122,21 +122,21 @@ func (uw *UserStatsProcessor) refreshUserStats(infoKeys []string, rawMetrics map readInfoStats := []string{"read_quota", "read_single_record_tps", "read_scan_query_rps", "limitless_read_scan_query"} writeInfoStats := []string{"write_quota", "write_single_record_tps", "write_scan_query_rps", "limitless_write_scan_query"} - asMetric, labels, labelValues := internalCreateLocalAerospikeStat(rawMetrics, "conns_in_use", user.User) + asMetric, labels, labelValues := internalCreateLocalAerospikeStat("conns_in_use", user.User) asMetric.updateValues(float64(user.ConnsInUse), labels, labelValues) allMetricsToSend = append(allMetricsToSend, asMetric) if len(user.ReadInfo) >= 4 && len(user.WriteInfo) >= 4 { for idxReadinfo := 0; idxReadinfo < len(user.ReadInfo); idxReadinfo++ { - riAeroMetric, riLabels, riLabelValues := internalCreateLocalAerospikeStat(rawMetrics, readInfoStats[idxReadinfo], user.User) + riAeroMetric, riLabels, riLabelValues := internalCreateLocalAerospikeStat(readInfoStats[idxReadinfo], user.User) riAeroMetric.updateValues(float64(user.ReadInfo[idxReadinfo]), riLabels, riLabelValues) allMetricsToSend = append(allMetricsToSend, riAeroMetric) } for idxWriteinfo := 0; idxWriteinfo < len(user.WriteInfo); idxWriteinfo++ { - wiAeroMetric, wiLabels, wiLabelValues := internalCreateLocalAerospikeStat(rawMetrics, writeInfoStats[idxWriteinfo], user.User) + wiAeroMetric, wiLabels, wiLabelValues := internalCreateLocalAerospikeStat(writeInfoStats[idxWriteinfo], user.User) wiAeroMetric.updateValues(float64(user.WriteInfo[idxWriteinfo]), wiLabels, wiLabelValues) allMetricsToSend = append(allMetricsToSend, wiAeroMetric) @@ -147,7 +147,7 @@ func (uw *UserStatsProcessor) refreshUserStats(infoKeys []string, rawMetrics map return allMetricsToSend, nil } -func internalCreateLocalAerospikeStat(rawMetrics map[string]string, pStatName string, username string) (AerospikeStat, []string, []string) { +func internalCreateLocalAerospikeStat(pStatName string, username string) (AerospikeStat, []string, []string) { labels := []string{commons.METRIC_LABEL_CLUSTER_NAME, commons.METRIC_LABEL_SERVICE, commons.METRIC_LABEL_USER} labelValues := []string{ClusterName, Service, username} allowed := isMetricAllowed(commons.CTX_USERS, pStatName) diff --git a/internal/pkg/statprocessors/sp_xdr.go b/internal/pkg/statprocessors/sp_xdr.go index 77b69a22..c3d074e6 100644 --- a/internal/pkg/statprocessors/sp_xdr.go +++ b/internal/pkg/statprocessors/sp_xdr.go @@ -61,9 +61,6 @@ func (xw *XdrStatsProcessor) Refresh(infoKeys []string, rawMetrics map[string]st xw.xdrMetrics = make(map[string]AerospikeStat) } - clusterName := rawMetrics[Infokey_ClusterName] - service := rawMetrics[Infokey_Service] - var allMetricsToSend = []AerospikeStat{} for _, key := range infoKeys { @@ -71,7 +68,7 @@ func (xw *XdrStatsProcessor) Refresh(infoKeys []string, rawMetrics map[string]st xdrRawMetrics := rawMetrics[key] // find and construct metric name dcName, ns, metricPrefix := xw.constructMetricNamePrefix(key) - tmpXdrMetricsToSend := xw.handleRefresh(key, xdrRawMetrics, clusterName, service, dcName, ns, metricPrefix) + tmpXdrMetricsToSend := xw.handleRefresh(key, xdrRawMetrics, dcName, ns, metricPrefix) allMetricsToSend = append(allMetricsToSend, tmpXdrMetricsToSend...) } @@ -108,7 +105,7 @@ func (xw *XdrStatsProcessor) constructMetricNamePrefix(infoKeyToProcess string) } func (xw *XdrStatsProcessor) handleRefresh(infoKeyToProcess string, xdrRawMetrics string, - clusterName string, service string, dcName string, ns string, metricPrefix string) []AerospikeStat { + dcName string, ns string, metricPrefix string) []AerospikeStat { log.Tracef("xdr-%s:%s", infoKeyToProcess, xdrRawMetrics) stats := commons.ParseStats(xdrRawMetrics, ";")