diff --git a/check_azure_resource.py b/check_azure_resource.py index b17712f..4d8413d 100755 --- a/check_azure_resource.py +++ b/check_azure_resource.py @@ -61,7 +61,7 @@ class NagiosAzureResourceMonitor(Plugin): """Implements functionalities to grab metrics from Azure resource objects.""" DEFAULT_AZURE_SERVICE_HOST = 'management.azure.com' - _AZURE_METRICS_API = '2017-05-01-preview' + _AZURE_METRICS_API = '2018-01-01' _AZURE_METRICS_UNIT_SYMBOLS = {'Percent': '%', 'Bytes': 'B', 'Seconds': 's'} def __init__(self, *args, **kwargs): @@ -166,12 +166,11 @@ def _is_dimension_required(self): def _get_metric_value(self): """Get latest metric value available for the Azure resource object.""" - query = {'metric': self['metric']} + query = {'metricnames': self['metric']} if self['dimension'] is not None: query['$filter'] = "{} eq '{}'".format(self['dimension'], self['dimension-value']) - path = '{}/providers/Microsoft.Insights/metrics/{}'.format(self['resource'], - self['metric']) + path = '{}/providers/Microsoft.Insights/metrics/'.format(self['resource']) try: metric_values = _call_arm_rest_api(self._client, path,