This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.14
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.14 by this push:
new 55f0703 plugins: Host is counted twice if it has multiple host tags
in Prometheus exporter (#4383)
55f0703 is described below
commit 55f07030cbf3e5f5c6d3be258ea6ba77ce0317e7
Author: Wei Zhou <[email protected]>
AuthorDate: Wed Oct 14 12:21:15 2020 +0200
plugins: Host is counted twice if it has multiple host tags in Prometheus
exporter (#4383)
* Hosts are counted twice if it has multiple host tags in Prometheus
exporter
* Import HostVO and inject HostDao
---
.../org/apache/cloudstack/metrics/PrometheusExporterImpl.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git
a/plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
b/plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
index 92c128b..6ded663 100644
---
a/plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
+++
b/plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
@@ -32,7 +32,6 @@ import com.cloud.api.query.dao.DomainJoinDao;
import com.cloud.api.query.dao.HostJoinDao;
import com.cloud.api.query.dao.StoragePoolJoinDao;
import com.cloud.api.query.vo.DomainJoinVO;
-import com.cloud.api.query.vo.HostJoinVO;
import com.cloud.api.query.vo.StoragePoolJoinVO;
import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityManager;
@@ -45,7 +44,9 @@ import com.cloud.dc.Vlan;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.DataCenterIpAddressDao;
import com.cloud.host.Host;
+import com.cloud.host.HostVO;
import com.cloud.host.Status;
+import com.cloud.host.dao.HostDao;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.storage.ImageStore;
import com.cloud.storage.StorageStats;
@@ -73,6 +74,8 @@ public class PrometheusExporterImpl extends ManagerBase
implements PrometheusExp
@Inject
private DataCenterDao dcDao;
@Inject
+ private HostDao hostDao;
+ @Inject
private HostJoinDao hostJoinDao;
@Inject
private VMInstanceDao vmDao;
@@ -101,8 +104,8 @@ public class PrometheusExporterImpl extends ManagerBase
implements PrometheusExp
int total = 0;
int up = 0;
int down = 0;
- for (final HostJoinVO host : hostJoinDao.listAll()) {
- if (host == null || host.getType() != Host.Type.Routing ||
host.getZoneId() != dcId) {
+ for (final HostVO host : hostDao.listAll()) {
+ if (host == null || host.getType() != Host.Type.Routing ||
host.getDataCenterId() != dcId) {
continue;
}
total++;