-
Notifications
You must be signed in to change notification settings - Fork 196
/
ruleMetricNamespace.go
43 lines (35 loc) · 1.13 KB
/
ruleMetricNamespace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT
package emfprocessor
import (
"github.com/aws/amazon-cloudwatch-agent/translator"
"github.com/aws/amazon-cloudwatch-agent/translator/context"
"github.com/aws/amazon-cloudwatch-agent/translator/util/ecsutil"
)
const (
SectionKeyMetricNamespace = "metric_namespace"
ECSDefaultCloudWatchNamespace = "ECS/ContainerInsights/Prometheus"
K8SDefaultCloudWatchNamespace = "ContainerInsights/Prometheus"
EC2DefaultCloudWatchNamespace = "CWAgent/Prometheus"
)
type MetricNamespace struct {
}
func (d *MetricNamespace) ApplyRule(input interface{}) (returnKey string, returnVal interface{}) {
returnKey, returnVal = translator.DefaultCase(SectionKeyMetricNamespace, "", input)
if returnVal != "" {
return
}
if context.CurrentContext().RunInContainer() {
if ecsutil.GetECSUtilSingleton().IsECS() {
returnVal = ECSDefaultCloudWatchNamespace
} else {
returnVal = K8SDefaultCloudWatchNamespace
}
} else {
returnVal = EC2DefaultCloudWatchNamespace
}
return
}
func init() {
RegisterRule(SectionKeyMetricNamespace, new(MetricNamespace))
}