mehdy / keepalived-exporter

Prometheus Keepalived exporter
GNU General Public License v3.0
115 stars 37 forks source link

Multiple IPv4 interfaces with keepalived erroring out. #76

Closed arkaditya closed 1 year ago

arkaditya commented 2 years ago

Hi , I have two virtual ipv4 interfaces (internal and external network). I am running the keepalived-exporter as a service . It works absolutely fine when there's just one interface. But with two interfaces, I am getting the following error when doing curl:

$ curl http://x.x.x.x:9165/metrics
An error has occurred while serving metrics:

collected metric "keepalived_script_status" { label:<name:"name" value:"chk_haproxy" > gauge:<value:1 > } was collected before with the same name and label values

---------- keepalived.conf-----------

vrrp_script chk_haproxy {
  script "/usr/bin/pgrep haproxy"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}

vrrp_instance VI4_1 {
  interface eth0 

vrrp_instance VI4_2 {
  interface eth1 # interface to monitor

Should I change the internal code someplace so that it takes just one of the vrrp_instance instead ?

clwluvw commented 2 years ago

@arkaditya The error seems not related to the multiple vrrp_instances and seems it's related to the vrrp script Can you please share the keepalive version and also the /tmp/keepalived.data file?

arkaditya commented 2 years ago

keepalived -version Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2

There is not /tmp/keepalived.data. I think it's because the same chk script is used for both interfaces. If I create a different chk script , and map them to corresponding interfaces. The curl works fine

vrrp_script chk_haproxy => VI4_1 vrrp_script chk_haproxy2 => VI4_2

mehdy commented 1 year ago

@clwluvw Could you please review this issue?

clwluvw commented 1 year ago

This only happens in v1.3.5 (old versions) while using the same script in multi vrrp_instances. Keepalived will dump the stats for the script on each vrrp_instance and then when we register the metric for the script, it causes duplication.

@mehdy Should we still support old versions? Related: #47

mehdy commented 1 year ago

@clwluvw Thanks!

I think we should support older versions as well but I'm not sure if it's necessary now.

I'm closing the issue but if anyone reopened the issue we'll do it then.