Cloudwatch: Use the metric map from grafana-aws-sdk (#88733)

This commit is contained in:
Isabella Siu
2024-06-06 21:25:54 +03:00
committed by GitHub
parent 79f9d529d3
commit cd15e9732d
12 changed files with 134 additions and 753 deletions
@@ -3,14 +3,14 @@ package services
import (
"fmt"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/constants"
"github.com/grafana/grafana-aws-sdk/pkg/cloudWatchConsts"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
)
var GetHardCodedDimensionKeysByNamespace = func(namespace string) ([]resources.ResourceResponse[string], error) {
var response []string
exists := false
if response, exists = constants.NamespaceDimensionKeysMap[namespace]; !exists {
if response, exists = cloudWatchConsts.NamespaceDimensionKeysMap[namespace]; !exists {
return nil, fmt.Errorf("unable to find dimensions for namespace '%q'", namespace)
}
return valuesToListMetricRespone(response), nil
@@ -20,7 +20,7 @@ var GetHardCodedMetricsByNamespace = func(namespace string) ([]resources.Resourc
response := []resources.Metric{}
exists := false
var metrics []string
if metrics, exists = constants.NamespaceMetricsMap[namespace]; !exists {
if metrics, exists = cloudWatchConsts.NamespaceMetricsMap[namespace]; !exists {
return nil, fmt.Errorf("unable to find metrics for namespace '%q'", namespace)
}
@@ -33,7 +33,7 @@ var GetHardCodedMetricsByNamespace = func(namespace string) ([]resources.Resourc
var GetAllHardCodedMetrics = func() []resources.ResourceResponse[resources.Metric] {
response := []resources.Metric{}
for namespace, metrics := range constants.NamespaceMetricsMap {
for namespace, metrics := range cloudWatchConsts.NamespaceMetricsMap {
for _, metric := range metrics {
response = append(response, resources.Metric{Namespace: namespace, Name: metric})
}
@@ -44,7 +44,7 @@ var GetAllHardCodedMetrics = func() []resources.ResourceResponse[resources.Metri
var GetHardCodedNamespaces = func() []resources.ResourceResponse[string] {
response := []string{}
for key := range constants.NamespaceMetricsMap {
for key := range cloudWatchConsts.NamespaceMetricsMap {
response = append(response, key)
}