Skip to content

Commit

Permalink
Fix solr plugin for Solr 7
Browse files Browse the repository at this point in the history
  • Loading branch information
sambhav committed Jun 12, 2018
1 parent daddd8b commit 8848339
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
2 changes: 1 addition & 1 deletion plugins/inputs/solr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The [solr](http://lucene.apache.org/solr/) plugin collects stats via the

More about [performance statistics](https://cwiki.apache.org/confluence/display/solr/Performance+Statistics+Reference)

Tested from 3.5 to 6.*
Tested from 3.5 to 7.*

### Configuration:

Expand Down
35 changes: 6 additions & 29 deletions plugins/inputs/solr/solr.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,7 @@ type Hitratio interface{}
// Cache is an exported type that
// contains cache metrics
type Cache struct {
Stats struct {
CumulativeEvictions int64 `json:"cumulative_evictions"`
CumulativeHitratio Hitratio `json:"cumulative_hitratio"`
CumulativeHits int64 `json:"cumulative_hits"`
CumulativeInserts int64 `json:"cumulative_inserts"`
CumulativeLookups int64 `json:"cumulative_lookups"`
Evictions int64 `json:"evictions"`
Hitratio Hitratio `json:"hitratio"`
Hits int64 `json:"hits"`
Inserts int64 `json:"inserts"`
Lookups int64 `json:"lookups"`
Size int64 `json:"size"`
WarmupTime int64 `json:"warmupTime"`
} `json:"stats"`
Stats map[string]interface{} `json:"stats"`
}

// NewSolr return a new instance of Solr
Expand Down Expand Up @@ -424,21 +411,11 @@ func addCacheMetricsToAcc(acc telegraf.Accumulator, core string, mBeansData *MBe
return err
}
for name, metrics := range cacheMetrics {
cumulativeHits := getFloat(metrics.Stats.CumulativeHitratio)
hitratio := getFloat(metrics.Stats.Hitratio)
coreFields := map[string]interface{}{
"cumulative_evictions": metrics.Stats.CumulativeEvictions,
"cumulative_hitratio": cumulativeHits,
"cumulative_hits": metrics.Stats.CumulativeHits,
"cumulative_inserts": metrics.Stats.CumulativeInserts,
"cumulative_lookups": metrics.Stats.CumulativeLookups,
"evictions": metrics.Stats.Evictions,
"hitratio": hitratio,
"hits": metrics.Stats.Hits,
"inserts": metrics.Stats.Inserts,
"lookups": metrics.Stats.Lookups,
"size": metrics.Stats.Size,
"warmup_time": metrics.Stats.WarmupTime,
coreFields := make(map[string]interface{})
for key, value := range metrics.Stats {
splitKey := strings.Split(key, ".")
newKey := splitKey[len(splitKey)-1]
coreFields[newKey] = value
}
acc.AddFields(
"solr_cache",
Expand Down

0 comments on commit 8848339

Please sign in to comment.