Prometheus: Ensure tagged hosts maintenance status is reported consistently (#7471)

When a host is not tagged, its maintenance status is reported in the
cloudstack_hosts_total metric: maintenance_enabled is OFFLINE,
maintenance_disabled is ONLINE.

When a host is tagged, its maintenance status is now also verified to
ensure consistent behaviour.

In prometheus exporter, maintenance status for cloudstack_hosts_total_by_tag is not checked. While it is checked for cloudstack_hosts_total metric.
Classified by_tag or not, metrics should be the same.

Fixes: #7470
This commit is contained in:
Ben 2023-05-23 01:44:43 -04:00 committed by GitHub
parent 257c0929cf
commit 3e8c0684ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -212,9 +212,9 @@ public class PrometheusExporterImpl extends ManagerBase implements PrometheusExp
private String markTagMaps(HostVO host, Map<String, Integer> totalHosts, Map<String, Integer> upHosts, Map<String, Integer> downHosts) {
List<String> hostTags = _hostTagsDao.getHostTags(host.getId());
markTags(hostTags,totalHosts);
if (host.getStatus() == Status.Up) {
if (host.getStatus() == Status.Up && !host.isInMaintenanceStates()) {
markTags(hostTags, upHosts);
} else if (host.getStatus() == Status.Disconnected || host.getStatus() == Status.Down) {
} else if (host.getStatus() == Status.Disconnected || host.getStatus() == Status.Down || host.isInMaintenanceStates()) {
markTags(hostTags, downHosts);
}
return StringUtils.join(hostTags, ",");