Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for diskio tags & naming #1453

Closed
wants to merge 1 commit into from
Closed

add support for diskio tags & naming #1453

wants to merge 1 commit into from

Conversation

phemmer
Copy link
Contributor

@phemmer phemmer commented Jul 4, 2016

This adds support for adding tags and device naming via udev info.
This should address #1386, and #1428

Lets start with the configuration

[[inputs.diskio]]
    NameTemplates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
    DeviceTags = ["ID_FS_TYPE","ID_FS_USAGE"]

The NameTemplates parameter says to set the name parameter to the ID_FS_LABEL value if it exists, and if not then a concatenation of DM_VG_NAME/DM_LV_NAME, and if either of those tags don't exist, it falls back to the original device name.

The DeviceTags parameter is a list of udev variables to add as device tags to the measurement.

The result looks like this on my system:

* Plugin: diskio, Collection 1
> diskio,ID_FS_TYPE=xfs,ID_FS_USAGE=filesystem,host=whistler,name=mytestlabel io_time=1266i,read_bytes=2421760i,read_time=957i,reads=303i,write_bytes=10881024i,write_time=360i,writes=89i 1467672615000000000
> diskio,host=whistler,name=sda io_time=6598789i,read_bytes=5906184704i,read_time=1914387i,reads=182112i,write_bytes=26210285056i,write_time=52565790i,writes=1878296i 1467672615000000000
> diskio,ID_FS_TYPE=vfat,ID_FS_USAGE=filesystem,host=whistler,name=sda1 io_time=987i,read_bytes=1765376i,read_time=1078i,reads=215i,write_bytes=0i,write_time=0i,writes=0i 1467672615000000000
> diskio,ID_FS_TYPE=xfs,ID_FS_USAGE=filesystem,host=whistler,name=sys/crypt io_time=6851i,read_bytes=9407488i,read_time=8688i,reads=1019i,write_bytes=2098176i,write_time=2009i,writes=2051i 1467672615000000000
> diskio,ID_FS_TYPE=xfs,ID_FS_USAGE=filesystem,host=whistler,name=sys/usr-portage io_time=58660i,read_bytes=86578688i,read_time=51486i,reads=13245i,write_bytes=35152384i,write_time=1025767i,writes=3790i 1467672615000000000
> diskio,ID_FS_TYPE=xfs,ID_FS_USAGE=filesystem,host=whistler,name=sys/am io_time=639i,read_bytes=1867776i,read_time=939i,reads=236i,write_bytes=0i,write_time=0i,writes=0i 1467672615000000000
> diskio,ID_FS_TYPE=LVM2_member,ID_FS_USAGE=raid,host=whistler,name=sda2 io_time=3891613i,read_bytes=5903923712i,read_time=1912824i,reads=181837i,write_bytes=26210285056i,write_time=44116445i,writes=1398911i 1467672615000000000
> diskio,host=whistler,name=sys/root io_time=636082i,read_bytes=1317065728i,read_time=404206i,reads=36903i,write_bytes=801451520i,write_time=1559775i,writes=96473i 1467672615000000000
> diskio,ID_FS_TYPE=xfs,ID_FS_USAGE=filesystem,host=whistler,name=sys/root-old io_time=1682i,read_bytes=1867776i,read_time=2054i,reads=236i,write_bytes=0i,write_time=0i,writes=0i 1467672615000000000
> diskio,ID_FS_TYPE=btrfs,ID_FS_USAGE=filesystem,host=whistler,name=sys/docker io_time=66057i,read_bytes=287211520i,read_time=28592i,reads=3386i,write_bytes=2467983360i,write_time=6786216i,writes=37110i 1467672615000000000
> diskio,ID_FS_TYPE=xfs,ID_FS_USAGE=filesystem,host=whistler,name=dm-9 io_time=5607021i,read_bytes=4150764032i,read_time=1421167i,reads=124988i,write_bytes=22246219776i,write_time=84288330i,writes=1265505i 1467672615000000000
> diskio,ID_FS_TYPE=crypto_LUKS,ID_FS_USAGE=crypto,host=whistler,name=sys/home-phemmer-luks io_time=5526527i,read_bytes=4151519744i,read_time=1387029i,reads=125057i,write_bytes=22246219776i,write_time=52502736i,writes=1386108i 1467672615000000000
> diskio,ID_FS_TYPE=xfs,ID_FS_USAGE=filesystem,host=whistler,name=sys/stmp io_time=2674i,read_bytes=3829248i,read_time=2334i,reads=233i,write_bytes=2110464i,write_time=566i,writes=11i 1467672615000000000
> diskio,ID_FS_TYPE=xfs,ID_FS_USAGE=filesystem,host=whistler,name=sys/var-log io_time=522335i,read_bytes=41872896i,read_time=42444i,reads=2050i,write_bytes=644383232i,write_time=3587523i,writes=132792i 1467672615000000000

The first line is an example of $ID_FS_LABEL being used (name=mytestlabel).
On several of the entries we can see the $DM_VG_NAME/$DM_LV_NAME in action, such as in sys/crypt.
The 3rd line shows us an entry that fell all the way through to normal naming (name=sda1).

And then on many of the lines, we can see the ID_FS_TYPE and ID_FS_USAGE tags.

I designed the code so that on operating systems without udev, the plugin still works, and that the plugin can be easily adapted for any device information available in these other operating systems.

Still needs tests & documentation, but can add once some high level feedback is obtained.

Required for all PRs:

  • CHANGELOG.md updated
  • Sign CLA (if not already signed)

@sparrc
Copy link
Contributor

sparrc commented Jul 18, 2016

these need to be changed to name_templates and device_tags, and you need to add them to the sampleConfig string.

@phemmer
Copy link
Contributor Author

phemmer commented Jul 18, 2016

The TOML parser supports both formats. Putting NameTemplates and name_templates in the config both work.

If no design changes are necessary I'll work on updating the docs, including the sample config.

@phemmer
Copy link
Contributor Author

phemmer commented Jul 19, 2016

PR updated with sample config documentation, tests, and changelog update.
Good for final review.

@sparrc
Copy link
Contributor

sparrc commented Aug 30, 2016

sorry to let this fall through the cracks @phemmer, can you rebase again?

@phemmer
Copy link
Contributor Author

phemmer commented Aug 30, 2016

Rebased

@Andor
Copy link

Andor commented Nov 30, 2016

What about these tags for disk?

@sparrc sparrc added this to the 1.3.0 milestone Jan 26, 2017
@sparrc
Copy link
Contributor

sparrc commented Jan 26, 2017

@phemmer sorry but looks like this conflicted with #1807, if you can rebase I'll get it merged for 1.3

@phemmer
Copy link
Contributor Author

phemmer commented Jan 26, 2017

What about these tags for disk?

Somehow I missed this comment. Sorry :-(

Anyway, I had considered this possibility previously, and I think it could be done, but it had a few minor gotchas. Unfortunately without going through it again, I can't recall what they were.
While I don't think there's any reason it couldn't be added, implementation wouldn't result in any breaking changes, so it can always come later.

@phemmer
Copy link
Contributor Author

phemmer commented Jan 26, 2017

@sparrc rebased

@sparrc sparrc closed this in 074e6d1 Jan 28, 2017
@phemmer phemmer deleted the disk-tags branch January 28, 2017 02:13
njwhite pushed a commit to njwhite/telegraf that referenced this pull request Jan 31, 2017
mlindes pushed a commit to Comcast/telegraf that referenced this pull request Feb 6, 2017
maxunt pushed a commit that referenced this pull request Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants