Add weighted_io_time to diskio input (#3119)

This commit is contained in:
Patrick Hemmer 2017-08-11 14:49:42 -04:00 committed by Daniel Nelson
parent 257b460f61
commit b0109b3550
3 changed files with 60 additions and 15 deletions

View File

@ -57,6 +57,7 @@
- [#3098](https://github.com/influxdata/telegraf/pull/3098): Add path tag to logparser containing path of logfile.
- [#3075](https://github.com/influxdata/telegraf/pull/3075): Add salesforce input plugin.
- [#3097](https://github.com/influxdata/telegraf/pull/3097): Add option to run varnish under sudo.
- [#3119](https://github.com/influxdata/telegraf/pull/3119): Add weighted_io_time to diskio input.
### Bugfixes

View File

@ -72,18 +72,55 @@ The diskio input plugin gathers metrics about disk traffic and timing.
Data collection is based on github.com/shirou/gopsutil. This package handles platform dependencies and converts all timing information to milliseconds.
### Measurements & Fields:
- diskio
- reads (integer, counter)
- writes (integer, counter)
- read_bytes (integer, bytes)
- write_bytes (integer, bytes)
- read_time (integer, milliseconds)
- write_time (integer, milliseconds)
- io_time (integer, milliseconds)
- iops_in_progress (integer, counter) (since #2037, not yet in STABLE)
- read_bytes (integer, counter, bytes)
- write_bytes (integer, counter, bytes)
- read_time (integer, counter, milliseconds)
- write_time (integer, counter, milliseconds)
- io_time (integer, counter, milliseconds)
- weighted_io_time (integer, counter, milliseconds)
- iops_in_progress (integer, gauge)
On linux these values correspond to the values in [`/proc/diskstats`](https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats) and [`/sys/block/<dev>/stat`](https://www.kernel.org/doc/Documentation/block/stat.txt).
#### `reads` & `writes`:
These values increment when an I/O request completes.
#### `read_bytes` & `write_bytes`:
These values count the number of bytes read from or written to this
block device.
#### `read_time` & `write_time`:
These values count the number of milliseconds that I/O requests have
waited on this block device. If there are multiple I/O requests waiting,
these values will increase at a rate greater than 1000/second; for
example, if 60 read requests wait for an average of 30 ms, the read_time
field will increase by 60*30 = 1800.
#### `io_time`:
This value counts the number of milliseconds during which the device has
had I/O requests queued.
#### `weighted_io_time`:
This value counts the number of milliseconds that I/O requests have waited
on this block device. If there are multiple I/O requests waiting, this
value will increase as the product of the number of milliseconds times the
number of requests waiting (see `read_time` above for an example).
#### `iops_in_progress`:
This value counts the number of I/O requests that have been issued to
the device driver but have not yet completed. It does not include I/O
requests that are in the queue but not yet issued to the device driver.
### Tags:
@ -94,21 +131,27 @@ Data collection is based on github.com/shirou/gopsutil. This package handles pla
### Sample Queries:
Calculate percent IO utilization per disk and host:
#### Calculate percent IO utilization per disk and host:
```
SELECT derivative(last("io_time"),1ms) FROM "diskio" WHERE time > now() - 30m GROUP BY "host","name",time(60s)
```
#### Calculate average queue depth:
`iops_in_progress` will give you an instantaneous value. This will give you the average between polling intervals.
```
SELECT derivative(last("weighted_io_time",1ms))/1000 from "diskio" WHERE time > now() - 30m GROUP BY "host","name",time(60s)
```
### Example Output:
```
% telegraf -config ~/.telegraf/telegraf.conf -input-filter diskio -test
* Plugin: inputs.diskio, Collection 1
> diskio,name=mmcblk1p2 io_time=244i,read_bytes=966656i,read_time=276i,reads=128i,write_bytes=0i,write_time=0i,writes=0i 1484916036000000000
> diskio,name=mmcblk1boot1 io_time=264i,read_bytes=90112i,read_time=264i,reads=22i,write_bytes=0i,write_time=0i,writes=0i 1484916036000000000
> diskio,name=mmcblk1boot0 io_time=212i,read_bytes=90112i,read_time=212i,reads=22i,write_bytes=0i,write_time=0i,writes=0i 1484916036000000000
> diskio,name=mmcblk0 io_time=1855380i,read_bytes=135861248i,read_time=58484i,reads=4081i,write_bytes=364068864i,write_time=7128792i,writes=18019i 1484916036000000000
> diskio,name=mmcblk0p1 io_time=1855256i,read_bytes=134915072i,read_time=58256i,reads=3958i,write_bytes=364068864i,write_time=7128792i,writes=18019i 1484916036000000000
> diskio,name=mmcblk1 io_time=384i,read_bytes=2633728i,read_time=728i,reads=323i,write_bytes=0i,write_time=0i,writes=0i 1484916036000000000
> diskio,name=mmcblk1p1 io_time=216i,read_bytes=860160i,read_time=288i,reads=106i,write_bytes=0i,write_time=0i,writes=0i 1484916036000000000
> diskio,name=sda weighted_io_time=8411917i,read_time=7446444i,write_time=971489i,io_time=866197i,write_bytes=5397686272i,iops_in_progress=0i,reads=2970519i,writes=361139i,read_bytes=119528903168i 1502467254359000000
> diskio,name=sda1 reads=2149i,read_bytes=10753536i,write_bytes=20697088i,write_time=346i,weighted_io_time=505i,writes=2110i,read_time=161i,io_time=208i,iops_in_progress=0i 1502467254359000000
> diskio,name=sda2 reads=2968279i,writes=359029i,write_bytes=5376989184i,iops_in_progress=0i,weighted_io_time=8411250i,read_bytes=119517334528i,read_time=7446249i,write_time=971143i,io_time=866010i 1502467254359000000
> diskio,name=sdb writes=99391856i,write_time=466700894i,io_time=630259874i,weighted_io_time=4245949844i,reads=2750773828i,read_bytes=80667939499008i,write_bytes=6329347096576i,read_time=3783042534i,iops_in_progress=2i 1502467254359000000
> diskio,name=centos/root read_time=7472461i,write_time=950014i,iops_in_progress=0i,weighted_io_time=8424447i,writes=298543i,read_bytes=119510105088i,io_time=837421i,reads=2971769i,write_bytes=5192795648i 1502467254359000000
> diskio,name=centos/var_log reads=1065i,writes=69711i,read_time=1083i,write_time=35376i,read_bytes=6828032i,write_bytes=184193536i,io_time=29699i,iops_in_progress=0i,weighted_io_time=36460i 1502467254359000000
> diskio,name=postgresql/pgsql write_time=478267417i,io_time=631098730i,iops_in_progress=2i,weighted_io_time=4263637564i,reads=2750777151i,writes=110044361i,read_bytes=80667939288064i,write_bytes=6329347096576i,read_time=3784499336i 1502467254359000000
```

View File

@ -152,6 +152,7 @@ func (s *DiskIOStats) Gather(acc telegraf.Accumulator) error {
"read_time": io.ReadTime,
"write_time": io.WriteTime,
"io_time": io.IoTime,
"weighted_io_time": io.WeightedIO,
"iops_in_progress": io.IopsInProgress,
}
acc.AddCounter("diskio", fields, tags)