Supporterino / truenas-graphite-to-prometheus

A graphite exporter mapping file for truenas scale >23.10.1 metrics and some example grafana dashboards
GNU General Public License v3.0
78 stars 12 forks source link

feat: support to hostname includes dots #21

Closed yuta1024 closed 8 months ago

yuta1024 commented 8 months ago

cpu_idlestate, cpu_usage and zfs_pool accept hostname that includes dots. However, other metrics does not accept it. Therefore, this PR fix all patterns to use regex same like cpu_idlestate etc.

Before

truenas_nas_example_com_cputemp_temperatures_0 28.45

After

cpu_temperature{cpu="cpu0",instance="nas.example.com",job="truenas"} 28.3666667
Supporterino commented 8 months ago

Regular expression matching is significantly slower than glob mapping as all mappings must be tested in order. Because of this, regex mappings are only executed after all glob mappings. In other words, glob mappings take preference over regex matches, irrespective of the order in which they are specified. Regular expression matches are always evaluated in order, and the first match wins.

https://github.com/prometheus/statsd_exporter

The documentation for the statsd_exporter mentions that regex parsing can be slow. I would like to test the speed of the exporter with this change and the resource usage before merging. If you have time feel free to do a comparison. I will mostly likely get to it on the weekend. @yuta1024

yuta1024 commented 8 months ago

Thank you for you reply!

I add --log.level=debug to graphite-exporter and check processing time for one push.

It seems to be no significant peformance degration. However I don't know what happen until time passed. So I will wait about 1 day and check again. I hope this will be useful to you.

Machine specs(Docker on Ubuntu 22.04.2 LTS on Proxmox VE):

Supporterino commented 8 months ago

@yuta1024 Could you rebase your branch real quick then I get a docker image for my testing as well. But your results look promising

yuta1024 commented 8 months ago

@Supporterino OK, I rebased branch. I checked processing time again for one push. The result is 0.137 secs.

Supporterino commented 8 months ago

I also did my fair checking and the performance hit isn't notable to I am going to merge it. @yuta1024 thank you for your patience

yuta1024 commented 8 months ago

Thank you!