-
Notifications
You must be signed in to change notification settings - Fork 180
/
diskio.go
44 lines (37 loc) · 927 Bytes
/
diskio.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package migrate
func init() {
AddRule(DiskIORule)
}
// [inputs]
// [[inputs.diskio]]
// fieldpass = ["io_time", "write_bytes", "read_bytes", "writes", "reads"]
//- report_deltas = true
// [inputs.diskio.tags]
// metricPath = "metrics"
//+ report_deltas = "true"
//
// [processors]
//+ [[processors.delta]]
func DiskIORule(conf map[string]interface{}) error {
ds := getItem(conf, "inputs", "diskio")
if ds == nil {
return nil
}
for _, d := range ds {
delete(d, "report_deltas")
ts, ok := d["tags"].(map[string]interface{})
if ok {
ts["report_deltas"] = "true"
} else {
d["tags"] = map[string]interface{}{"report_deltas": "true"}
}
}
ps, ok := conf["processors"].(map[string]interface{})
if !ok {
ps = make(map[string]interface{})
conf["processors"] = ps
}
empty := make(map[string]interface{})
ps["delta"] = []map[string]interface{}{empty}
return nil
}