GabrielBrascher commented on a change in pull request #4438:
URL: https://github.com/apache/cloudstack/pull/4438#discussion_r776757233



##########
File path: 
plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
##########
@@ -201,6 +252,18 @@ private void addVMMetrics(final List<Item> metricsList, 
final long dcId, final S
             }
             metricsList.add(new ItemVM(zoneName, zoneUuid, 
state.name().toLowerCase(), count));
         }
+
+        List<String> allHostTags = hostDao.listAll().stream()
+                .flatMap( h -> _hostTagsDao.gethostTags(h.getId()).stream())
+                .distinct()
+                .collect(Collectors.toList());
+
+        for (final State state : State.values()) {
+            for (final String hosttag : allHostTags) {
+                final Long count = vmDao.countByZoneAndStateAndHostTag(dcId, 
state, hosttag);
+                metricsList.add(new ItemVMByTag(zoneName, zoneUuid, 
state.name().toLowerCase(), count, hosttag));
+            }
+        }

Review comment:
       @soreana @DaanHoogland +1 on extracting these code lines.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to