Skip to content

Commit

Permalink
Add per instance values as tag (#5584)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreYang authored Feb 4, 2020
1 parent a2f8671 commit 8e608ca
Show file tree
Hide file tree
Showing 10 changed files with 748 additions and 565 deletions.
7 changes: 6 additions & 1 deletion vsphere/datadog_checks/vsphere/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ def check_health(self):

@smart_retry
def get_perf_counter_by_level(self, collection_level):
"""Requests and returns the list of counter available for a given collection_level."""
"""
Requests and returns the list of counter available for a given collection_level.
:return list of vim.PerformanceManager.CounterInfo:
https://vdc-download.vmware.com/vmwb-repository/dcr-public/fe08899f-1eec-4d8d-b3bc-a6664c168c2c/7fdf97a1-4c0d-4be0-9d43-2ceebbc174d9/doc/vim.PerformanceManager.CounterInfo.html
"""
return self._conn.content.perfManager.QueryPerfCounterByLevel(collection_level)

@smart_retry
Expand Down
8 changes: 6 additions & 2 deletions vsphere/datadog_checks/vsphere/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ def __init__(self, instance, log):

# Filters
self.resource_filters = self._parse_resource_filters(instance.get("resource_filters", {}))
self.metric_filters = self._parse_metric_filters(instance.get("metric_filters", {}))
self.metric_filters = self._parse_metric_regex_filters(instance.get("metric_filters", {}))
# Since `collect_per_instance_filters` have the same structure as `metric_filters` we use the same parser
self.collect_per_instance_filters = self._parse_metric_regex_filters(
instance.get("collect_per_instance_filters", {})
)

self.validate_config()

Expand Down Expand Up @@ -147,7 +151,7 @@ def _parse_resource_filters(self, all_resource_filters):

return formatted_resource_filters

def _parse_metric_filters(self, all_metric_filters):
def _parse_metric_regex_filters(self, all_metric_filters):
allowed_resource_types = [MOR_TYPE_AS_STRING[k] for k in self.collected_resource_types]
metric_filters = {}
for resource_type, filters in iteritems(all_metric_filters):
Expand Down
21 changes: 20 additions & 1 deletion vsphere/datadog_checks/vsphere/data/conf.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ instances:
## you can choose which metric you want to collect using a list of regex.
## If you do not specify a regex for the resource, all metrics will be collected.
## See https://github.com/DataDog/integrations-core/blob/master/vsphere/datadog_checks/vsphere/metrics.py
## for the list of collected metrics (do not prefix then with `vsphere`)
## for the list of collected metrics (do not prefix them with `vsphere`)
## Note1: 'datastore', 'datacenter' and 'cluster' filters are ignored when collecting realtime metrics as those
## resources do not have realtime metrics
## Note2: 'vm' and 'host' filters are ignored when collecting historical metrics as those resources do no
Expand All @@ -119,6 +119,25 @@ instances:
# cluster:
# - <CLUSTER_REGEX> # Only possible with "collection_type: historical"

## @param collect_per_instance_filters - object - optional - default: none
## For each resource type (vm, host, datastore, datacenter, cluster) to collect,
## you can choose which metric you want to collect the instance value using a list of regex.
## See https://github.com/DataDog/integrations-core/blob/master/vsphere/datadog_checks/vsphere/metrics.py
## for the list of collected metrics (do not prefix them with `vsphere`)
## /!\ Use with parsimony, collecting per-instance metrics might be very expensive for big environments.
#
# collect_per_instance_filters:
# vm:
# - <VM_REGEX> # Only possible with "collection_type: realtime"
# host:
# - <HOST_REGEX> # Only possible with "collection_type: realtime"
# datastore:
# - <DATASTORE_REGEX> # Only possible with "collection_type: historical"
# datacenter:
# - <DATACENTER_REGEX> # Only possible with "collection_type: historical"
# cluster:
# - <CLUSTER_REGEX> # Only possible with "collection_type: historical"

## @param use_guest_hostname - boolean - optional - default: false
## If true, the check will use the guest hostname for VMs instead of the VM name
## This requires the VM to have VMware tools installed in it. If the guest hostname is
Expand Down
Loading

0 comments on commit 8e608ca

Please sign in to comment.