Skip to content

Commit c973f92

Browse files
committed
[vsphere] skip unknown metrics
vSphere metrics are hardcoded and stored at in `checks.libs.vmware.all_metrics`. New versions of vSphere bring new metrics: thus, we should not consider this list exhaustive, neither fail (raise a `KeyError` exceptions) on an "unknown" metric. ``` 2016-06-03 20:14:04 UTC | CRITICAL | dd.collector | checks.vsphere(vsphere.py:932) | A worker thread crashed: Traceback (most recent call last): File "/opt/datadog-agent/agent/checks.d/vsphere.py", line 299, in wrapper method(*args, **kwargs) File "/opt/datadog-agent/agent/checks.d/vsphere.py", line 866, in _collect_metrics_atomic if ALL_METRICS[self.metrics_metadata[i_key][result.id.counterId]['name']]['s_type'] == 'rate': KeyError: 'vflashModule.numActiveVMDKs' ``` Instead, skip these metrics.
1 parent 72b04f3 commit c973f92

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

checks.d/vsphere.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,12 +844,19 @@ def _collect_metrics_atomic(self, instance, mor):
844844
value = self._transform_value(instance, result.id.counterId, result.value[0])
845845

846846
# Metric types are absolute, delta, and rate
847-
if ALL_METRICS[self.metrics_metadata[i_key][result.id.counterId]['name']]['s_type'] == 'rate':
847+
metric_name = self.metrics_metadata[i_key][result.id.counterId]['name']
848+
849+
if metric_name not in ALL_METRICS:
850+
self.log.debug(u"Skipping unknown `%s` metric.", metric_name)
851+
continue
852+
853+
if ALL_METRICS[metric_name]['s_type'] == 'rate':
848854
record_metric = self.rate
849855
else:
850856
record_metric = self.gauge
857+
851858
record_metric(
852-
"vsphere.%s" % self.metrics_metadata[i_key][result.id.counterId]['name'],
859+
"vsphere.%s" % metric_name,
853860
value,
854861
hostname=mor['hostname'],
855862
tags=['instance:%s' % instance_name]

0 commit comments

Comments
 (0)