From 7679876e68b2c2817ed1b442142eb41b268dcf2b Mon Sep 17 00:00:00 2001 From: Sambhav Kothari Date: Tue, 12 Jun 2018 18:45:47 +0530 Subject: [PATCH] Add contraints on keys and type cast correctly --- plugins/inputs/solr/solr.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/solr/solr.go b/plugins/inputs/solr/solr.go index fe3a166012a6f..461f9ade1b49e 100644 --- a/plugins/inputs/solr/solr.go +++ b/plugins/inputs/solr/solr.go @@ -415,7 +415,24 @@ func addCacheMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBe for key, value := range metrics.Stats { splitKey := strings.Split(key, ".") newKey := splitKey[len(splitKey)-1] - coreFields[newKey] = value + switch newKey { + case "cumulative_evictions", + "cumulative_hits", + "cumulative_inserts", + "cumulative_lookups", + "eviction", + "hits", + "inserts", + "lookups", + "size", + "warmupTime": + coreFields[newKey] = getInt(value) + case "hitratio", + "cumulative_hitratio": + coreFields[newKey] = getFloat(value) + default: + continue + } } acc.AddFields( "solr_cache",