|
|
|
|
@ -309,7 +309,8 @@ func parseMultiSelectValue(input string) []string { |
|
|
|
|
|
|
|
|
|
// Whenever this list is updated, the frontend list should also be updated.
|
|
|
|
|
// Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html
|
|
|
|
|
func (e *cloudWatchExecutor) handleGetRegions(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) { |
|
|
|
|
func (e *cloudWatchExecutor) handleGetRegions(ctx context.Context, parameters *simplejson.Json, |
|
|
|
|
queryContext *tsdb.TsdbQuery) ([]suggestData, error) { |
|
|
|
|
dsInfo := e.getDSInfo(defaultRegion) |
|
|
|
|
profile := dsInfo.Profile |
|
|
|
|
if cache, ok := regionCache.Load(profile); ok { |
|
|
|
|
@ -479,7 +480,8 @@ func (e *cloudWatchExecutor) handleGetDimensionValues(ctx context.Context, param |
|
|
|
|
return result, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (e *cloudWatchExecutor) handleGetEbsVolumeIds(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) { |
|
|
|
|
func (e *cloudWatchExecutor) handleGetEbsVolumeIds(ctx context.Context, parameters *simplejson.Json, |
|
|
|
|
queryContext *tsdb.TsdbQuery) ([]suggestData, error) { |
|
|
|
|
region := parameters.Get("region").MustString() |
|
|
|
|
instanceId := parameters.Get("instanceId").MustString() |
|
|
|
|
|
|
|
|
|
@ -501,7 +503,8 @@ func (e *cloudWatchExecutor) handleGetEbsVolumeIds(ctx context.Context, paramete |
|
|
|
|
return result, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (e *cloudWatchExecutor) handleGetEc2InstanceAttribute(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) { |
|
|
|
|
func (e *cloudWatchExecutor) handleGetEc2InstanceAttribute(ctx context.Context, parameters *simplejson.Json, |
|
|
|
|
queryContext *tsdb.TsdbQuery) ([]suggestData, error) { |
|
|
|
|
region := parameters.Get("region").MustString() |
|
|
|
|
attributeName := parameters.Get("attributeName").MustString() |
|
|
|
|
filterJson := parameters.Get("filters").MustMap() |
|
|
|
|
@ -580,7 +583,8 @@ func (e *cloudWatchExecutor) handleGetEc2InstanceAttribute(ctx context.Context, |
|
|
|
|
return result, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (e *cloudWatchExecutor) handleGetResourceArns(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) { |
|
|
|
|
func (e *cloudWatchExecutor) handleGetResourceArns(ctx context.Context, parameters *simplejson.Json, |
|
|
|
|
queryContext *tsdb.TsdbQuery) ([]suggestData, error) { |
|
|
|
|
region := parameters.Get("region").MustString() |
|
|
|
|
resourceType := parameters.Get("resourceType").MustString() |
|
|
|
|
filterJson := parameters.Get("tags").MustMap() |
|
|
|
|
@ -618,7 +622,8 @@ func (e *cloudWatchExecutor) handleGetResourceArns(ctx context.Context, paramete |
|
|
|
|
return result, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (e *cloudWatchExecutor) cloudwatchListMetrics(region string, namespace string, metricName string, dimensions []*cloudwatch.DimensionFilter) (*cloudwatch.ListMetricsOutput, error) { |
|
|
|
|
func (e *cloudWatchExecutor) cloudwatchListMetrics(region string, namespace string, metricName string, |
|
|
|
|
dimensions []*cloudwatch.DimensionFilter) (*cloudwatch.ListMetricsOutput, error) { |
|
|
|
|
svc, err := e.getCWClient(region) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
@ -706,6 +711,7 @@ func (e *cloudWatchExecutor) getAllMetrics(region string) (cloudwatch.ListMetric |
|
|
|
|
Namespace: aws.String(dsInfo.Namespace), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
plog.Debug("Listing metrics pages") |
|
|
|
|
var resp cloudwatch.ListMetricsOutput |
|
|
|
|
err = client.ListMetricsPages(params, func(page *cloudwatch.ListMetricsOutput, lastPage bool) bool { |
|
|
|
|
metrics.MAwsCloudWatchListMetrics.Inc() |
|
|
|
|
@ -726,6 +732,7 @@ func (e *cloudWatchExecutor) getAllMetrics(region string) (cloudwatch.ListMetric |
|
|
|
|
var metricsCacheLock sync.Mutex |
|
|
|
|
|
|
|
|
|
func (e *cloudWatchExecutor) getMetricsForCustomMetrics(region, namespace string) ([]string, error) { |
|
|
|
|
plog.Debug("Getting metrics for custom metrics", "region", region, "namespace", namespace) |
|
|
|
|
metricsCacheLock.Lock() |
|
|
|
|
defer metricsCacheLock.Unlock() |
|
|
|
|
|
|
|
|
|
@ -750,6 +757,7 @@ func (e *cloudWatchExecutor) getMetricsForCustomMetrics(region, namespace string |
|
|
|
|
if err != nil { |
|
|
|
|
return []string{}, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = make([]string, 0) |
|
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Expire = time.Now().Add(5 * time.Minute) |
|
|
|
|
|
|
|
|
|
@ -757,7 +765,8 @@ func (e *cloudWatchExecutor) getMetricsForCustomMetrics(region, namespace string |
|
|
|
|
if isDuplicate(customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *metric.MetricName) { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = append(customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *metric.MetricName) |
|
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = append( |
|
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *metric.MetricName) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, nil |
|
|
|
|
@ -797,7 +806,8 @@ func (e *cloudWatchExecutor) getDimensionsForCustomMetrics(region string) ([]str |
|
|
|
|
if isDuplicate(customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *dimension.Name) { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = append(customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *dimension.Name) |
|
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = append( |
|
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *dimension.Name) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|