ClusterLabs / ha_cluster_exporter

Prometheus exporter for Pacemaker based Linux HA clusters
Apache License 2.0
79 stars 35 forks source link

Issue with `ha_cluster_pacemaker_config_last_change` and timezone #187

Open rudexi opened 3 years ago

rudexi commented 3 years ago

Software used:

I'm experiencing issues with the ha_cluster_pacemaker_config_last_change metric. It does report the time in Unix time format, but it takes the time as if it was GMT, while crm_mon reports it without any timestamp markup, resulting in the error. This error is very noticeable for time zones in advance from GMT, since the reported time is in the future.

Here is more data to illustrate the issue:

$ date
Tue Mar 16 09:01:17 JST 2021

$ curl -s localhost:9664/metrics|grep ^ha_cluster_pacemaker_config_last_change
ha_cluster_pacemaker_config_last_change 1.615884919e+09

$ date -d @1615884919
Tue Mar 16 17:55:19 JST 2021

$ sudo crm_mon -X --inactive|grep last_change
    <last_change time="Tue Mar 16 08:55:19 2021" user="root" client="crm_attribute" origin="host01"/>

$ date -d 'Tue Mar 16 08:55:19 2021'
Tue Mar 16 08:55:19 JST 2021

$ date -d 'Tue Mar 16 08:55:19 2021 GMT'
Tue Mar 16 17:55:19 JST 2021

Several possibilities for fixing this:

stefanotorresi commented 3 years ago

I wasn't aware that crm_mon would report the time as local, I assumed it was UTC, my bad! It totally makes sense to convert it to UTC when we collect it in the exporter.