def getDefaultModelSpecs(resourceType, region, instanceId, dimension=None): """Gets model specs for the default metrics for the specified instance. :param resourceType: the resource type of the instance :param region: the region the instance is in :param instanceId: the resource-type-specific identifier for the instance :param dimension: the optional dimension name to use for the identifier to use instead of the defaults for the metrics :returns: a sequence of model spec dicts for each default metric """ # Get the adapters for the resource types default metrics. defaultMetricAdapters = AWSResourceAdapterBase.getDefaultResourceMetrics( resourceType) # Build the model specs for the default metrics. modelSpecs = [] for metricAdapter in defaultMetricAdapters: metricDimension = dimension or metricAdapter.DIMENSION_GROUPS[0][0] modelSpecs.append({ "region": region, "namespace": metricAdapter.NAMESPACE, "datasource": "cloudwatch", "metric": metricAdapter.METRIC_NAME, # TODO: Is there a method for getting this or one we can make public? # TODO: Is this right? "dimensions": {metricDimension: instanceId}, }) return modelSpecs
def getDefaultModelSpecs(resourceType, region, instanceId, dimension=None): """Gets model specs for the default metrics for the specified instance. :param resourceType: the resource type of the instance :param region: the region the instance is in :param instanceId: the resource-type-specific identifier for the instance :param dimension: the optional dimension name to use for the identifier to use instead of the defaults for the metrics :returns: a sequence of model spec dicts for each default metric """ # Get the adapters for the resource types default metrics. defaultMetricAdapters = AWSResourceAdapterBase.getDefaultResourceMetrics( resourceType) # Build the model specs for the default metrics. modelSpecs = [] for metricAdapter in defaultMetricAdapters: metricDimension = dimension or metricAdapter.DIMENSION_GROUPS[0][0] modelSpecs.append({ "region": region, "namespace": metricAdapter.NAMESPACE, "datasource": "cloudwatch", "metric": metricAdapter.METRIC_NAME, # TODO: Is there a method for getting this or one we can make public? # TODO: Is this right? "dimensions": { metricDimension: instanceId }, }) return modelSpecs