The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/tsdb/cloudwatch/services/hardcoded_metrics.go

52 lines
1.6 KiB

package services
import (
"fmt"
"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 = cloudWatchConsts.NamespaceDimensionKeysMap[namespace]; !exists {
return nil, fmt.Errorf("unable to find dimensions for namespace '%q'", namespace)
}
return valuesToListMetricRespone(response), nil
}
var GetHardCodedMetricsByNamespace = func(namespace string) ([]resources.ResourceResponse[resources.Metric], error) {
response := []resources.Metric{}
exists := false
var metrics []string
if metrics, exists = cloudWatchConsts.NamespaceMetricsMap[namespace]; !exists {
return nil, fmt.Errorf("unable to find metrics for namespace '%q'", namespace)
}
for _, metric := range metrics {
response = append(response, resources.Metric{Namespace: namespace, Name: metric})
}
return valuesToListMetricRespone(response), nil
}
var GetAllHardCodedMetrics = func() []resources.ResourceResponse[resources.Metric] {
response := []resources.Metric{}
for namespace, metrics := range cloudWatchConsts.NamespaceMetricsMap {
for _, metric := range metrics {
response = append(response, resources.Metric{Namespace: namespace, Name: metric})
}
}
return valuesToListMetricRespone(response)
}
var GetHardCodedNamespaces = func() []resources.ResourceResponse[string] {
response := []string{}
for key := range cloudWatchConsts.NamespaceMetricsMap {
response = append(response, key)
}
return valuesToListMetricRespone(response)
}