Skip to content

Commit

Permalink
Non-working fix for newer varnishstat JSON with metrics in the "count…
Browse files Browse the repository at this point in the history
…ers" object

```
{
  "version": 1,
  "timestamp": "2020-09-22T11:55:40",
  "counters": {
    "MGT.uptime": {
      "description": "Management process uptime",
      "flag": "c",
      "format": "d",
      "value": 4725
    },
    ...
```
  • Loading branch information
jangrewe authored and johanneswuerbach committed Sep 30, 2020
1 parent f0f90fc commit 4c6d791
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions varnish.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,15 @@ func ScrapeVarnishFrom(buf []byte, ch chan<- prometheus.Metric) ([]byte, error)
return buf, err
}

for vName, raw := range metricsJSON {
if vName == "timestamp" {
countersJSON := make(map[string]interface{})
if metricsJSON["version"] == 1 {
countersJSON = metricsJSON["counters"]
} else {
countersJSON = metricsJSON
}

for vName, raw := range countersJSON {
if vName == "version" || vName == "timestamp" {
continue
}
if dt := reflect.TypeOf(raw); dt.Kind() != reflect.Map {
Expand Down

0 comments on commit 4c6d791

Please sign in to comment.