fix(inputs/aerospike): Statistics query bug (#10930)
This commit is contained in:
parent
47113efc5a
commit
50d706ecfa
|
|
@ -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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
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,
|
"aerospike_host": hostPort,
|
||||||
"node_name": nodeName,
|
"node_name": nodeName,
|
||||||
}
|
}
|
||||||
fields := make(map[string]interface{})
|
nFields := make(map[string]interface{})
|
||||||
|
stat := strings.Split(stats["statistics"], ";")
|
||||||
for k, v := range stats {
|
for _, pair := range stat {
|
||||||
key := strings.Replace(k, "-", "_", -1)
|
parts := strings.Split(pair, "=")
|
||||||
fields[key] = parseAerospikeValue(key, v)
|
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) {
|
func (a *Aerospike) getNamespaces(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, error) {
|
||||||
|
|
|
||||||
|
|
@ -316,9 +316,7 @@ func TestParseNodeInfo(t *testing.T) {
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
stats := map[string]string{
|
stats := map[string]string{
|
||||||
"early_tsvc_from_proxy_error": "0",
|
"statistics": "early_tsvc_from_proxy_error=0;cluster_principal=BB9020012AC4202;cluster_is_member=true",
|
||||||
"cluster_principal": "BB9020012AC4202",
|
|
||||||
"cluster_is_member": "true",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedFields := map[string]interface{}{
|
expectedFields := map[string]interface{}{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue