Skip to content

Commit

Permalink
hotfix for new format 18.* from username1366
Browse files Browse the repository at this point in the history
  • Loading branch information
f1yegor committed Oct 16, 2018
1 parent 8c9e82d commit 85e5803
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,25 @@ func (e *Exporter) handleResponse(uri string) ([]byte, error) {
}
return nil, fmt.Errorf("Status %s (%d): %s", resp.Status, resp.StatusCode, data)
}


if strings.Contains(uri, "system.metrics") || strings.Contains(uri, "system.events") {
data = DataFix(data)
}
return data, nil
}

func DataFix(data []byte) []byte {
datastr := string(data)
var fixedData string
for _, line := range strings.Split(datastr, "\n") {
parts := strings.Fields(line)
if len(parts) >= 2 {
fixedData = fixedData + fmt.Sprintf("%v %v\n", parts[0], parts[1])
}
}
return []byte(fixedData)
}

type lineResult struct {
key string
value int
Expand Down

0 comments on commit 85e5803

Please sign in to comment.