fix(inputs/aerospike): Statistics query bug (#10930)

This commit is contained in:
Arati Kulkarni 2022-04-13 02:45:13 +05:30 committed by GitHub
parent 47113efc5a
commit 50d706ecfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View File

@ -181,7 +181,7 @@ func (a *Aerospike) gatherServer(acc telegraf.Accumulator, hostPort string) erro
}
func (a *Aerospike) getNodeInfo(n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) {
stats, err := n.RequestInfo(infoPolicy)
stats, err := n.RequestInfo(infoPolicy, "statistics")
if err != nil {
return nil, err
}
@ -190,17 +190,21 @@ func (a *Aerospike) getNodeInfo(n *as.Node, infoPolicy *as.InfoPolicy) (map[stri
}
func (a *Aerospike) parseNodeInfo(acc telegraf.Accumulator, stats map[string]string, hostPort string, nodeName string) {
tags := map[string]string{
nTags := map[string]string{
"aerospike_host": hostPort,
"node_name": nodeName,
}
fields := make(map[string]interface{})
for k, v := range stats {
key := strings.Replace(k, "-", "_", -1)
fields[key] = parseAerospikeValue(key, v)
nFields := make(map[string]interface{})
stat := strings.Split(stats["statistics"], ";")
for _, pair := range stat {
parts := strings.Split(pair, "=")
if len(parts) < 2 {
continue
}
key := strings.Replace(parts[0], "-", "_", -1)
nFields[key] = parseAerospikeValue(key, parts[1])
}
acc.AddFields("aerospike_node", fields, tags, time.Now())
acc.AddFields("aerospike_node", nFields, nTags, time.Now())
}
func (a *Aerospike) getNamespaces(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, error) {

View File

@ -316,9 +316,7 @@ func TestParseNodeInfo(t *testing.T) {
var acc testutil.Accumulator
stats := map[string]string{
"early_tsvc_from_proxy_error": "0",
"cluster_principal": "BB9020012AC4202",
"cluster_is_member": "true",
"statistics": "early_tsvc_from_proxy_error=0;cluster_principal=BB9020012AC4202;cluster_is_member=true",
}
expectedFields := map[string]interface{}{