@@ -73,6 +73,17 @@ func (m *MockEC2Client) DescribeInstancesRequest(input *ec2.DescribeInstancesInp
73
73
privateDNSName := "ip-5-6-7-8.us-west-1.compute.internal"
74
74
privateIP := "5.6.7.8"
75
75
76
+ tags := []ec2.Tag {
77
+ {
78
+ Key : awssdk .String ("app.kubernetes.io/name" ),
79
+ Value : awssdk .String ("foo" ),
80
+ },
81
+ {
82
+ Key : awssdk .String ("helm.sh/chart" ),
83
+ Value : awssdk .String ("foo-chart" ),
84
+ },
85
+ }
86
+
76
87
instance := ec2.Instance {
77
88
InstanceId : awssdk .String (instanceID ),
78
89
InstanceType : ec2 .InstanceTypeT2Medium ,
@@ -95,6 +106,7 @@ func (m *MockEC2Client) DescribeInstancesRequest(input *ec2.DescribeInstancesInp
95
106
PublicIpAddress : & publicIP ,
96
107
PrivateDnsName : & privateDNSName ,
97
108
PrivateIpAddress : & privateIP ,
109
+ Tags : tags ,
98
110
}
99
111
100
112
httpReq , _ := http .NewRequest ("" , "" , nil )
@@ -126,7 +138,7 @@ func TestGetInstanceIDs(t *testing.T) {
126
138
assert .Equal (t , awssdk .String ("us-west-1a" ), instancesOutputs [instanceID ].Placement .AvailabilityZone )
127
139
}
128
140
129
- func TestCreateCloudWatchEvents (t * testing.T ) {
141
+ func TestCreateCloudWatchEventsDedotTags (t * testing.T ) {
130
142
expectedEvent := mb.Event {
131
143
RootFields : common.MapStr {
132
144
"cloud" : common.MapStr {
@@ -156,6 +168,10 @@ func TestCreateCloudWatchEvents(t *testing.T) {
156
168
"ip" : "5.6.7.8" ,
157
169
},
158
170
},
171
+ "tags" : common.MapStr {
172
+ "app_kubernetes_io/name" : "foo" ,
173
+ "helm_sh/chart" : "foo-chart" ,
174
+ },
159
175
},
160
176
}
161
177
svcEC2Mock := & MockEC2Client {}
@@ -203,6 +219,7 @@ func TestCreateCloudWatchEvents(t *testing.T) {
203
219
assert .Equal (t , expectedEvent .RootFields , events [instanceID ].RootFields )
204
220
assert .Equal (t , expectedEvent .MetricSetFields ["cpu" ], events [instanceID ].MetricSetFields ["cpu" ])
205
221
assert .Equal (t , expectedEvent .MetricSetFields ["instance" ], events [instanceID ].MetricSetFields ["instance" ])
222
+ assert .Equal (t , expectedEvent .MetricSetFields ["tags" ], events [instanceID ].ModuleFields ["tags" ])
206
223
}
207
224
208
225
func TestConstructMetricQueries (t * testing.T ) {
0 commit comments