@@ -18,197 +18,8 @@ function (angular, _) {
18
18
this . supportMetrics = true ;
19
19
this . proxyUrl = datasource . url ;
20
20
this . defaultRegion = datasource . jsonData . defaultRegion ;
21
-
22
- /* jshint -W101 */
23
-
24
- this . supportedMetrics = {
25
- 'AWS/AutoScaling' : [
26
- 'GroupMinSize' , 'GroupMaxSize' , 'GroupDesiredCapacity' , 'GroupInServiceInstances' , 'GroupPendingInstances' , 'GroupStandbyInstances' , 'GroupTerminatingInstances' , 'GroupTotalInstances'
27
- ] ,
28
- 'AWS/Billing' : [
29
- 'EstimatedCharges'
30
- ] ,
31
- 'AWS/CloudFront' : [
32
- 'Requests' , 'BytesDownloaded' , 'BytesUploaded' , 'TotalErrorRate' , '4xxErrorRate' , '5xxErrorRate'
33
- ] ,
34
- 'AWS/CloudSearch' : [
35
- 'SuccessfulRequests' , 'SearchableDocuments' , 'IndexUtilization' , 'Partitions'
36
- ] ,
37
- 'AWS/DynamoDB' : [
38
- 'ConditionalCheckFailedRequests' , 'ConsumedReadCapacityUnits' , 'ConsumedWriteCapacityUnits' , 'OnlineIndexConsumedWriteCapacity' , 'OnlineIndexPercentageProgress' , 'OnlineIndexThrottleEvents' , 'ProvisionedReadCapacityUnits' , 'ProvisionedWriteCapacityUnits' , 'ReadThrottleEvents' , 'ReturnedItemCount' , 'SuccessfulRequestLatency' , 'SystemErrors' , 'ThrottledRequests' , 'UserErrors' , 'WriteThrottleEvents'
39
- ] ,
40
- 'AWS/ElastiCache' : [
41
- 'CPUUtilization' , 'SwapUsage' , 'FreeableMemory' , 'NetworkBytesIn' , 'NetworkBytesOut' ,
42
- 'BytesUsedForCacheItems' , 'BytesReadIntoMemcached' , 'BytesWrittenOutFromMemcached' , 'CasBadval' , 'CasHits' , 'CasMisses' , 'CmdFlush' , 'CmdGet' , 'CmdSet' , 'CurrConnections' , 'CurrItems' , 'DecrHits' , 'DecrMisses' , 'DeleteHits' , 'DeleteMisses' , 'Evictions' , 'GetHits' , 'GetMisses' , 'IncrHits' , 'IncrMisses' , 'Reclaimed' ,
43
- 'CurrConnections' , 'Evictions' , 'Reclaimed' , 'NewConnections' , 'BytesUsedForCache' , 'CacheHits' , 'CacheMisses' , 'ReplicationLag' , 'GetTypeCmds' , 'SetTypeCmds' , 'KeyBasedCmds' , 'StringBasedCmds' , 'HashBasedCmds' , 'ListBasedCmds' , 'SetBasedCmds' , 'SortedSetBasedCmds' , 'CurrItems'
44
- ] ,
45
- 'AWS/EBS' : [
46
- 'VolumeReadBytes' , 'VolumeWriteBytes' , 'VolumeReadOps' , 'VolumeWriteOps' , 'VolumeTotalReadTime' , 'VolumeTotalWriteTime' , 'VolumeIdleTime' , 'VolumeQueueLength' , 'VolumeThroughputPercentage' , 'VolumeConsumedReadWriteOps'
47
- ] ,
48
- 'AWS/EC2' : [
49
- 'CPUCreditUsage' , 'CPUCreditBalance' , 'CPUUtilization' , 'DiskReadOps' , 'DiskWriteOps' , 'DiskReadBytes' , 'DiskWriteBytes' , 'NetworkIn' , 'NetworkOut' , 'StatusCheckFailed' , 'StatusCheckFailed_Instance' , 'StatusCheckFailed_System'
50
- ] ,
51
- 'AWS/ELB' : [
52
- 'HealthyHostCount' , 'UnHealthyHostCount' , 'RequestCount' , 'Latency' , 'HTTPCode_ELB_4XX' , 'HTTPCode_ELB_5XX' , 'HTTPCode_Backend_2XX' , 'HTTPCode_Backend_3XX' , 'HTTPCode_Backend_4XX' , 'HTTPCode_Backend_5XX' , 'BackendConnectionErrors' , 'SurgeQueueLength' , 'SpilloverCount'
53
- ] ,
54
- 'AWS/ElasticMapReduce' : [
55
- 'CoreNodesPending' , 'CoreNodesRunning' , 'HBaseBackupFailed' , 'HBaseMostRecentBackupDuration' , 'HBaseTimeSinceLastSuccessfulBackup' , 'HDFSBytesRead' , 'HDFSBytesWritten' , 'HDFSUtilization' , 'IsIdle' , 'JobsFailed' , 'JobsRunning' , 'LiveDataNodes' , 'LiveTaskTrackers' , 'MapSlotsOpen' , 'MissingBlocks' , 'ReduceSlotsOpen' , 'RemainingMapTasks' , 'RemainingMapTasksPerSlot' , 'RemainingReduceTasks' , 'RunningMapTasks' , 'RunningReduceTasks' , 'S3BytesRead' , 'S3BytesWritten' , 'TaskNodesPending' , 'TaskNodesRunning' , 'TotalLoad'
56
- ] ,
57
- 'AWS/Kinesis' : [
58
- 'PutRecord.Bytes' , 'PutRecord.Latency' , 'PutRecord.Success' , 'PutRecords.Bytes' , 'PutRecords.Latency' , 'PutRecords.Records' , 'PutRecords.Success' , 'IncomingBytes' , 'IncomingRecords' , 'GetRecords.Bytes' , 'GetRecords.IteratorAgeMilliseconds' , 'GetRecords.Latency' , 'GetRecords.Success'
59
- ] ,
60
- 'AWS/ML' : [
61
- 'PredictCount' , 'PredictFailureCount'
62
- ] ,
63
- 'AWS/OpsWorks' : [
64
- 'cpu_idle' , 'cpu_nice' , 'cpu_system' , 'cpu_user' , 'cpu_waitio' , 'load_1' , 'load_5' , 'load_15' , 'memory_buffers' , 'memory_cached' , 'memory_free' , 'memory_swap' , 'memory_total' , 'memory_used' , 'procs'
65
- ] ,
66
- 'AWS/Redshift' : [
67
- 'CPUUtilization' , 'DatabaseConnections' , 'HealthStatus' , 'MaintenanceMode' , 'NetworkReceiveThroughput' , 'NetworkTransmitThroughput' , 'PercentageDiskSpaceUsed' , 'ReadIOPS' , 'ReadLatency' , 'ReadThroughput' , 'WriteIOPS' , 'WriteLatency' , 'WriteThroughput'
68
- ] ,
69
- 'AWS/RDS' : [
70
- 'BinLogDiskUsage' , 'CPUUtilization' , 'DatabaseConnections' , 'DiskQueueDepth' , 'FreeableMemory' , 'FreeStorageSpace' , 'ReplicaLag' , 'SwapUsage' , 'ReadIOPS' , 'WriteIOPS' , 'ReadLatency' , 'WriteLatency' , 'ReadThroughput' , 'WriteThroughput' , 'NetworkReceiveThroughput' , 'NetworkTransmitThroughput'
71
- ] ,
72
- 'AWS/Route53' : [
73
- 'HealthCheckStatus' , 'HealthCheckPercentageHealthy'
74
- ] ,
75
- 'AWS/SNS' : [
76
- 'NumberOfMessagesPublished' , 'PublishSize' , 'NumberOfNotificationsDelivered' , 'NumberOfNotificationsFailed'
77
- ] ,
78
- 'AWS/SQS' : [
79
- 'NumberOfMessagesSent' , 'SentMessageSize' , 'NumberOfMessagesReceived' , 'NumberOfEmptyReceives' , 'NumberOfMessagesDeleted' , 'ApproximateNumberOfMessagesDelayed' , 'ApproximateNumberOfMessagesVisible' , 'ApproximateNumberOfMessagesNotVisible'
80
- ] ,
81
- 'AWS/S3' : [
82
- 'BucketSizeBytes' , 'NumberOfObjects'
83
- ] ,
84
- 'AWS/SWF' : [
85
- 'DecisionTaskScheduleToStartTime' , 'DecisionTaskStartToCloseTime' , 'DecisionTasksCompleted' , 'StartedDecisionTasksTimedOutOnClose' , 'WorkflowStartToCloseTime' , 'WorkflowsCanceled' , 'WorkflowsCompleted' , 'WorkflowsContinuedAsNew' , 'WorkflowsFailed' , 'WorkflowsTerminated' , 'WorkflowsTimedOut'
86
- ] ,
87
- 'AWS/StorageGateway' : [
88
- 'CacheHitPercent' , 'CachePercentUsed' , 'CachePercentDirty' , 'CloudBytesDownloaded' , 'CloudDownloadLatency' , 'CloudBytesUploaded' , 'UploadBufferFree' , 'UploadBufferPercentUsed' , 'UploadBufferUsed' , 'QueuedWrites' , 'ReadBytes' , 'ReadTime' , 'TotalCacheSize' , 'WriteBytes' , 'WriteTime' , 'WorkingStorageFree' , 'WorkingStoragePercentUsed' , 'WorkingStorageUsed' , 'CacheHitPercent' , 'CachePercentUsed' , 'CachePercentDirty' , 'ReadBytes' , 'ReadTime' , 'WriteBytes' , 'WriteTime' , 'QueuedWrites'
89
- ] ,
90
- 'AWS/WorkSpaces' : [
91
- 'Available' , 'Unhealthy' , 'ConnectionAttempt' , 'ConnectionSuccess' , 'ConnectionFailure' , 'SessionLaunchTime' , 'InSessionLatency' , 'SessionDisconnect'
92
- ] ,
93
- } ;
94
-
95
- this . supportedDimensions = {
96
- 'AWS/AutoScaling' : [
97
- 'AutoScalingGroupName'
98
- ] ,
99
- 'AWS/Billing' : [
100
- 'ServiceName' , 'LinkedAccount' , 'Currency'
101
- ] ,
102
- 'AWS/CloudFront' : [
103
- 'DistributionId' , 'Region'
104
- ] ,
105
- 'AWS/CloudSearch' : [
106
-
107
- ] ,
108
- 'AWS/DynamoDB' : [
109
- 'TableName' , 'GlobalSecondaryIndexName' , 'Operation'
110
- ] ,
111
- 'AWS/ElastiCache' : [
112
- 'CacheClusterId' , 'CacheNodeId'
113
- ] ,
114
- 'AWS/EBS' : [
115
- 'VolumeId'
116
- ] ,
117
- 'AWS/EC2' : [
118
- 'AutoScalingGroupName' , 'ImageId' , 'InstanceId' , 'InstanceType'
119
- ] ,
120
- 'AWS/ELB' : [
121
- 'LoadBalancerName' , 'AvailabilityZone'
122
- ] ,
123
- 'AWS/ElasticMapReduce' : [
124
- 'ClusterId' , 'JobId'
125
- ] ,
126
- 'AWS/Kinesis' : [
127
- 'StreamName'
128
- ] ,
129
- 'AWS/ML' : [
130
- 'MLModelId' , 'RequestMode'
131
- ] ,
132
- 'AWS/OpsWorks' : [
133
- 'StackId' , 'LayerId' , 'InstanceId'
134
- ] ,
135
- 'AWS/Redshift' : [
136
- 'NodeID' , 'ClusterIdentifier'
137
- ] ,
138
- 'AWS/RDS' : [
139
- 'DBInstanceIdentifier' , 'DatabaseClass' , 'EngineName'
140
- ] ,
141
- 'AWS/Route53' : [
142
- 'HealthCheckId'
143
- ] ,
144
- 'AWS/SNS' : [
145
- 'Application' , 'Platform' , 'TopicName'
146
- ] ,
147
- 'AWS/SQS' : [
148
- 'QueueName'
149
- ] ,
150
- 'AWS/S3' : [
151
- 'BucketName' , 'StorageType'
152
- ] ,
153
- 'AWS/SWF' : [
154
- 'Domain' , 'ActivityTypeName' , 'ActivityTypeVersion'
155
- ] ,
156
- 'AWS/StorageGateway' : [
157
- 'GatewayId' , 'GatewayName' , 'VolumeId'
158
- ] ,
159
- 'AWS/WorkSpaces' : [
160
- 'DirectoryId' , 'WorkspaceId'
161
- ] ,
162
- } ;
163
- /* jshint +W101 */
164
-
165
- /* load custom metrics definitions */
166
- var self = this ;
167
- $q . all (
168
- _ . chain ( datasource . jsonData . customMetricsAttributes )
169
- . reject ( function ( u ) {
170
- return _ . isEmpty ( u ) ;
171
- } )
172
- . map ( function ( u ) {
173
- return backendSrv . datasourceRequest ( { method : 'GET' , url : u } ) ;
174
- } )
175
- )
176
- . then ( function ( allResponse ) {
177
- _ . chain ( allResponse )
178
- . map ( function ( d ) {
179
- return d . data . Metrics ;
180
- } )
181
- . flatten ( )
182
- . reject ( function ( metric ) {
183
- return metric . Namespace . indexOf ( 'AWS/' ) === 0 ;
184
- } )
185
- . map ( function ( metric ) {
186
- metric . Dimensions = _ . chain ( metric . Dimensions )
187
- . map ( function ( d ) {
188
- return d . Name ;
189
- } )
190
- . value ( ) . sort ( ) ;
191
- return metric ;
192
- } )
193
- . uniq ( function ( metric ) {
194
- return metric . Namespace + metric . MetricName + metric . Dimensions . join ( '' ) ;
195
- } )
196
- . each ( function ( metric ) {
197
- if ( ! _ . has ( self . supportedMetrics , metric . Namespace ) ) {
198
- self . supportedMetrics [ metric . Namespace ] = [ ] ;
199
- }
200
- self . supportedMetrics [ metric . Namespace ] . push ( metric . MetricName ) ;
201
-
202
- if ( ! _ . has ( self . supportedDimensions , metric . Namespace ) ) {
203
- self . supportedDimensions [ metric . Namespace ] = [ ] ;
204
- }
205
-
206
- self . supportedDimensions [ metric . Namespace ] = _ . union ( self . supportedDimensions [ metric . Namespace ] , metric . Dimensions ) ;
207
- } ) ;
208
- } ) ;
209
21
}
210
22
211
- // Called once per panel (graph)
212
23
CloudWatchDatasource . prototype . query = function ( options ) {
213
24
var start = convertToCloudWatchTime ( options . range . from ) ;
214
25
var end = convertToCloudWatchTime ( options . range . to ) ;
@@ -280,12 +91,16 @@ function (angular, _) {
280
91
} ;
281
92
282
93
CloudWatchDatasource . prototype . getNamespaces = function ( ) {
283
- return $q . when ( _ . keys ( this . supportedMetrics ) ) ;
94
+ return this . awsRequest ( { action : '__GetNamespaces' } ) ;
284
95
} ;
285
96
286
97
CloudWatchDatasource . prototype . getMetrics = function ( namespace ) {
287
- namespace = templateSrv . replace ( namespace ) ;
288
- return $q . when ( this . supportedMetrics [ namespace ] || [ ] ) ;
98
+ return this . awsRequest ( {
99
+ action : '__GetMetrics' ,
100
+ parameters : {
101
+ namespace : templateSrv . replace ( namespace )
102
+ }
103
+ } ) ;
289
104
} ;
290
105
291
106
CloudWatchDatasource . prototype . getDimensionKeys = function ( namespace ) {
@@ -342,13 +157,12 @@ function (angular, _) {
342
157
343
158
var namespaceQuery = query . match ( / ^ n a m e s p a c e s \( \) / ) ;
344
159
if ( namespaceQuery ) {
345
- return this . getNamespaces ( ) . then ( transformSuggestData ) ;
160
+ return this . getNamespaces ( ) ;
346
161
}
347
162
348
163
var metricNameQuery = query . match ( / ^ m e t r i c s \( ( [ ^ \) ] + ?) \) / ) ;
349
164
if ( metricNameQuery ) {
350
- namespace = templateSrv . replace ( metricNameQuery [ 1 ] ) ;
351
- return this . getMetrics ( namespace ) . then ( transformSuggestData ) ;
165
+ return this . getMetrics ( metricNameQuery [ 1 ] ) ;
352
166
}
353
167
354
168
var dimensionKeysQuery = query . match ( / ^ d i m e n s i o n _ k e y s \( ( [ ^ \) ] + ?) \) / ) ;
0 commit comments