Closed yuta1024 closed 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
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.
main branch: 0.144 sec
ts=2024-03-14T15:56:59.432Z caller=collector.go:131 level=debug msg="Incoming line" line="truenas.(snip: hostname).system.cpu.guest_nice 0.0000000 1710431816"
(snip)
ts=2024-03-14T15:56:59.576Z caller=collector.go:183 level=debug msg="Processing sample" sample="collector.graphiteSample{OriginalName:\"truenas.(snip: hostname).smart_log_smart.disktemp.nvme0n1.nvme0n1\", Name:\"truenas_(snip: hostname)_smart_log_smart_disktemp_nvme0n1_nvme0n1\", Labels:prometheus.Labels{}, Help:\"Graphite metric truenas_(snip: hostname)smart_log_smart_disktemp_nvme0n1_nvme0n1\", Value:45, Type:2, Timestamp:time.Date(2024, time.March, 15, 0, 53, 0, 0, time.Local)}"
this branch: 0.122 sec
ts=2024-03-14T15:50:59.432Z caller=collector.go:131 level=debug msg="Incoming line" line="truenas.(snip: hostname).system.cpu.guest_nice 0.0000000 1710431456"
(snip)
ts=2024-03-14T15:50:59.544Z caller=collector.go:183 level=debug msg="Processing sample" sample="collector.graphiteSample{OriginalName:\"truenas.(snip: hostname).smart_log_smart.disktemp.nvme0n1.nvme0n1\", Name:\"disk_temperature\", Labels:prometheus.Labels{\"instance\":\"(snip: hostname)\", \"job\":\"truenas\", \"serial\":\"nvme0n1\"}, Help:\"Graphite metric disk_temperature\", Value:44, Type:2, Timestamp:time.Date(2024, time.March, 15, 0, 47, 0, 0, time.Local)}"
Machine specs(Docker on Ubuntu 22.04.2 LTS on Proxmox VE):
@yuta1024 Could you rebase your branch real quick then I get a docker image for my testing as well. But your results look promising
@Supporterino OK, I rebased branch. I checked processing time again for one push. The result is 0.137 secs.
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
Thank you!
cpu_idlestate
,cpu_usage
andzfs_pool
accept hostname that includes dots. However, other metrics does not accept it. Therefore, this PR fix all patterns to use regex same likecpu_idlestate
etc.Before
After