[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16254748#comment-16254748
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9998:
--------------------------------------------

rhtyd closed pull request #2325: CLOUDSTACK-9998: Fix metrics generation 
failurein prometheus exporter
URL: https://github.com/apache/cloudstack/pull/2325
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/plugins/integrations/prometheus/src/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
 
b/plugins/integrations/prometheus/src/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
index a51b2966631..92c128b27fe 100644
--- 
a/plugins/integrations/prometheus/src/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
+++ 
b/plugins/integrations/prometheus/src/org/apache/cloudstack/metrics/PrometheusExporterImpl.java
@@ -114,13 +114,23 @@ private void addHostMetrics(final List<Item> metricsList, 
final long dcId, final
 
             final String cpuFactor = 
String.valueOf(CapacityManager.CpuOverprovisioningFactor.valueIn(host.getClusterId()));
             final CapacityVO cpuCapacity = 
capacityDao.findByHostIdType(host.getId(), Capacity.CAPACITY_TYPE_CPU);
-            metricsList.add(new ItemHostCpu(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), cpuFactor, USED, 
cpuCapacity.getUsedCapacity()));
-            metricsList.add(new ItemHostCpu(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), cpuFactor, TOTAL, 
cpuCapacity.getTotalCapacity()));
+            if (cpuCapacity != null) {
+                metricsList.add(new ItemHostCpu(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), cpuFactor, USED, 
cpuCapacity.getUsedCapacity()));
+                metricsList.add(new ItemHostCpu(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), cpuFactor, TOTAL, 
cpuCapacity.getTotalCapacity()));
+            } else {
+                metricsList.add(new ItemHostCpu(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), cpuFactor, USED, 
0L));
+                metricsList.add(new ItemHostCpu(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), cpuFactor, TOTAL, 
0L));
+            }
 
             final String memoryFactor = 
String.valueOf(CapacityManager.MemOverprovisioningFactor.valueIn(host.getClusterId()));
             final CapacityVO memCapacity = 
capacityDao.findByHostIdType(host.getId(), Capacity.CAPACITY_TYPE_MEMORY);
-            metricsList.add(new ItemHostMemory(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), memoryFactor, USED, 
memCapacity.getUsedCapacity()));
-            metricsList.add(new ItemHostMemory(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), memoryFactor, 
TOTAL, memCapacity.getTotalCapacity()));
+            if (memCapacity != null) {
+                metricsList.add(new ItemHostMemory(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), memoryFactor, USED, 
memCapacity.getUsedCapacity()));
+                metricsList.add(new ItemHostMemory(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), memoryFactor, 
TOTAL, memCapacity.getTotalCapacity()));
+            } else {
+                metricsList.add(new ItemHostMemory(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), memoryFactor, USED, 
0L));
+                metricsList.add(new ItemHostMemory(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), memoryFactor, 
TOTAL, 0L));
+            }
 
             metricsList.add(new ItemHostVM(zoneName, zoneUuid, host.getName(), 
host.getUuid(), host.getPrivateIpAddress(), 
vmDao.listByHostId(host.getId()).size()));
 
@@ -128,6 +138,9 @@ private void addHostMetrics(final List<Item> metricsList, 
final long dcId, final
             if (coreCapacity != null) {
                 metricsList.add(new ItemVMCore(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), USED, 
coreCapacity.getUsedCapacity()));
                 metricsList.add(new ItemVMCore(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), TOTAL, 
coreCapacity.getTotalCapacity()));
+            } else {
+                metricsList.add(new ItemVMCore(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), USED, 0L));
+                metricsList.add(new ItemVMCore(zoneName, zoneUuid, 
host.getName(), host.getUuid(), host.getPrivateIpAddress(), TOTAL, 0L));
             }
         }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> CloudStack exporter for Prometheus
> ----------------------------------
>
>                 Key: CLOUDSTACK-9998
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9998
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>            Reporter: Rohit Yadav
>            Assignee: Rohit Yadav
>             Fix For: Future, 4.11.0.0
>
>
> The aim is to implement a CloudStack exporter plugin for exporting metrics 
> data to Prometheus monitoring system.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to