2015-10-02 04:54:35 -05:00
|
|
|
package cloudwatch
|
|
|
|
|
|
|
|
import (
|
2017-09-09 14:24:39 -05:00
|
|
|
"context"
|
2017-09-13 05:35:05 -05:00
|
|
|
"errors"
|
2018-01-19 02:24:44 -06:00
|
|
|
"fmt"
|
2017-09-19 04:55:11 -05:00
|
|
|
"reflect"
|
2017-09-13 05:35:05 -05:00
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
"sync"
|
2016-01-14 04:02:04 -06:00
|
|
|
"time"
|
2015-10-02 04:54:35 -05:00
|
|
|
|
2017-09-13 05:35:05 -05:00
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
|
|
"github.com/aws/aws-sdk-go/aws/awsutil"
|
|
|
|
"github.com/aws/aws-sdk-go/service/cloudwatch"
|
2017-09-19 04:09:57 -05:00
|
|
|
"github.com/aws/aws-sdk-go/service/ec2"
|
2019-01-09 15:06:27 -06:00
|
|
|
"github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi"
|
2017-09-09 14:24:39 -05:00
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
2019-02-23 16:35:26 -06:00
|
|
|
"github.com/grafana/grafana/pkg/infra/metrics"
|
2017-09-09 14:24:39 -05:00
|
|
|
"github.com/grafana/grafana/pkg/tsdb"
|
2020-07-24 01:37:24 -05:00
|
|
|
"github.com/grafana/grafana/pkg/util/errutil"
|
2015-10-02 04:54:35 -05:00
|
|
|
)
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
// Known AWS regions.
|
|
|
|
var knownRegions = []string{
|
2020-07-23 06:02:25 -05:00
|
|
|
"af-south-1", "ap-east-1", "ap-northeast-1", "ap-northeast-2", "ap-northeast-3", "ap-south-1", "ap-southeast-1",
|
2020-07-14 01:23:23 -05:00
|
|
|
"ap-southeast-2", "ca-central-1", "cn-north-1", "cn-northwest-1", "eu-central-1", "eu-north-1", "eu-west-1",
|
|
|
|
"eu-west-2", "eu-west-3", "me-south-1", "sa-east-1", "us-east-1", "us-east-2", "us-gov-east-1", "us-gov-west-1",
|
|
|
|
"us-iso-east-1", "us-isob-east-1", "us-west-1", "us-west-2",
|
|
|
|
}
|
|
|
|
|
2017-09-09 14:24:39 -05:00
|
|
|
type suggestData struct {
|
|
|
|
Text string
|
|
|
|
Value string
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
type customMetricsCache struct {
|
2016-01-14 04:02:04 -06:00
|
|
|
Expire time.Time
|
|
|
|
Cache []string
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
var customMetricsMetricsMap = make(map[string]map[string]map[string]*customMetricsCache)
|
|
|
|
var customMetricsDimensionsMap = make(map[string]map[string]map[string]*customMetricsCache)
|
2020-05-18 05:25:58 -05:00
|
|
|
var metricsMap = map[string][]string{
|
|
|
|
"AWS/ACMPrivateCA": {"CRLGenerated", "Failure", "MisconfiguredCRLBucket", "Success", "Time"},
|
2020-09-02 14:32:43 -05:00
|
|
|
"AWS/AmazonMQ": {"BurstBalance", "ConsumerCount", "CpuCreditBalance", "CpuUtilization", "CurrentConnectionsCount", "DequeueCount", "DispatchCount", "EnqueueCount", "EnqueueTime", "EstablishedConnectionsCount", "ExpiredCount", "HeapUsage", "InactiveDurableTopicSubscribersCount", "InFlightCount", "JobSchedulerStorePercentUsage", "JournalFilesForFastRecovery", "JournalFilesForFullRecovery", "MemoryUsage", "NetworkIn", "NetworkOut", "OpenTransactionCount", "ProducerCount", "QueueSize", "ReceiveCount", "StorePercentUsage", "TempPercentUsage", "TotalConsumerCount", "TotalDequeueCount", "TotalEnqueueCount", "TotalMessageCount", "TotalProducerCount", "VolumeReadOps", "VolumeWriteOps"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/ApiGateway": {"4XXError", "5XXError", "CacheHitCount", "CacheMissCount", "Count", "IntegrationLatency", "Latency"},
|
|
|
|
"AWS/AppStream": {"ActualCapacity", "AvailableCapacity", "CapacityUtilization", "DesiredCapacity", "InUseCapacity", "InsufficientCapacityError", "PendingCapacity", "RunningCapacity"},
|
|
|
|
"AWS/AppSync": {"4XXError", "5XXError", "Latency"},
|
|
|
|
"AWS/ApplicationELB": {"ActiveConnectionCount", "ClientTLSNegotiationErrorCount", "ConsumedLCUs", "ELBAuthError", "ELBAuthFailure", "ELBAuthLatency", "ELBAuthRefreshTokenSuccess", "ELBAuthSuccess", "ELBAuthUserClaimsSizeExceeded", "HTTPCode_ELB_3XX_Count", "HTTPCode_ELB_4XX_Count", "HTTPCode_ELB_5XX_Count", "HTTPCode_Target_2XX_Count", "HTTPCode_Target_3XX_Count", "HTTPCode_Target_4XX_Count", "HTTPCode_Target_5XX_Count", "HTTP_Fixed_Response_Count", "HTTP_Redirect_Count", "HTTP_Redirect_Url_Limit_Exceeded_Count", "HealthyHostCount", "IPv6ProcessedBytes", "IPv6RequestCount", "LambdaInternalError", "LambdaTargetProcessedBytes", "LambdaUserError", "NewConnectionCount", "NonStickyRequestCount", "ProcessedBytes", "RejectedConnectionCount", "RequestCount", "RequestCountPerTarget", "RuleEvaluations", "StandardProcessedBytes", "TargetConnectionErrorCount", "TargetResponseTime", "TargetTLSNegotiationErrorCount", "UnHealthyHostCount"},
|
|
|
|
"AWS/Athena": {"DataScannedInBytes", "EngineExecutionTime", "QueryPlanningTime", "QueryQueueTime", "QueryState", "QueryType", "ServiceProcessingTime", "TotalExecutionTime", "WorkGroup"},
|
|
|
|
"AWS/AutoScaling": {"GroupDesiredCapacity", "GroupInServiceInstances", "GroupMaxSize", "GroupMinSize", "GroupPendingInstances", "GroupStandbyInstances", "GroupTerminatingInstances", "GroupTotalInstances"},
|
|
|
|
"AWS/Billing": {"EstimatedCharges"},
|
|
|
|
"AWS/Chatbot": {"EventsThrottled", "EventsProcessed", "MessageDeliverySuccess", "MessageDeliveryFailure", "UnsupportedEvents"},
|
|
|
|
"AWS/CloudFront": {"4xxErrorRate", "5xxErrorRate", "BytesDownloaded", "BytesUploaded", "Requests", "TotalErrorRate"},
|
|
|
|
"AWS/CloudHSM": {"HsmKeysSessionOccupied", "HsmKeysTokenOccupied", "HsmSessionCount", "HsmSslCtxsOccupied", "HsmTemperature", "HsmUnhealthy", "HsmUsersAvailable", "HsmUsersMax", "InterfaceEth2OctetsInput", "InterfaceEth2OctetsOutput"},
|
|
|
|
"AWS/CloudSearch": {"IndexUtilization", "Partitions", "SearchableDocuments", "SuccessfulRequests"},
|
|
|
|
"AWS/CodeBuild": {"BuildDuration", "Builds", "DownloadSourceDuration", "Duration", "FailedBuilds", "FinalizingDuration", "InstallDuration", "PostBuildDuration", "PreBuildDuration", "ProvisioningDuration", "QueuedDuration", "SubmittedDuration", "SucceededBuilds", "UploadArtifactsDuration"},
|
|
|
|
"AWS/Cognito": {"AccountTakeOverRisk", "CompromisedCredentialsRisk", "NoRisk", "OverrideBlock", "Risk"},
|
|
|
|
"AWS/Connect": {"CallBackNotDialableNumber", "CallRecordingUploadError", "CallsBreachingConcurrencyQuota", "CallsPerInterval", "ConcurrentCalls", "ConcurrentCallsPercentage", "ContactFlowErrors", "ContactFlowFatalErrors", "LongestQueueWaitTime", "MisconfiguredPhoneNumbers", "MissedCalls", "PublicSigningKeyUsage", "QueueCapacityExceededError", "QueueSize", "ThrottledCalls", "ToInstancePacketLossRate"},
|
2020-05-25 08:05:52 -05:00
|
|
|
"AWS/DataSync": {"BytesVerifiedSource", "BytesPreparedSource", "FilesVerifiedSource", "FilesPreparedSource", "BytesVerifiedDestination", "BytesPreparedDestination", "FilesVerifiedDestination", "FilesPreparedDestination", "FilesTransferred", "BytesTransferred", "BytesWritten"},
|
2020-05-25 10:14:28 -05:00
|
|
|
"AWS/DDoSProtection": {"DDoSDetected", "DDoSAttackBitsPerSecond", "DDoSAttackPacketsPerSecond", "DDoSAttackRequestsPerSecond"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/DMS": {"CDCChangesDiskSource", "CDCChangesDiskTarget", "CDCChangesMemorySource", "CDCChangesMemoryTarget", "CDCIncomingChanges", "CDCLatencySource", "CDCLatencyTarget", "CDCThroughputBandwidthSource", "CDCThroughputBandwidthTarget", "CDCThroughputRowsSource", "CDCThroughputRowsTarget", "CPUUtilization", "FreeStorageSpace", "FreeableMemory", "FullLoadThroughputBandwidthSource", "FullLoadThroughputBandwidthTarget", "FullLoadThroughputRowsSource", "FullLoadThroughputRowsTarget", "NetworkReceiveThroughput", "NetworkTransmitThroughput", "ReadIOPS", "ReadLatency", "ReadThroughput", "SwapUsage", "WriteIOPS", "WriteLatency", "WriteThroughput"},
|
|
|
|
"AWS/DocDB": {"BackupRetentionPeriodStorageUsed", "BufferCacheHitRatio", "ChangeStreamLogSize", "CPUUtilization", "DatabaseConnections", "DBInstanceReplicaLag", "DBClusterReplicaLagMaximum", "DBClusterReplicaLagMinimum", "DiskQueueDepth", "EngineUptime", "FreeableMemory", "FreeLocalStorage", "NetworkReceiveThroughput", "NetworkThroughput", "NetworkTransmitThroughput", "ReadIOPS", "ReadLatency", "ReadThroughput", "SnapshotStorageUsed", "SwapUsage", "TotalBackupStorageBilled", "VolumeBytesUsed", "VolumeReadIOPs", "VolumeWriteIOPs", "WriteIOPS", "WriteLatency", "WriteThroughput"},
|
2020-10-05 11:19:40 -05:00
|
|
|
"AWS/DX": {"ConnectionBpsEgress", "ConnectionBpsIngress", "ConnectionCRCErrorCount", "ConnectionLightLevelRx", "ConnectionLightLevelTx", "ConnectionPpsEgress", "ConnectionPpsIngress", "ConnectionState", "VirtualInterfaceBpsEgress", "VirtualInterfaceBpsIngress", "VirtualInterfacePpsEgress", "VirtualInterfacePpsIngress"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/DAX": {"CPUUtilization", "NetworkPacketsIn", "NetworkPacketsOut", "GetItemRequestCount", "BatchGetItemRequestCount", "BatchWriteItemRequestCount", "DeleteItemRequestCount", "PutItemRequestCount", "UpdateItemRequestCount", "TransactWriteItemsCount", "TransactGetItemsCount", "ItemCacheHits", "ItemCacheMisses", "QueryCacheHits", "QueryCacheMisses", "ScanCacheHits", "ScanCacheMisses", "TotalRequestCount", "ErrorRequestCount", "FaultRequestCount", "FailedRequestCount", "QueryRequestCount", "ScanRequestCount", "ClientConnections", "EstimatedDbSize", "EvictedSize"},
|
|
|
|
"AWS/DynamoDB": {"ConditionalCheckFailedRequests", "ConsumedReadCapacityUnits", "ConsumedWriteCapacityUnits", "OnlineIndexConsumedWriteCapacity", "OnlineIndexPercentageProgress", "OnlineIndexThrottleEvents", "PendingReplicationCount", "ProvisionedReadCapacityUnits", "ProvisionedWriteCapacityUnits", "ReadThrottleEvents", "ReplicationLatency", "ReturnedBytes", "ReturnedItemCount", "ReturnedRecordsCount", "SuccessfulRequestLatency", "SystemErrors", "ThrottledRequests", "TimeToLiveDeletedItemCount", "UserErrors", "WriteThrottleEvents"},
|
|
|
|
"AWS/EBS": {"BurstBalance", "VolumeConsumedReadWriteOps", "VolumeIdleTime", "VolumeQueueLength", "VolumeReadBytes", "VolumeReadOps", "VolumeThroughputPercentage", "VolumeTotalReadTime", "VolumeTotalWriteTime", "VolumeWriteBytes", "VolumeWriteOps"},
|
|
|
|
"AWS/EC2": {"CPUCreditBalance", "CPUCreditUsage", "CPUSurplusCreditBalance", "CPUSurplusCreditsCharged", "CPUUtilization", "DiskReadBytes", "DiskReadOps", "DiskWriteBytes", "DiskWriteOps", "EBSByteBalance%", "EBSIOBalance%", "EBSReadBytes", "EBSReadOps", "EBSWriteBytes", "EBSWriteOps", "NetworkIn", "NetworkOut", "NetworkPacketsIn", "NetworkPacketsOut", "StatusCheckFailed", "StatusCheckFailed_Instance", "StatusCheckFailed_System"},
|
|
|
|
"AWS/EC2/API": {"ClientErrors", "RequestLimitExceeded", "ServerErrors", "SuccessfulCalls"},
|
|
|
|
"AWS/EC2Spot": {"AvailableInstancePoolsCount", "BidsSubmittedForCapacity", "EligibleInstancePoolCount", "FulfilledCapacity", "MaxPercentCapacityAllocation", "PendingCapacity", "PercentCapacityAllocation", "TargetCapacity", "TerminatingCapacity"},
|
|
|
|
"AWS/ECS": {"CPUReservation", "CPUUtilization", "GPUReservation", "MemoryReservation", "MemoryUtilization"},
|
|
|
|
"AWS/EFS": {"BurstCreditBalance", "ClientConnections", "DataReadIOBytes", "DataWriteIOBytes", "MetadataIOBytes", "PercentIOLimit", "PermittedThroughput", "TotalIOBytes"},
|
|
|
|
"AWS/ELB": {"BackendConnectionErrors", "EstimatedALBActiveConnectionCount", "EstimatedALBConsumedLCUs", "EstimatedALBNewConnectionCount", "EstimatedProcessedBytes", "HTTPCode_Backend_2XX", "HTTPCode_Backend_3XX", "HTTPCode_Backend_4XX", "HTTPCode_Backend_5XX", "HTTPCode_ELB_4XX", "HTTPCode_ELB_5XX", "HealthyHostCount", "Latency", "RequestCount", "SpilloverCount", "SurgeQueueLength", "UnHealthyHostCount"},
|
|
|
|
"AWS/ES": {"AutomatedSnapshotFailure", "CPUCreditBalance", "CPUUtilization", "ClusterIndexWritesBlocked", "ClusterStatus.green", "ClusterStatus.red", "ClusterStatus.yellow", "ClusterUsedSpace", "DeletedDocuments", "DiskQueueDepth", "ElasticsearchRequests", "FreeStorageSpace", "IndexingLatency", "IndexingRate", "InvalidHostHeaderRequests", "JVMGCOldCollectionCount", "JVMGCOldCollectionTime", "JVMGCYoungCollectionCount", "JVMGCYoungCollectionTime", "JVMMemoryPressure", "KMSKeyError", "KMSKeyInaccessible", "KibanaHealthyNodes", "MasterCPUCreditBalance", "MasterCPUUtilization", "MasterFreeStorageSpace", "MasterJVMMemoryPressure", "MasterReachableFromNode", "Nodes", "ReadIOPS", "ReadLatency", "ReadThroughput", "RequestCount", "SearchLatency", "SearchRate", "SearchableDocuments", "SysMemoryUtilization", "ThreadpoolBulkQueue", "ThreadpoolBulkRejected", "ThreadpoolBulkThreads", "ThreadpoolForce_mergeQueue", "ThreadpoolForce_mergeRejected", "ThreadpoolForce_mergeThreads", "ThreadpoolIndexQueue", "ThreadpoolIndexRejected", "ThreadpoolIndexThreads", "ThreadpoolSearchQueue", "ThreadpoolSearchRejected", "ThreadpoolSearchThreads", "WriteIOPS", "WriteLatency", "WriteThroughput"},
|
|
|
|
"AWS/ElastiCache": {"ActiveDefragHits", "BytesReadIntoMemcached", "BytesUsedForCache", "BytesUsedForCacheItems", "BytesUsedForHash", "BytesWrittenOutFromMemcached", "CPUUtilization", "CacheHits", "CacheMisses", "CasBadval", "CasHits", "CasMisses", "CmdConfigGet", "CmdConfigSet", "CmdFlush", "CmdGet", "CmdSet", "CmdTouch", "CurrConfig", "CurrConnections", "CurrItems", "DecrHits", "DecrMisses", "DeleteHits", "DeleteMisses", "EngineCPUUtilization", "EvictedUnfetched", "Evictions", "ExpiredUnfetched", "FreeableMemory", "GetHits", "GetMisses", "GetTypeCmds", "HashBasedCmds", "HyperLogLogBasedCmds", "IncrHits", "IncrMisses", "KeyBasedCmds", "ListBasedCmds", "NetworkBytesIn", "NetworkBytesOut", "NewConnections", "NewItems", "Reclaimed", "ReplicationBytes", "ReplicationLag", "SaveInProgress", "SetBasedCmds", "SetTypeCmds", "SlabsMoved", "SortedSetBasedCmds", "StringBasedCmds", "SwapUsage", "TouchHits", "TouchMisses", "UnusedMemory"},
|
|
|
|
"AWS/ElasticBeanstalk": {"ApplicationLatencyP10", "ApplicationLatencyP50", "ApplicationLatencyP75", "ApplicationLatencyP85", "ApplicationLatencyP90", "ApplicationLatencyP95", "ApplicationLatencyP99", "ApplicationLatencyP99.9", "ApplicationRequests2xx", "ApplicationRequests3xx", "ApplicationRequests4xx", "ApplicationRequests5xx", "ApplicationRequestsTotal", "CPUIdle", "CPUIowait", "CPUIrq", "CPUNice", "CPUSoftirq", "CPUSystem", "CPUUser", "EnvironmentHealth", "InstanceHealth", "InstancesDegraded", "InstancesInfo", "InstancesNoData", "InstancesOk", "InstancesPending", "InstancesSevere", "InstancesUnknown", "InstancesWarning", "LoadAverage1min", "LoadAverage5min", "RootFilesystemUtil"},
|
|
|
|
"AWS/ElasticInference": {"AcceleratorHealthCheckFailed", "AcceleratorMemoryUsage", "ConnectivityCheckFailed"},
|
|
|
|
"AWS/ElasticMapReduce": {"AppsCompleted", "AppsFailed", "AppsKilled", "AppsPending", "AppsRunning", "AppsSubmitted", "BackupFailed", "CapacityRemainingGB", "Cluster Status", "ContainerAllocated", "ContainerPending", "ContainerPendingRatio", "ContainerReserved", "CoreNodesPending", "CoreNodesRunning", "CorruptBlocks", "DfsPendingReplicationBlocks", "HBase", "HDFSBytesRead", "HDFSBytesWritten", "HDFSUtilization", "HbaseBackupFailed", "IO", "IsIdle", "JobsFailed", "JobsRunning", "LiveDataNodes", "LiveTaskTrackers", "MRActiveNodes", "MRDecommissionedNodes", "MRLostNodes", "MRRebootedNodes", "MRTotalNodes", "MRUnhealthyNodes", "Map/Reduce", "MapSlotsOpen", "MapTasksRemaining", "MapTasksRunning", "MemoryAllocatedMB", "MemoryAvailableMB", "MemoryReservedMB", "MemoryTotalMB", "MissingBlocks", "MostRecentBackupDuration", "Node Status", "PendingDeletionBlocks", "ReduceSlotsOpen", "ReduceTasksRemaining", "ReduceTasksRunning", "RemainingMapTasksPerSlot", "S3BytesRead", "S3BytesWritten", "TaskNodesPending", "TaskNodesRunning", "TimeSinceLastSuccessfulBackup", "TotalLoad", "UnderReplicatedBlocks", "YARNMemoryAvailablePercentage"},
|
|
|
|
"AWS/ElasticTranscoder": {"Billed Audio Output", "Billed HD Output", "Billed SD Output", "Errors", "Jobs Completed", "Jobs Errored", "Outputs per Job", "Standby Time", "Throttles"},
|
|
|
|
"AWS/Events": {"DeadLetterInvocations", "FailedInvocations", "Invocations", "MatchedEvents", "ThrottledRules", "TriggeredRules"},
|
2020-07-22 09:11:53 -05:00
|
|
|
"AWS/FSx": {"DataReadBytes", "DataReadOperations", "DataWriteBytes", "DataWriteOperations", "FreeDataStorageCapacity", "FreeStorageCapacity", "MetadataOperations"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/Firehose": {"BackupToS3.Bytes", "BackupToS3.DataFreshness", "BackupToS3.Records", "BackupToS3.Success", "DataReadFromKinesisStream.Bytes", "DataReadFromKinesisStream.Records", "DeliveryToElasticsearch.Bytes", "DeliveryToElasticsearch.Records", "DeliveryToElasticsearch.Success", "DeliveryToRedshift.Bytes", "DeliveryToRedshift.Records", "DeliveryToRedshift.Success", "DeliveryToS3.Bytes", "DeliveryToS3.DataFreshness", "DeliveryToS3.Records", "DeliveryToS3.Success", "DeliveryToSplunk.Bytes", "DeliveryToSplunk.DataFreshness", "DeliveryToSplunk.Records", "DeliveryToSplunk.Success", "DescribeDeliveryStream.Latency", "DescribeDeliveryStream.Requests", "ExecuteProcessing.Duration", "ExecuteProcessing.Success", "FailedConversion.Bytes", "FailedConversion.Records", "IncomingBytes", "IncomingRecords", "KinesisMillisBehindLatest", "ListDeliveryStreams.Latency", "ListDeliveryStreams.Requests", "PutRecord.Bytes", "PutRecord.Latency", "PutRecord.Requests", "PutRecordBatch.Bytes", "PutRecordBatch.Latency", "PutRecordBatch.Records", "PutRecordBatch.Requests", "SucceedConversion.Bytes", "SucceedConversion.Records", "SucceedProcessing.Bytes", "SucceedProcessing.Records", "ThrottledDescribeStream", "ThrottledGetRecords", "ThrottledGetShardIterator", "UpdateDeliveryStream.Latency", "UpdateDeliveryStream.Requests"},
|
|
|
|
"AWS/GameLift": {"ActivatingGameSessions", "ActiveGameSessions", "ActiveInstances", "ActiveServerProcesses", "AvailableGameSessions", "AverageWaitTime", "CurrentPlayerSessions", "CurrentTickets", "DesiredInstances", "FirstChoiceNotViable", "FirstChoiceOutOfCapacity", "GameSessionInterruptions", "HealthyServerProcesses", "IdleInstances", "InstanceInterruptions", "LowestLatencyPlacement", "LowestPricePlacement", "MatchAcceptancesTimedOut", "MatchesAccepted", "MatchesCreated", "MatchesPlaced", "MatchesRejected", "MaxInstances", "MinInstances", "PercentAvailableGameSessions", "PercentHealthyServerProcesses", "PercentIdleInstances", "Placement", "PlacementsCanceled", "PlacementsFailed", "PlacementsStarted", "PlacementsSucceeded", "PlacementsTimedOut", "PlayerSessionActivations", "PlayersStarted", "QueueDepth", "RuleEvaluationsFailed", "RuleEvaluationsPassed", "ServerProcessAbnormalTerminations", "ServerProcessActivations", "ServerProcessTerminations", "TicketsFailed", "TicketsStarted", "TicketsTimedOut", "TimeToMatch", "TimeToTicketSuccess"},
|
|
|
|
"AWS/Glue": {"glue.driver.BlockManager.disk.diskSpaceUsed_MB", "glue.driver.ExecutorAllocationManager.executors.numberAllExecutors", "glue.driver.ExecutorAllocationManager.executors.numberMaxNeededExecutors", "glue.driver.aggregate.bytesRead", "glue.driver.aggregate.elapsedTime", "glue.driver.aggregate.numCompletedStages", "glue.driver.aggregate.numCompletedTasks", "glue.driver.aggregate.numFailedTasks", "glue.driver.aggregate.numKilledTasks", "glue.driver.aggregate.recordsRead", "glue.driver.aggregate.shuffleBytesWritten", "glue.driver.aggregate.shuffleLocalBytesRead", "glue.driver.jvm.heap.usage glue.executorId.jvm.heap.usage glue.ALL.jvm.heap.usage", "glue.driver.jvm.heap.used glue.executorId.jvm.heap.used glue.ALL.jvm.heap.used", "glue.driver.s3.filesystem.read_bytes glue.executorId.s3.filesystem.read_bytes glue.ALL.s3.filesystem.read_bytes", "glue.driver.s3.filesystem.write_bytes glue.executorId.s3.filesystem.write_bytes glue.ALL.s3.filesystem.write_bytes", "glue.driver.system.cpuSystemLoad glue.executorId.system.cpuSystemLoad glue.ALL.system.cpuSystemLoad"},
|
|
|
|
"AWS/Inspector": {"TotalAssessmentRunFindings", "TotalAssessmentRuns", "TotalHealthyAgents", "TotalMatchingAgents"},
|
|
|
|
"AWS/IoT": {"CanceledJobExecutionCount", "CanceledJobExecutionTotalCount", "ClientError", "Connect.AuthError", "Connect.ClientError", "Connect.ServerError", "Connect.Success", "Connect.Throttle", "DeleteThingShadow.Accepted", "FailedJobExecutionCount", "FailedJobExecutionTotalCount", "Failure", "GetThingShadow.Accepted", "InProgressJobExecutionCount", "InProgressJobExecutionTotalCount", "NonCompliantResources", "NumLogBatchesFailedToPublishThrottled", "NumLogEventsFailedToPublishThrottled", "ParseError", "Ping.Success", "PublishIn.AuthError", "PublishIn.ClientError", "PublishIn.ServerError", "PublishIn.Success", "PublishIn.Throttle", "PublishOut.AuthError", "PublishOut.ClientError", "PublishOut.Success", "QueuedJobExecutionCount", "QueuedJobExecutionTotalCount", "RejectedJobExecutionCount", "RejectedJobExecutionTotalCount", "RemovedJobExecutionCount", "RemovedJobExecutionTotalCount", "ResourcesEvaluated", "RuleMessageThrottled", "RuleNotFound", "RulesExecuted", "ServerError", "Subscribe.AuthError", "Subscribe.ClientError", "Subscribe.ServerError", "Subscribe.Success", "Subscribe.Throttle", "SuccededJobExecutionCount", "SuccededJobExecutionTotalCount", "Success", "TopicMatch", "Unsubscribe.ClientError", "Unsubscribe.ServerError", "Unsubscribe.Success", "Unsubscribe.Throttle", "UpdateThingShadow.Accepted", "Violations", "ViolationsCleared", "ViolationsInvalidated"},
|
|
|
|
"AWS/IoTAnalytics": {"ActionExecution", "ActivityExecutionError", "IncomingMessages"},
|
|
|
|
"AWS/KMS": {"SecondsUntilKeyMaterialExpiration"},
|
|
|
|
"AWS/Kafka": {"ActiveControllerCount", "BytesInPerSec", "BytesOutPerSec", "CpuIdle", "CpuSystem", "CpuUser", "FetchConsumerLocalTimeMsMean", "FetchConsumerRequestQueueTimeMsMean", "FetchConsumerResponseQueueTimeMsMean", "FetchConsumerResponseSendTimeMsMean", "FetchConsumerTotalTimeMsMean", "FetchFollowerLocalTimeMsMean", "FetchFollowerRequestQueueTimeMsMean", "FetchFollowerResponseQueueTimeMsMean", "FetchFollowerResponseSendTimeMsMean", "FetchFollowerTotalTimeMsMean", "FetchMessageConversionsPerSec", "FetchThrottleByteRate", "FetchThrottleQueueSize", "FetchThrottleTime", "GlobalPartitionCount", "GlobalTopicCount", "KafkaAppLogsDiskUsed", "KafkaDataLogsDiskUsed", "LeaderCount", "MemoryBuffered", "MemoryCached", "MemoryFree", "MemoryUsed", "MessagesInPerSec", "NetworkProcessorAvgIdlePercent", "NetworkRxDropped", "NetworkRxErrors", "NetworkRxPackets", "NetworkTxDropped", "NetworkTxErrors", "NetworkTxPackets", "OfflinePartitionsCount", "PartitionCount", "ProduceLocalTimeMsMean", "ProduceMessageConversionsPerSec", "ProduceMessageConversionsTimeMsMean", "ProduceRequestQueueTimeMsMean", "ProduceResponseQueueTimeMsMean", "ProduceResponseSendTimeMsMean", "ProduceThrottleByteRate", "ProduceThrottleQueueSize", "ProduceThrottleTime", "ProduceTotalTimeMsMean", "RequestBytesMean", "RequestExemptFromThrottleTime", "RequestHandlerAvgIdlePercent", "RequestThrottleQueueSize", "RequestThrottleTime", "RequestTime", "RootDiskUsed", "SwapFree", "SwapUsed", "UnderMinIsrPartitionCount", "UnderReplicatedPartitions", "ZooKeeperRequestLatencyMsMean", "ZooKeeperSessionState"},
|
|
|
|
"AWS/Kinesis": {"GetRecords.Bytes", "GetRecords.IteratorAge", "GetRecords.IteratorAgeMilliseconds", "GetRecords.Latency", "GetRecords.Records", "GetRecords.Success", "IncomingBytes", "IncomingRecords", "IteratorAgeMilliseconds", "OutgoingBytes", "OutgoingRecords", "PutRecord.Bytes", "PutRecord.Latency", "PutRecord.Success", "PutRecords.Bytes", "PutRecords.Latency", "PutRecords.Records", "PutRecords.Success", "ReadProvisionedThroughputExceeded", "SubscribeToShard.RateExceeded", "SubscribeToShard.Success", "SubscribeToShardEvent.Bytes", "SubscribeToShardEvent.MillisBehindLatest", "SubscribeToShardEvent.Records", "SubscribeToShardEvent.Success", "WriteProvisionedThroughputExceeded"},
|
|
|
|
"AWS/KinesisAnalytics": {"Bytes", "InputProcessing.DroppedRecords", "InputProcessing.Duration", "InputProcessing.OkBytes", "InputProcessing.OkRecords", "InputProcessing.ProcessingFailedRecords", "InputProcessing.Success", "KPUs", "LambdaDelivery.DeliveryFailedRecords", "LambdaDelivery.Duration", "LambdaDelivery.OkRecords", "MillisBehindLatest", "Records", "Success"},
|
|
|
|
"AWS/KinesisVideo": {"GetHLSMasterPlaylist.Latency", "GetHLSMasterPlaylist.Requests", "GetHLSMasterPlaylist.Success", "GetHLSMediaPlaylist.Latency", "GetHLSMediaPlaylist.Requests", "GetHLSMediaPlaylist.Success", "GetHLSStreamingSessionURL.Latency", "GetHLSStreamingSessionURL.Requests", "GetHLSStreamingSessionURL.Success", "GetMP4InitFragment.Latency", "GetMP4InitFragment.Requests", "GetMP4InitFragment.Success", "GetMP4MediaFragment.Latency", "GetMP4MediaFragment.OutgoingBytes", "GetMP4MediaFragment.Requests", "GetMP4MediaFragment.Success", "GetMedia.ConnectionErrors", "GetMedia.MillisBehindNow", "GetMedia.OutgoingBytes", "GetMedia.OutgoingFragments", "GetMedia.OutgoingFrames", "GetMedia.Requests", "GetMedia.Success", "GetMediaForFragmentList.OutgoingBytes", "GetMediaForFragmentList.OutgoingFragments", "GetMediaForFragmentList.OutgoingFrames", "GetMediaForFragmentList.Requests", "GetMediaForFragmentList.Success", "GetTSFragment.Latency", "GetTSFragment.OutgoingBytes", "GetTSFragment.Requests", "GetTSFragment.Success", "ListFragments.Latency", "PutMedia.ActiveConnections", "PutMedia.BufferingAckLatency", "PutMedia.ConnectionErrors", "PutMedia.ErrorAckCount", "PutMedia.FragmentIngestionLatency", "PutMedia.FragmentPersistLatency", "PutMedia.IncomingBytes", "PutMedia.IncomingFragments", "PutMedia.IncomingFrames", "PutMedia.Latency", "PutMedia.PersistedAckLatency", "PutMedia.ReceivedAckLatency", "PutMedia.Requests", "PutMedia.Success"},
|
|
|
|
"AWS/Lambda": {"ConcurrentExecutions", "DeadLetterErrors", "Duration", "Errors", "Invocations", "IteratorAge", "Throttles", "UnreservedConcurrentExecutions"},
|
|
|
|
"AWS/Lex": {"BotChannelAuthErrors", "BotChannelConfigurationErrors", "BotChannelInboundThrottledEvents", "BotChannelOutboundThrottledEvents", "BotChannelRequestCount", "BotChannelResponseCardErrors", "BotChannelSystemErrors", "MissedUtteranceCount", "RuntimeInvalidLambdaResponses", "RuntimeLambdaErrors", "RuntimePollyErrors", "RuntimeRequestCount", "RuntimeSucessfulRequestLatency", "RuntimeSystemErrors", "RuntimeThrottledEvents", "RuntimeUserErrors"},
|
|
|
|
"AWS/Logs": {"DeliveryErrors", "DeliveryThrottling", "ForwardedBytes", "ForwardedLogEvents", "IncomingBytes", "IncomingLogEvents"},
|
|
|
|
"AWS/ML": {"PredictCount", "PredictFailureCount"},
|
2020-07-07 02:16:20 -05:00
|
|
|
"AWS/MediaConnect": {"ARQRecovered", "ARQRequests", "BitRate", "CATError", "CRCError", "Connected", "ConnectedOutputs", "ContinuityCounter", "Disconnections", "DroppedPackets", "FECPackets", "FECRecovered", "NotRecoveredPackets", "OutputConnected", "OutputDisconnections", "OverflowPackets", "PATError", "PCRAccuracyError", "PCRError", "PIDError", "PMTError", "PTSError", "PacketLossPercent", "RecoveredPackets", "RoundTripTime", "SourceARQRecovered", "SourceARQRequests", "SourceBitRate", "SourceCATError", "SourceCRCError", "SourceConnected", "SourceContinuityCounter", "SourceDisconnections", "SourceDroppedPackets", "SourceFECPackets", "SourceFECRecovered", "SourceNotRecoveredPackets", "SourceOverflowPackets", "SourcePATError", "SourcePCRAccuracyError", "SourcePCRError", "SourcePIDError", "SourcePMTError", "SourcePTSError", "SourcePacketLossPercent", "SourceRecoveredPackets", "SourceRoundTripTime", "SourceTSByteError", "SourceTSSyncLoss", "SourceTotalPackets", "SourceTransportError", "TSByteError", "TSSyncLoss", "TotalPackets", "TransportError"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/MediaConvert": {"AudioOutputSeconds", "Errors", "HDOutputSeconds", "JobsCompletedCount", "JobsErroredCount", "SDOutputSeconds", "StandbyTime", "TranscodingTime", "UHDOutputSeconds"},
|
|
|
|
"AWS/MediaPackage": {"ActiveInput", "EgressBytes", "EgressRequestCount", "EgressResponseTime", "IngressBytes", "IngressResponseTime"},
|
2020-06-24 03:06:57 -05:00
|
|
|
"AWS/MediaStore": {"RequestCount", "4xxErrorCount", "5xxErrorCount", "BytesUploaded", "BytesDownloaded", "TotalTime", "TurnaroundTime"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/MediaTailor": {"AdDecisionServer.Ads", "AdDecisionServer.Duration", "AdDecisionServer.Errors", "AdDecisionServer.FillRate", "AdDecisionServer.Timeouts", "AdNotReady", "Avails.Duration", "Avails.FillRate", "Avails.FilledDuration", "GetManifest.Errors", "Origin.Errors", "Origin.Timeouts"},
|
|
|
|
"AWS/NATGateway": {"ActiveConnectionCount", "BytesInFromDestination", "BytesInFromSource", "BytesOutToDestination", "BytesOutToSource", "ConnectionAttemptCount", "ConnectionEstablishedCount", "ErrorPortAllocation", "IdleTimeoutCount", "PacketsDropCount", "PacketsInFromDestination", "PacketsInFromSource", "PacketsOutToDestination", "PacketsOutToSource"},
|
|
|
|
"AWS/Neptune": {"CPUUtilization", "ClusterReplicaLag", "ClusterReplicaLagMaximum", "ClusterReplicaLagMinimum", "EngineUptime", "FreeLocalStorage", "FreeableMemory", "GremlinErrors", "GremlinHttp1xx", "GremlinHttp2xx", "GremlinHttp4xx", "GremlinHttp5xx", "GremlinRequests", "GremlinRequestsPerSec", "GremlinWebSocketAvailableConnections", "GremlinWebSocketClientErrors", "GremlinWebSocketServerErrors", "GremlinWebSocketSuccess", "Http100", "Http101", "Http1xx", "Http200", "Http2xx", "Http400", "Http403", "Http405", "Http413", "Http429", "Http4xx", "Http500", "Http501", "Http5xx", "LoaderErrors", "LoaderRequests", "NetworkReceiveThroughput", "NetworkThroughput", "NetworkTransmitThroughput", "SparqlErrors", "SparqlHttp1xx", "SparqlHttp2xx", "SparqlHttp4xx", "SparqlHttp5xx", "SparqlRequests", "SparqlRequestsPerSec", "StatusErrors", "StatusRequests", "VolumeBytesUsed", "VolumeReadIOPs", "VolumeWriteIOPs"},
|
|
|
|
"AWS/NetworkELB": {"ActiveFlowCount", "ActiveFlowCount_TLS", "ClientTLSNegotiationErrorCount", "ConsumedLCUs", "HealthyHostCount", "NewFlowCount", "NewFlowCount_TLS", "ProcessedBytes", "ProcessedBytes_TLS", "TCP_Client_Reset_Count", "TCP_ELB_Reset_Count", "TCP_Target_Reset_Count", "TargetTLSNegotiationErrorCount", "UnHealthyHostCount"},
|
|
|
|
"AWS/OpsWorks": {"cpu_idle", "cpu_nice", "cpu_steal", "cpu_system", "cpu_user", "cpu_waitio", "load_1", "load_15", "load_5", "memory_buffers", "memory_cached", "memory_free", "memory_swap", "memory_total", "memory_used", "procs"},
|
|
|
|
"AWS/Polly": {"2XXCount", "4XXCount", "5XXCount", "RequestCharacters", "ResponseLatency"},
|
|
|
|
"AWS/RDS": {"ActiveTransactions", "AuroraBinlogReplicaLag", "AuroraGlobalDBDataTransferBytes", "AuroraGlobalDBReplicatedWriteIO", "AuroraGlobalDBReplicationLag", "AuroraReplicaLag", "AuroraReplicaLagMaximum", "AuroraReplicaLagMinimum", "BacktrackChangeRecordsCreationRate", "BacktrackChangeRecordsStored", "BacktrackWindowActual", "BacktrackWindowAlert", "BackupRetentionPeriodStorageUsed", "BinLogDiskUsage", "BlockedTransactions", "BufferCacheHitRatio", "BurstBalance", "CPUCreditBalance", "CPUCreditUsage", "CPUUtilization", "CommitLatency", "CommitThroughput", "DDLLatency", "DDLThroughput", "DMLLatency", "DMLThroughput", "DatabaseConnections", "Deadlocks", "DeleteLatency", "DeleteThroughput", "DiskQueueDepth", "EngineUptime", "FailedSQLServerAgentJobsCount", "FreeLocalStorage", "FreeStorageSpace", "FreeableMemory", "InsertLatency", "InsertThroughput", "LoginFailures", "MaximumUsedTransactionIDs", "NetworkReceiveThroughput", "NetworkThroughput", "NetworkTransmitThroughput", "OldestReplicationSlotLag", "Queries", "RDSToAuroraPostgreSQLReplicaLag", "ReadIOPS", "ReadLatency", "ReadThroughput", "ReplicaLag", "ReplicationSlotDiskUsage", "ResultSetCacheHitRatio", "SelectLatency", "SelectThroughput", "ServerlessDatabaseCapacity", "SnapshotStorageUsed", "SwapUsage", "TotalBackupStorageBilled", "TransactionLogsDiskUsage", "TransactionLogsGeneration", "UpdateLatency", "UpdateThroughput", "VolumeBytesUsed", "VolumeReadIOPs", "VolumeWriteIOPs", "WriteIOPS", "WriteLatency", "WriteThroughput"},
|
|
|
|
"AWS/Redshift": {"CPUUtilization", "DatabaseConnections", "HealthStatus", "MaintenanceMode", "NetworkReceiveThroughput", "NetworkTransmitThroughput", "PercentageDiskSpaceUsed", "QueriesCompletedPerSecond", "QueryDuration", "QueryRuntimeBreakdown", "ReadIOPS", "ReadLatency", "ReadThroughput", "TotalTableCount", "WLMQueriesCompletedPerSecond", "WLMQueryDuration", "WLMQueueLength", "WriteIOPS", "WriteLatency", "WriteThroughput"},
|
2020-05-27 05:00:25 -05:00
|
|
|
"AWS/Route53": {"ChildHealthCheckHealthyCount", "ConnectionTime", "DNSQueries", "HealthCheckPercentageHealthy", "HealthCheckStatus", "SSLHandshakeTime", "TimeToFirstByte"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/Route53Resolver": {"InboundQueryVolume", "OutboundQueryVolume", "OutboundQueryAggregatedVolume"},
|
|
|
|
"AWS/S3": {"4xxErrors", "5xxErrors", "AllRequests", "BucketSizeBytes", "BytesDownloaded", "BytesUploaded", "DeleteRequests", "FirstByteLatency", "GetRequests", "HeadRequests", "ListRequests", "NumberOfObjects", "PostRequests", "PutRequests", "SelectRequests", "SelectReturnedBytes", "SelectScannedBytes", "TotalRequestLatency"},
|
2020-06-05 02:10:38 -05:00
|
|
|
"AWS/SDKMetrics": {"CallCount", "ClientErrorCount", "EndToEndLatency", "ConnectionErrorCount", "ServerErrorCount", "ThrottleCount"},
|
2020-06-24 18:26:41 -05:00
|
|
|
"AWS/ServiceCatalog": {"ProvisionedProductLaunch"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/SES": {"Bounce", "Clicks", "Complaint", "Delivery", "Opens", "Reject", "Rendering Failures", "Reputation.BounceRate", "Reputation.ComplaintRate", "Send"},
|
|
|
|
"AWS/SNS": {"NumberOfMessagesPublished", "NumberOfNotificationsDelivered", "NumberOfNotificationsFailed", "NumberOfNotificationsFilteredOut", "NumberOfNotificationsFilteredOut-InvalidAttributes", "NumberOfNotificationsFilteredOut-NoMessageAttributes", "PublishSize", "SMSMonthToDateSpentUSD", "SMSSuccessRate"},
|
|
|
|
"AWS/SQS": {"ApproximateAgeOfOldestMessage", "ApproximateNumberOfMessagesDelayed", "ApproximateNumberOfMessagesNotVisible", "ApproximateNumberOfMessagesVisible", "NumberOfEmptyReceives", "NumberOfMessagesDeleted", "NumberOfMessagesReceived", "NumberOfMessagesSent", "SentMessageSize"},
|
|
|
|
"AWS/SWF": {"ActivityTaskScheduleToCloseTime", "ActivityTaskScheduleToStartTime", "ActivityTaskStartToCloseTime", "ActivityTasksCanceled", "ActivityTasksCompleted", "ActivityTasksFailed", "ConsumedCapacity", "DecisionTaskScheduleToStartTime", "DecisionTaskStartToCloseTime", "DecisionTasksCompleted", "PendingTasks", "ProvisionedBucketSize", "ProvisionedRefillRate", "ScheduledActivityTasksTimedOutOnClose", "ScheduledActivityTasksTimedOutOnStart", "StartedActivityTasksTimedOutOnClose", "StartedActivityTasksTimedOutOnHeartbeat", "StartedDecisionTasksTimedOutOnClose", "ThrottledEvents", "WorkflowStartToCloseTime", "WorkflowsCanceled", "WorkflowsCompleted", "WorkflowsContinuedAsNew", "WorkflowsFailed", "WorkflowsTerminated", "WorkflowsTimedOut"},
|
|
|
|
"AWS/SageMaker": {"CPUUtilization", "DatasetObjectsAutoAnnotated", "DatasetObjectsHumanAnnotated", "DatasetObjectsLabelingFailed", "DiskUtilization", "GPUMemoryUtilization", "GPUUtilization", "Invocation4XXErrors", "Invocation5XXErrors", "Invocations", "InvocationsPerInstance", "JobsFailed", "JobsStopped", "JobsSucceeded", "MemoryUtilization", "ModelLatency", "OverheadLatency", "TotalDatasetObjectsLabeled"},
|
|
|
|
"AWS/States": {"ActivitiesFailed", "ActivitiesHeartbeatTimedOut", "ActivitiesScheduled", "ActivitiesStarted", "ActivitiesSucceeded", "ActivitiesTimedOut", "ActivityRunTime", "ActivityScheduleTime", "ActivityTime", "ConsumedCapacity", "ExecutionThrottled", "ExecutionTime", "ExecutionsAborted", "ExecutionsFailed", "ExecutionsStarted", "ExecutionsSucceeded", "ExecutionsTimedOut", "LambdaFunctionRunTime", "LambdaFunctionScheduleTime", "LambdaFunctionTime", "LambdaFunctionsFailed", "LambdaFunctionsHeartbeatTimedOut", "LambdaFunctionsScheduled", "LambdaFunctionsStarted", "LambdaFunctionsSucceeded", "LambdaFunctionsTimedOut", "ProvisionedBucketSize", "ProvisionedRefillRate", "ThrottledEvents"},
|
|
|
|
"AWS/StorageGateway": {"CacheFree", "CacheHitPercent", "CachePercentDirty", "CachePercentUsed", "CacheUsed", "CloudBytesDownloaded", "CloudBytesUploaded", "CloudDownloadLatency", "QueuedWrites", "ReadBytes", "ReadTime", "TimeSinceLastRecoveryPoint", "TotalCacheSize", "UploadBufferFree", "UploadBufferPercentUsed", "UploadBufferUsed", "WorkingStorageFree", "WorkingStoragePercentUsed", "WorkingStorageUsed", "WriteBytes", "WriteTime"},
|
|
|
|
"AWS/Textract": {"ResponseTime", "ServerErrorCount", "SuccessfulRequestCount", "ThrottledCount", "UserErrorCount"},
|
|
|
|
"AWS/ThingsGraph": {"EventStoreQueueSize", "FlowExecutionTime", "FlowExecutionsFailed", "FlowExecutionsStarted", "FlowExecutionsSucceeded", "FlowStepExecutionTime", "FlowStepExecutionsFailed", "FlowStepExecutionsStarted", "FlowStepExecutionsSucceeded"},
|
|
|
|
"AWS/TransitGateway": {"BytesIn", "BytesOut", "PacketDropCountBlackhole", "PacketDropCountNoRoute", "PacketsIn", "PacketsOut"},
|
|
|
|
"AWS/Translate": {"CharacterCount", "ResponseTime", "ServerErrorCount", "SuccessfulRequestCount", "ThrottledCount", "UserErrorCount"},
|
|
|
|
"AWS/TrustedAdvisor": {"GreenChecks", "RedChecks", "RedResources", "ServiceLimitUsage", "YellowChecks", "YellowResources"},
|
2020-05-26 16:58:57 -05:00
|
|
|
"AWS/Usage": {"CallCount", "ResourceCount"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/VPN": {"TunnelDataIn", "TunnelDataOut", "TunnelState"},
|
2020-05-25 10:14:28 -05:00
|
|
|
"AWS/WAF": {"AllowedRequests", "BlockedRequests", "CountedRequests", "PassedRequests"},
|
2020-06-09 01:51:02 -05:00
|
|
|
"AWS/WAFV2": {"AllowedRequests", "BlockedRequests", "CountedRequests", "PassedRequests"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/WorkSpaces": {"Available", "ConnectionAttempt", "ConnectionFailure", "ConnectionSuccess", "InSessionLatency", "Maintenance", "SessionDisconnect", "SessionLaunchTime", "Stopped", "Unhealthy", "UserConnected"},
|
|
|
|
"ECS/ContainerInsights": {"ContainerInstanceCount", "CpuUtilized", "CpuReserved", "DeploymentCount", "DesiredTaskCount", "MemoryUtilized", "MemoryReserved", "NetworkRxBytes", "NetworkTxBytes", "PendingTaskCount", "RunningTaskCount", "ServiceCount", "StorageReadBytes", "StorageWriteBytes", "TaskCount", "TaskSetCount", "instance_cpu_limit", "instance_cpu_reserved_capacity", "instance_cpu_usage_total", "instance_cpu_utilization", "instance_filesystem_utilization", "instance_memory_limit", "instance_memory_reserved_capacity", "instance_memory_utliization", "instance_memory_working_set", "instance_network_total_bytes", "instance_number_of_running_tasks"},
|
|
|
|
"ContainerInsights": {"cluster_failed_node_count", "cluster_node_count", "namespace_number_of_running_pods", "node_cpu_limit", "node_cpu_reserved_capacity", "node_cpu_usage_total", "node_cpu_utilization", "node_filesystem_utilization", "node_memory_limit", "node_memory_reserved_capacity", "node_memory_utilization", "node_memory_working_set", "node_network_total_bytes", "node_number_of_running_containers", "node_number_of_running_pods", "pod_cpu_reserved_capacity", "pod_cpu_utilization", "pod_cpu_utilization_over_pod_limit", "pod_memory_reserved_capacity", "pod_memory_utilization", "pod_memory_utilization_over_pod_limit", "pod_number_of_container_restarts", "pod_network_rx_bytes", "pod_network_tx_bytes", "service_number_of_running_pods"},
|
|
|
|
"Rekognition": {"DetectedFaceCount", "DetectedLabelCount", "ResponseTime", "ServerErrorCount", "SuccessfulRequestCount", "ThrottledCount", "UserErrorCount"},
|
|
|
|
"AWS/Cassandra": {"AccountMaxReads", "AccountMaxTableLevelReads", "AccountMaxTableLevelWrites", "AccountMaxWrites", "AccountProvisionedReadCapacityUtilization", "AccountProvisionedWriteCapacityUtilization", "ConditionalCheckFailedRequests", "ConsumedReadCapacityUnits", "ConsumedWriteCapacityUnits", "MaxProvisionedTableReadCapacityUtilization", "MaxProvisionedTableWriteCapacityUtilization", "ReturnedItemCount", "ReturnedItemCountBySelect", "SuccessfulRequestCount", "SuccessfulRequestLatency", "SystemErrors", "UserErrors"},
|
|
|
|
}
|
2016-01-14 04:02:04 -06:00
|
|
|
|
2020-05-18 05:25:58 -05:00
|
|
|
var dimensionsMap = map[string][]string{
|
|
|
|
"AWS/ACMPrivateCA": {},
|
2020-09-02 14:32:43 -05:00
|
|
|
"AWS/AmazonMQ": {"Broker", "NetworkConnector", "Queue", "Topic"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/ApiGateway": {"ApiName", "Method", "Resource", "Stage"},
|
|
|
|
"AWS/AppStream": {"Fleet"},
|
|
|
|
"AWS/AppSync": {"GraphQLAPIId"},
|
|
|
|
"AWS/ApplicationELB": {"AvailabilityZone", "LoadBalancer", "TargetGroup"},
|
|
|
|
"AWS/AutoScaling": {"AutoScalingGroupName"},
|
|
|
|
"AWS/Billing": {"Currency", "LinkedAccount", "ServiceName"},
|
|
|
|
"AWS/Chatbot": {"ConfigurationName"},
|
|
|
|
"AWS/CloudFront": {"DistributionId", "Region"},
|
|
|
|
"AWS/CloudHSM": {"ClusterId", "HsmId", "Region"},
|
|
|
|
"AWS/CloudSearch": {"ClientId", "DomainName"},
|
|
|
|
"AWS/CodeBuild": {"ProjectName"},
|
|
|
|
"AWS/Cognito": {"Operation", "RiskLevel", "UserPoolId"},
|
|
|
|
"AWS/Connect": {"InstanceId", "MetricGroup", "Participant", "QueueName", "Stream Type", "Type of Connection"},
|
2020-05-25 08:05:52 -05:00
|
|
|
"AWS/DataSync": {"AgentId", "TaskId"},
|
2020-06-03 04:58:05 -05:00
|
|
|
"AWS/DDoSProtection": {"ResourceArn", "AttackVector"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/DMS": {"ReplicationInstanceIdentifier", "ReplicationTaskIdentifier"},
|
|
|
|
"AWS/DocDB": {"DBClusterIdentifier", "DBInstanceIdentifier", "Role"},
|
2020-10-05 11:19:40 -05:00
|
|
|
"AWS/DX": {"ConnectionId", "OpticalLaneNumber", "VirtualInterfaceId"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/DAX": {"Account", "ClusterId", "NodeId"},
|
|
|
|
"AWS/DynamoDB": {"GlobalSecondaryIndexName", "Operation", "ReceivingRegion", "StreamLabel", "TableName"},
|
|
|
|
"AWS/EBS": {"VolumeId"},
|
|
|
|
"AWS/EC2": {"AutoScalingGroupName", "ImageId", "InstanceId", "InstanceType"},
|
|
|
|
"AWS/EC2/API": {},
|
|
|
|
"AWS/EC2Spot": {"AvailabilityZone", "FleetRequestId", "InstanceType"},
|
|
|
|
"AWS/ECS": {"ClusterName", "ServiceName"},
|
|
|
|
"AWS/EFS": {"FileSystemId"},
|
|
|
|
"AWS/ELB": {"AvailabilityZone", "LoadBalancerName"},
|
|
|
|
"AWS/ES": {"ClientId", "DomainName"},
|
|
|
|
"AWS/ElastiCache": {"CacheClusterId", "CacheNodeId"},
|
|
|
|
"AWS/ElasticBeanstalk": {"EnvironmentName", "InstanceId"},
|
|
|
|
"AWS/ElasticInference": {"ElasticInferenceAcceleratorId", "InstanceId"},
|
|
|
|
"AWS/ElasticMapReduce": {"ClusterId", "JobFlowId", "JobId"},
|
|
|
|
"AWS/ElasticTranscoder": {"Operation", "PipelineId"},
|
|
|
|
"AWS/Events": {"RuleName"},
|
2020-07-29 01:35:07 -05:00
|
|
|
"AWS/FSx": {"FileSystemId"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/Firehose": {"DeliveryStreamName"},
|
|
|
|
"AWS/GameLift": {"FleetId", "InstanceType", "MatchmakingConfigurationName", "MatchmakingConfigurationName-RuleName", "MetricGroups", "OperatingSystem", "QueueName"},
|
|
|
|
"AWS/Glue": {"JobName", "JobRunId", "Type"},
|
|
|
|
"AWS/Inspector": {},
|
|
|
|
"AWS/IoT": {"ActionType", "BehaviorName", "CheckName", "JobId", "Protocol", "RuleName", "ScheduledAuditName", "SecurityProfileName"},
|
|
|
|
"AWS/IoTAnalytics": {"ActionType", "ChannelName", "DatasetName", "DatastoreName", "PipelineActivityName", "PipelineActivityType", "PipelineName"},
|
|
|
|
"AWS/KMS": {"KeyId"},
|
|
|
|
"AWS/Kafka": {"Broker ID", "Cluster Name", "Topic"},
|
|
|
|
"AWS/Kinesis": {"ShardId", "StreamName"},
|
|
|
|
"AWS/KinesisAnalytics": {"Application", "Flow", "Id"},
|
|
|
|
"AWS/KinesisVideo": {},
|
|
|
|
"AWS/Lambda": {"Alias", "ExecutedVersion", "FunctionName", "Resource"},
|
|
|
|
"AWS/Lex": {"BotAlias", "BotChannelName", "BotName", "BotVersion", "InputMode", "Operation", "Source"},
|
|
|
|
"AWS/Logs": {"DestinationType", "FilterName", "LogGroupName"},
|
|
|
|
"AWS/ML": {"MLModelId", "RequestMode"},
|
2020-07-07 02:16:20 -05:00
|
|
|
"AWS/MediaConnect": {"AvailabilityZone", "FlowARN", "SourceARN", "OutputARN"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/MediaConvert": {"Job", "Operation", "Queue"},
|
|
|
|
"AWS/MediaPackage": {"Channel", "No Dimension", "OriginEndpoint", "StatusCodeRange"},
|
2020-06-24 03:06:57 -05:00
|
|
|
"AWS/MediaStore": {"ContainerName", "ObjectGroupName", "RequestType"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/MediaTailor": {"Configuration Name"},
|
|
|
|
"AWS/NATGateway": {"NatGatewayId"},
|
|
|
|
"AWS/Neptune": {"DBClusterIdentifier", "DatabaseClass", "EngineName", "Role"},
|
|
|
|
"AWS/NetworkELB": {"AvailabilityZone", "LoadBalancer", "TargetGroup"},
|
|
|
|
"AWS/OpsWorks": {"InstanceId", "LayerId", "StackId"},
|
|
|
|
"AWS/Polly": {"Operation"},
|
|
|
|
"AWS/RDS": {"DBClusterIdentifier", "DBInstanceIdentifier", "DatabaseClass", "DbClusterIdentifier", "EngineName", "Role", "SourceRegion"},
|
|
|
|
"AWS/Redshift": {"ClusterIdentifier", "NodeID", "service class", "stage", "latency", "wlmid"},
|
2020-05-27 05:00:25 -05:00
|
|
|
"AWS/Route53": {"HealthCheckId", "Region", "HostedZoneId"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/Route53Resolver": {"EndpointId"},
|
|
|
|
"AWS/S3": {"BucketName", "FilterId", "StorageType"},
|
2020-06-05 02:10:38 -05:00
|
|
|
"AWS/SDKMetrics": {"DestinationRegion", "Service"},
|
2020-06-24 18:26:41 -05:00
|
|
|
"AWS/ServiceCatalog": {"State", "ProductId", "ProvisioningArtifactId"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/SES": {},
|
|
|
|
"AWS/SNS": {"Application", "Country", "Platform", "SMSType", "TopicName"},
|
|
|
|
"AWS/SQS": {"QueueName"},
|
|
|
|
"AWS/SWF": {"APIName", "ActivityTypeName", "ActivityTypeVersion", "DecisionName", "Domain", "TaskListName", "WorkflowTypeName", "WorkflowTypeVersion"},
|
|
|
|
"AWS/SageMaker": {"EndpointName", "Host", "LabelingJobName", "VariantName"},
|
|
|
|
"AWS/States": {"APIName", "ActivityArn", "LambdaFunctionArn", "StateMachineArn", "StateTransition"},
|
|
|
|
"AWS/StorageGateway": {"GatewayId", "GatewayName", "VolumeId"},
|
|
|
|
"AWS/Textract": {},
|
|
|
|
"AWS/ThingsGraph": {"FlowTemplateId", "StepName", "SystemTemplateId"},
|
2020-10-06 12:22:03 -05:00
|
|
|
"AWS/TransitGateway": {"TransitGateway", "TransitGatewayAttachment"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/Translate": {"LanguagePair", "Operation"},
|
|
|
|
"AWS/TrustedAdvisor": {},
|
|
|
|
"AWS/Usage": {"Class", "Resource", "Service", "Type"},
|
|
|
|
"AWS/VPN": {"TunnelIpAddress", "VpnId"},
|
2020-05-25 10:14:28 -05:00
|
|
|
"AWS/WAF": {"Region", "Rule", "RuleGroup", "WebACL"},
|
2020-06-09 01:51:02 -05:00
|
|
|
"AWS/WAFV2": {"Region", "Rule", "RuleGroup", "WebACL"},
|
2020-05-18 05:25:58 -05:00
|
|
|
"AWS/WorkSpaces": {"DirectoryId", "WorkspaceId"},
|
|
|
|
"ECS/ContainerInsights": {"ClusterName", "ServiceName", "TaskDefinitionFamily", "EC2InstanceId", "ContainerInstanceId"},
|
|
|
|
"ContainerInsights": {"ClusterName", "NodeName", "Namespace", "InstanceId", "PodName", "Service"},
|
|
|
|
"Rekognition": {},
|
|
|
|
"AWS/Cassandra": {"Keyspace", "Operation", "TableName"},
|
2015-10-02 04:54:35 -05:00
|
|
|
}
|
|
|
|
|
2020-05-18 05:25:58 -05:00
|
|
|
var regionCache sync.Map
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
func (e *cloudWatchExecutor) executeMetricFindQuery(ctx context.Context, queryContext *tsdb.TsdbQuery) (*tsdb.Response, error) {
|
2017-09-22 04:07:10 -05:00
|
|
|
firstQuery := queryContext.Queries[0]
|
2017-09-09 14:24:39 -05:00
|
|
|
|
2017-09-24 22:58:47 -05:00
|
|
|
parameters := firstQuery.Model
|
2017-09-22 04:07:10 -05:00
|
|
|
subType := firstQuery.Model.Get("subtype").MustString()
|
2017-09-09 14:24:39 -05:00
|
|
|
var data []suggestData
|
|
|
|
var err error
|
|
|
|
switch subType {
|
|
|
|
case "regions":
|
|
|
|
data, err = e.handleGetRegions(ctx, parameters, queryContext)
|
2017-09-13 05:35:05 -05:00
|
|
|
case "namespaces":
|
|
|
|
data, err = e.handleGetNamespaces(ctx, parameters, queryContext)
|
|
|
|
case "metrics":
|
|
|
|
data, err = e.handleGetMetrics(ctx, parameters, queryContext)
|
|
|
|
case "dimension_keys":
|
|
|
|
data, err = e.handleGetDimensions(ctx, parameters, queryContext)
|
2017-09-19 10:10:21 -05:00
|
|
|
case "dimension_values":
|
|
|
|
data, err = e.handleGetDimensionValues(ctx, parameters, queryContext)
|
2017-09-19 04:09:57 -05:00
|
|
|
case "ebs_volume_ids":
|
|
|
|
data, err = e.handleGetEbsVolumeIds(ctx, parameters, queryContext)
|
2017-09-19 04:55:11 -05:00
|
|
|
case "ec2_instance_attribute":
|
|
|
|
data, err = e.handleGetEc2InstanceAttribute(ctx, parameters, queryContext)
|
2019-01-09 15:06:27 -06:00
|
|
|
case "resource_arns":
|
|
|
|
data, err = e.handleGetResourceArns(ctx, parameters, queryContext)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
2020-05-18 05:25:58 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-09-22 04:07:10 -05:00
|
|
|
|
2020-05-18 05:25:58 -05:00
|
|
|
queryResult := &tsdb.QueryResult{Meta: simplejson.New(), RefId: firstQuery.RefId}
|
2017-09-09 14:24:39 -05:00
|
|
|
transformToTable(data, queryResult)
|
2020-05-18 05:25:58 -05:00
|
|
|
result := &tsdb.Response{
|
|
|
|
Results: map[string]*tsdb.QueryResult{
|
|
|
|
firstQuery.RefId: queryResult,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return result, nil
|
2015-10-02 04:54:35 -05:00
|
|
|
}
|
2015-10-02 13:25:28 -05:00
|
|
|
|
2017-09-09 14:24:39 -05:00
|
|
|
func transformToTable(data []suggestData, result *tsdb.QueryResult) {
|
|
|
|
table := &tsdb.Table{
|
2020-05-18 05:25:58 -05:00
|
|
|
Columns: []tsdb.TableColumn{
|
|
|
|
{
|
|
|
|
Text: "text",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Text: "value",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Rows: make([]tsdb.RowValues, 0),
|
2015-10-02 13:25:28 -05:00
|
|
|
}
|
2017-09-09 14:24:39 -05:00
|
|
|
|
|
|
|
for _, r := range data {
|
2020-05-18 05:25:58 -05:00
|
|
|
values := []interface{}{
|
|
|
|
r.Text,
|
|
|
|
r.Value,
|
|
|
|
}
|
2017-09-09 14:24:39 -05:00
|
|
|
table.Rows = append(table.Rows, values)
|
2015-10-02 13:25:28 -05:00
|
|
|
}
|
2017-09-09 14:24:39 -05:00
|
|
|
result.Tables = append(result.Tables, table)
|
|
|
|
result.Meta.Set("rowCount", len(data))
|
2015-10-02 13:25:28 -05:00
|
|
|
}
|
2016-01-14 04:02:04 -06:00
|
|
|
|
2018-01-24 08:41:42 -06:00
|
|
|
func parseMultiSelectValue(input string) []string {
|
|
|
|
trimmedInput := strings.TrimSpace(input)
|
|
|
|
if strings.HasPrefix(trimmedInput, "{") {
|
|
|
|
values := strings.Split(strings.TrimRight(strings.TrimLeft(trimmedInput, "{"), "}"), ",")
|
2020-05-18 05:25:58 -05:00
|
|
|
trimmedValues := make([]string, len(values))
|
2018-01-24 08:41:42 -06:00
|
|
|
for i, v := range values {
|
2020-05-18 05:25:58 -05:00
|
|
|
trimmedValues[i] = strings.TrimSpace(v)
|
2018-01-24 08:41:42 -06:00
|
|
|
}
|
2020-05-18 05:25:58 -05:00
|
|
|
return trimmedValues
|
2018-01-24 08:41:42 -06:00
|
|
|
}
|
2020-05-18 05:25:58 -05:00
|
|
|
|
Outdent code after if block that ends with return (golint)
This commit fixes the following golint warnings:
pkg/bus/bus.go:64:9: if block ends with a return statement, so drop this else and outdent its block
pkg/bus/bus.go:84:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:137:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:177:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:183:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:199:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:208:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/components/dynmap/dynmap.go:236:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:242:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:257:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:263:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:278:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:284:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:299:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:331:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:350:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:356:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:366:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:390:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:396:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:405:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:427:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:433:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:442:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:459:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:465:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:474:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:491:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:497:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:506:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:523:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:529:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:538:12: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:555:9: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:561:10: if block ends with a return statement, so drop this else and outdent its block
pkg/components/dynmap/dynmap.go:570:12: if block ends with a return statement, so drop this else and outdent its block
pkg/login/ldap.go:55:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/login/ldap_test.go:372:10: if block ends with a return statement, so drop this else and outdent its block
pkg/middleware/middleware_test.go:213:12: if block ends with a return statement, so drop this else and outdent its block
pkg/plugins/dashboard_importer.go:153:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/dashboards_updater.go:39:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/dashboards_updater.go:121:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/plugins.go:210:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/plugins/plugins.go:235:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/eval_context.go:111:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:92:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:98:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifier.go:122:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:108:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:118:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/rule.go:121:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/alerting/notifiers/telegram.go:94:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/annotation.go:34:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/annotation.go:99:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/dashboard_test.go:107:13: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/plugin_setting.go:78:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/preferences.go:91:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/user.go:50:10: if block ends with a return statement, so drop this else and outdent its block
pkg/services/sqlstore/migrator/migrator.go:106:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/services/sqlstore/migrator/postgres_dialect.go:48:10: if block ends with a return statement, so drop this else and outdent its block
pkg/tsdb/time_range.go:59:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/tsdb/time_range.go:67:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/tsdb/cloudwatch/metric_find_query.go:225:9: if block ends with a return statement, so drop this else and outdent its block
pkg/util/filepath.go:68:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
2018-04-27 15:42:49 -05:00
|
|
|
return []string{trimmedInput}
|
2018-01-24 08:41:42 -06:00
|
|
|
}
|
|
|
|
|
2020-05-18 05:25:58 -05:00
|
|
|
// Whenever this list is updated, the frontend list should also be updated.
|
2017-09-09 14:24:39 -05:00
|
|
|
// Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html
|
2020-07-24 05:34:56 -05:00
|
|
|
func (e *cloudWatchExecutor) handleGetRegions(ctx context.Context, parameters *simplejson.Json,
|
|
|
|
queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
2020-07-23 11:52:22 -05:00
|
|
|
dsInfo := e.getDSInfo(defaultRegion)
|
2018-10-25 13:10:27 -05:00
|
|
|
profile := dsInfo.Profile
|
|
|
|
if cache, ok := regionCache.Load(profile); ok {
|
2018-10-24 23:23:26 -05:00
|
|
|
if cache2, ok2 := cache.([]suggestData); ok2 {
|
|
|
|
return cache2, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-23 11:52:22 -05:00
|
|
|
client, err := e.getEC2Client(defaultRegion)
|
2018-06-19 03:06:56 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-07-14 01:23:23 -05:00
|
|
|
regions := knownRegions
|
2020-07-23 11:52:22 -05:00
|
|
|
r, err := client.DescribeRegions(&ec2.DescribeRegionsInput{})
|
2018-06-19 03:06:56 -05:00
|
|
|
if err != nil {
|
2018-10-15 22:06:57 -05:00
|
|
|
// ignore error for backward compatibility
|
|
|
|
plog.Error("Failed to get regions", "error", err)
|
|
|
|
} else {
|
|
|
|
for _, region := range r.Regions {
|
2018-10-17 03:58:06 -05:00
|
|
|
exists := false
|
|
|
|
|
|
|
|
for _, existingRegion := range regions {
|
|
|
|
if existingRegion == *region.RegionName {
|
|
|
|
exists = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !exists {
|
|
|
|
regions = append(regions, *region.RegionName)
|
|
|
|
}
|
2018-10-15 22:06:57 -05:00
|
|
|
}
|
2018-06-19 03:06:56 -05:00
|
|
|
}
|
|
|
|
sort.Strings(regions)
|
|
|
|
|
2017-09-09 14:24:39 -05:00
|
|
|
result := make([]suggestData, 0)
|
|
|
|
for _, region := range regions {
|
|
|
|
result = append(result, suggestData{Text: region, Value: region})
|
2016-01-14 04:02:04 -06:00
|
|
|
}
|
2018-10-25 13:10:27 -05:00
|
|
|
regionCache.Store(profile, result)
|
2016-01-14 04:02:04 -06:00
|
|
|
|
2017-09-09 14:24:39 -05:00
|
|
|
return result, nil
|
2016-01-14 04:02:04 -06:00
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
func (e *cloudWatchExecutor) handleGetNamespaces(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
2017-09-13 05:35:05 -05:00
|
|
|
keys := []string{}
|
|
|
|
for key := range metricsMap {
|
|
|
|
keys = append(keys, key)
|
|
|
|
}
|
|
|
|
customNamespaces := e.DataSource.JsonData.Get("customMetricsNamespaces").MustString()
|
|
|
|
if customNamespaces != "" {
|
2017-09-13 06:34:05 -05:00
|
|
|
keys = append(keys, strings.Split(customNamespaces, ",")...)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
2018-04-16 13:45:59 -05:00
|
|
|
sort.Strings(keys)
|
2017-09-13 05:35:05 -05:00
|
|
|
|
|
|
|
result := make([]suggestData, 0)
|
|
|
|
for _, key := range keys {
|
|
|
|
result = append(result, suggestData{Text: key, Value: key})
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
func (e *cloudWatchExecutor) handleGetMetrics(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
2017-09-13 05:35:05 -05:00
|
|
|
region := parameters.Get("region").MustString()
|
|
|
|
namespace := parameters.Get("namespace").MustString()
|
|
|
|
|
|
|
|
var namespaceMetrics []string
|
|
|
|
if !isCustomMetrics(namespace) {
|
|
|
|
var exists bool
|
|
|
|
if namespaceMetrics, exists = metricsMap[namespace]; !exists {
|
2020-05-18 05:25:58 -05:00
|
|
|
return nil, fmt.Errorf("unable to find namespace %q", namespace)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var err error
|
2020-07-24 01:37:24 -05:00
|
|
|
if namespaceMetrics, err = e.getMetricsForCustomMetrics(region, namespace); err != nil {
|
|
|
|
return nil, errutil.Wrap("unable to call AWS API", err)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
}
|
2018-04-16 13:45:59 -05:00
|
|
|
sort.Strings(namespaceMetrics)
|
2017-09-13 05:35:05 -05:00
|
|
|
|
|
|
|
result := make([]suggestData, 0)
|
|
|
|
for _, name := range namespaceMetrics {
|
|
|
|
result = append(result, suggestData{Text: name, Value: name})
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
func (e *cloudWatchExecutor) handleGetDimensions(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
2017-09-13 05:35:05 -05:00
|
|
|
region := parameters.Get("region").MustString()
|
|
|
|
namespace := parameters.Get("namespace").MustString()
|
|
|
|
|
|
|
|
var dimensionValues []string
|
|
|
|
if !isCustomMetrics(namespace) {
|
|
|
|
var exists bool
|
|
|
|
if dimensionValues, exists = dimensionsMap[namespace]; !exists {
|
2020-05-18 05:25:58 -05:00
|
|
|
return nil, fmt.Errorf("unable to find dimension %q", namespace)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var err error
|
2020-07-14 01:23:23 -05:00
|
|
|
dsInfo := e.getDSInfo(region)
|
2017-09-13 05:35:05 -05:00
|
|
|
dsInfo.Namespace = namespace
|
|
|
|
|
2020-07-23 11:52:22 -05:00
|
|
|
if dimensionValues, err = e.getDimensionsForCustomMetrics(region); err != nil {
|
2020-07-24 01:37:24 -05:00
|
|
|
return nil, errutil.Wrap("unable to call AWS API", err)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
}
|
2018-04-16 13:45:59 -05:00
|
|
|
sort.Strings(dimensionValues)
|
2017-09-13 05:35:05 -05:00
|
|
|
|
|
|
|
result := make([]suggestData, 0)
|
|
|
|
for _, name := range dimensionValues {
|
|
|
|
result = append(result, suggestData{Text: name, Value: name})
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
func (e *cloudWatchExecutor) handleGetDimensionValues(ctx context.Context, parameters *simplejson.Json, queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
2017-09-19 10:10:21 -05:00
|
|
|
region := parameters.Get("region").MustString()
|
|
|
|
namespace := parameters.Get("namespace").MustString()
|
|
|
|
metricName := parameters.Get("metricName").MustString()
|
|
|
|
dimensionKey := parameters.Get("dimensionKey").MustString()
|
2017-09-26 01:06:21 -05:00
|
|
|
dimensionsJson := parameters.Get("dimensions").MustMap()
|
2017-09-19 10:10:21 -05:00
|
|
|
|
|
|
|
var dimensions []*cloudwatch.DimensionFilter
|
2017-09-26 01:06:21 -05:00
|
|
|
for k, v := range dimensionsJson {
|
|
|
|
if vv, ok := v.(string); ok {
|
2017-09-19 10:10:21 -05:00
|
|
|
dimensions = append(dimensions, &cloudwatch.DimensionFilter{
|
2017-09-26 01:06:21 -05:00
|
|
|
Name: aws.String(k),
|
|
|
|
Value: aws.String(vv),
|
2017-09-19 10:10:21 -05:00
|
|
|
})
|
2020-01-08 05:24:10 -06:00
|
|
|
} else if vv, ok := v.([]interface{}); ok {
|
|
|
|
for _, v := range vv {
|
|
|
|
dimensions = append(dimensions, &cloudwatch.DimensionFilter{
|
|
|
|
Name: aws.String(k),
|
|
|
|
Value: aws.String(v.(string)),
|
|
|
|
})
|
|
|
|
}
|
2017-09-19 10:10:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
metrics, err := e.cloudwatchListMetrics(region, namespace, metricName, dimensions)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
result := make([]suggestData, 0)
|
|
|
|
dupCheck := make(map[string]bool)
|
|
|
|
for _, metric := range metrics.Metrics {
|
|
|
|
for _, dim := range metric.Dimensions {
|
|
|
|
if *dim.Name == dimensionKey {
|
|
|
|
if _, exists := dupCheck[*dim.Value]; exists {
|
|
|
|
continue
|
|
|
|
}
|
2020-05-18 05:25:58 -05:00
|
|
|
|
2017-09-19 10:10:21 -05:00
|
|
|
dupCheck[*dim.Value] = true
|
|
|
|
result = append(result, suggestData{Text: *dim.Value, Value: *dim.Value})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Slice(result, func(i, j int) bool {
|
|
|
|
return result[i].Text < result[j].Text
|
|
|
|
})
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-07-24 05:34:56 -05:00
|
|
|
func (e *cloudWatchExecutor) handleGetEbsVolumeIds(ctx context.Context, parameters *simplejson.Json,
|
|
|
|
queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
2017-09-19 04:09:57 -05:00
|
|
|
region := parameters.Get("region").MustString()
|
|
|
|
instanceId := parameters.Get("instanceId").MustString()
|
|
|
|
|
2018-01-24 08:41:42 -06:00
|
|
|
instanceIds := aws.StringSlice(parseMultiSelectValue(instanceId))
|
2017-09-19 04:09:57 -05:00
|
|
|
instances, err := e.ec2DescribeInstances(region, nil, instanceIds)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
result := make([]suggestData, 0)
|
2018-01-24 08:41:42 -06:00
|
|
|
for _, reservation := range instances.Reservations {
|
|
|
|
for _, instance := range reservation.Instances {
|
|
|
|
for _, mapping := range instance.BlockDeviceMappings {
|
|
|
|
result = append(result, suggestData{Text: *mapping.Ebs.VolumeId, Value: *mapping.Ebs.VolumeId})
|
|
|
|
}
|
|
|
|
}
|
2017-09-19 04:09:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-07-24 05:34:56 -05:00
|
|
|
func (e *cloudWatchExecutor) handleGetEc2InstanceAttribute(ctx context.Context, parameters *simplejson.Json,
|
|
|
|
queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
2017-09-19 04:55:11 -05:00
|
|
|
region := parameters.Get("region").MustString()
|
|
|
|
attributeName := parameters.Get("attributeName").MustString()
|
|
|
|
filterJson := parameters.Get("filters").MustMap()
|
|
|
|
|
|
|
|
var filters []*ec2.Filter
|
|
|
|
for k, v := range filterJson {
|
2017-11-13 06:07:46 -06:00
|
|
|
if vv, ok := v.([]interface{}); ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
var values []*string
|
2017-09-19 04:55:11 -05:00
|
|
|
for _, vvv := range vv {
|
2017-11-13 06:07:46 -06:00
|
|
|
if vvvv, ok := vvv.(string); ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
values = append(values, &vvvv)
|
2017-11-13 06:07:46 -06:00
|
|
|
}
|
2017-09-19 04:55:11 -05:00
|
|
|
}
|
|
|
|
filters = append(filters, &ec2.Filter{
|
|
|
|
Name: aws.String(k),
|
2020-07-14 01:23:23 -05:00
|
|
|
Values: values,
|
2017-09-19 04:55:11 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
instances, err := e.ec2DescribeInstances(region, filters, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
result := make([]suggestData, 0)
|
|
|
|
dupCheck := make(map[string]bool)
|
2017-09-26 10:00:38 -05:00
|
|
|
for _, reservation := range instances.Reservations {
|
|
|
|
for _, instance := range reservation.Instances {
|
|
|
|
tags := make(map[string]string)
|
|
|
|
for _, tag := range instance.Tags {
|
|
|
|
tags[*tag.Key] = *tag.Value
|
|
|
|
}
|
2017-09-19 04:55:11 -05:00
|
|
|
|
2017-09-26 10:00:38 -05:00
|
|
|
var data string
|
|
|
|
if strings.Index(attributeName, "Tags.") == 0 {
|
|
|
|
tagName := attributeName[5:]
|
|
|
|
data = tags[tagName]
|
|
|
|
} else {
|
|
|
|
attributePath := strings.Split(attributeName, ".")
|
|
|
|
v := reflect.ValueOf(instance)
|
|
|
|
for _, key := range attributePath {
|
|
|
|
if v.Kind() == reflect.Ptr {
|
|
|
|
v = v.Elem()
|
|
|
|
}
|
|
|
|
if v.Kind() != reflect.Struct {
|
|
|
|
return nil, errors.New("invalid attribute path")
|
|
|
|
}
|
|
|
|
v = v.FieldByName(key)
|
2018-09-11 05:53:39 -05:00
|
|
|
if !v.IsValid() {
|
|
|
|
return nil, errors.New("invalid attribute path")
|
|
|
|
}
|
2017-09-19 04:55:11 -05:00
|
|
|
}
|
2017-09-26 10:00:38 -05:00
|
|
|
if attr, ok := v.Interface().(*string); ok {
|
|
|
|
data = *attr
|
2019-11-21 02:20:44 -06:00
|
|
|
} else if attr, ok := v.Interface().(*time.Time); ok {
|
2020-06-29 07:08:32 -05:00
|
|
|
data = attr.String()
|
2017-09-26 10:00:38 -05:00
|
|
|
} else {
|
2017-09-19 04:55:11 -05:00
|
|
|
return nil, errors.New("invalid attribute path")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-26 10:00:38 -05:00
|
|
|
if _, exists := dupCheck[data]; exists {
|
|
|
|
continue
|
|
|
|
}
|
2020-05-18 05:25:58 -05:00
|
|
|
|
2017-09-26 10:00:38 -05:00
|
|
|
dupCheck[data] = true
|
|
|
|
result = append(result, suggestData{Text: data, Value: data})
|
2017-09-19 04:55:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Slice(result, func(i, j int) bool {
|
|
|
|
return result[i].Text < result[j].Text
|
|
|
|
})
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-07-24 05:34:56 -05:00
|
|
|
func (e *cloudWatchExecutor) handleGetResourceArns(ctx context.Context, parameters *simplejson.Json,
|
|
|
|
queryContext *tsdb.TsdbQuery) ([]suggestData, error) {
|
2019-01-09 15:06:27 -06:00
|
|
|
region := parameters.Get("region").MustString()
|
|
|
|
resourceType := parameters.Get("resourceType").MustString()
|
|
|
|
filterJson := parameters.Get("tags").MustMap()
|
|
|
|
|
|
|
|
var filters []*resourcegroupstaggingapi.TagFilter
|
|
|
|
for k, v := range filterJson {
|
|
|
|
if vv, ok := v.([]interface{}); ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
var values []*string
|
2019-01-09 15:06:27 -06:00
|
|
|
for _, vvv := range vv {
|
|
|
|
if vvvv, ok := vvv.(string); ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
values = append(values, &vvvv)
|
2019-01-09 15:06:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
filters = append(filters, &resourcegroupstaggingapi.TagFilter{
|
|
|
|
Key: aws.String(k),
|
2020-07-14 01:23:23 -05:00
|
|
|
Values: values,
|
2019-01-09 15:06:27 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var resourceTypes []*string
|
|
|
|
resourceTypes = append(resourceTypes, &resourceType)
|
|
|
|
|
|
|
|
resources, err := e.resourceGroupsGetResources(region, filters, resourceTypes)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
result := make([]suggestData, 0)
|
|
|
|
for _, resource := range resources.ResourceTagMappingList {
|
|
|
|
data := *resource.ResourceARN
|
|
|
|
result = append(result, suggestData{Text: data, Value: data})
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-07-24 05:34:56 -05:00
|
|
|
func (e *cloudWatchExecutor) cloudwatchListMetrics(region string, namespace string, metricName string,
|
|
|
|
dimensions []*cloudwatch.DimensionFilter) (*cloudwatch.ListMetricsOutput, error) {
|
2020-07-14 01:23:23 -05:00
|
|
|
svc, err := e.getCWClient(region)
|
2017-09-19 10:10:21 -05:00
|
|
|
if err != nil {
|
2017-09-26 04:30:40 -05:00
|
|
|
return nil, err
|
2017-09-19 10:10:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
params := &cloudwatch.ListMetricsInput{
|
|
|
|
Namespace: aws.String(namespace),
|
|
|
|
Dimensions: dimensions,
|
|
|
|
}
|
|
|
|
|
2019-11-14 03:59:41 -06:00
|
|
|
if metricName != "" {
|
|
|
|
params.MetricName = aws.String(metricName)
|
|
|
|
}
|
|
|
|
|
2017-09-19 10:10:21 -05:00
|
|
|
var resp cloudwatch.ListMetricsOutput
|
2020-05-18 05:25:58 -05:00
|
|
|
if err := svc.ListMetricsPages(params,
|
2017-09-19 10:10:21 -05:00
|
|
|
func(page *cloudwatch.ListMetricsOutput, lastPage bool) bool {
|
2019-07-16 09:58:46 -05:00
|
|
|
metrics.MAwsCloudWatchListMetrics.Inc()
|
2017-09-19 10:10:21 -05:00
|
|
|
metrics, _ := awsutil.ValuesAtPath(page, "Metrics")
|
|
|
|
for _, metric := range metrics {
|
|
|
|
resp.Metrics = append(resp.Metrics, metric.(*cloudwatch.Metric))
|
|
|
|
}
|
|
|
|
return !lastPage
|
2020-05-18 05:25:58 -05:00
|
|
|
}); err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to call cloudwatch:ListMetrics: %w", err)
|
2017-09-19 10:10:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return &resp, nil
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
func (e *cloudWatchExecutor) ec2DescribeInstances(region string, filters []*ec2.Filter, instanceIds []*string) (*ec2.DescribeInstancesOutput, error) {
|
2017-09-19 04:09:57 -05:00
|
|
|
params := &ec2.DescribeInstancesInput{
|
|
|
|
Filters: filters,
|
|
|
|
InstanceIds: instanceIds,
|
|
|
|
}
|
|
|
|
|
2020-07-23 11:52:22 -05:00
|
|
|
client, err := e.getEC2Client(region)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2017-09-19 04:09:57 -05:00
|
|
|
var resp ec2.DescribeInstancesOutput
|
2020-07-23 11:52:22 -05:00
|
|
|
if err := client.DescribeInstancesPages(params, func(page *ec2.DescribeInstancesOutput, lastPage bool) bool {
|
2020-07-14 01:23:23 -05:00
|
|
|
resp.Reservations = append(resp.Reservations, page.Reservations...)
|
|
|
|
return !lastPage
|
|
|
|
}); err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to call ec2:DescribeInstances, %w", err)
|
2017-09-19 04:09:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return &resp, nil
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
func (e *cloudWatchExecutor) resourceGroupsGetResources(region string, filters []*resourcegroupstaggingapi.TagFilter,
|
|
|
|
resourceTypes []*string) (*resourcegroupstaggingapi.GetResourcesOutput, error) {
|
2019-01-09 15:06:27 -06:00
|
|
|
params := &resourcegroupstaggingapi.GetResourcesInput{
|
|
|
|
ResourceTypeFilters: resourceTypes,
|
|
|
|
TagFilters: filters,
|
|
|
|
}
|
|
|
|
|
2020-07-23 11:52:22 -05:00
|
|
|
client, err := e.getRGTAClient(region)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-01-09 15:06:27 -06:00
|
|
|
var resp resourcegroupstaggingapi.GetResourcesOutput
|
2020-07-23 11:52:22 -05:00
|
|
|
if err := client.GetResourcesPages(params,
|
2019-01-09 15:06:27 -06:00
|
|
|
func(page *resourcegroupstaggingapi.GetResourcesOutput, lastPage bool) bool {
|
2020-07-14 01:23:23 -05:00
|
|
|
resp.ResourceTagMappingList = append(resp.ResourceTagMappingList, page.ResourceTagMappingList...)
|
2019-01-09 15:06:27 -06:00
|
|
|
return !lastPage
|
2020-07-14 01:23:23 -05:00
|
|
|
}); err != nil {
|
2020-08-26 04:01:50 -05:00
|
|
|
return nil, fmt.Errorf("failed to call tag:GetResources, %w", err)
|
2019-01-09 15:06:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return &resp, nil
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
func (e *cloudWatchExecutor) getAllMetrics(region string) (cloudwatch.ListMetricsOutput, error) {
|
2020-07-23 11:52:22 -05:00
|
|
|
client, err := e.getCWClient(region)
|
2017-09-13 05:35:05 -05:00
|
|
|
if err != nil {
|
|
|
|
return cloudwatch.ListMetricsOutput{}, err
|
|
|
|
}
|
|
|
|
|
2020-07-23 11:52:22 -05:00
|
|
|
dsInfo := e.getDSInfo(region)
|
2017-09-13 05:35:05 -05:00
|
|
|
params := &cloudwatch.ListMetricsInput{
|
2020-07-14 01:23:23 -05:00
|
|
|
Namespace: aws.String(dsInfo.Namespace),
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
|
2020-07-24 05:34:56 -05:00
|
|
|
plog.Debug("Listing metrics pages")
|
2017-09-13 05:35:05 -05:00
|
|
|
var resp cloudwatch.ListMetricsOutput
|
2020-07-23 11:52:22 -05:00
|
|
|
err = client.ListMetricsPages(params, func(page *cloudwatch.ListMetricsOutput, lastPage bool) bool {
|
2020-05-18 05:25:58 -05:00
|
|
|
metrics.MAwsCloudWatchListMetrics.Inc()
|
|
|
|
metrics, err := awsutil.ValuesAtPath(page, "Metrics")
|
|
|
|
if err != nil {
|
2017-09-13 05:35:05 -05:00
|
|
|
return !lastPage
|
2020-05-18 05:25:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, metric := range metrics {
|
|
|
|
resp.Metrics = append(resp.Metrics, metric.(*cloudwatch.Metric))
|
|
|
|
}
|
|
|
|
return !lastPage
|
|
|
|
})
|
2020-07-23 11:52:22 -05:00
|
|
|
|
2018-04-16 12:54:23 -05:00
|
|
|
return resp, err
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var metricsCacheLock sync.Mutex
|
|
|
|
|
2020-07-24 01:37:24 -05:00
|
|
|
func (e *cloudWatchExecutor) getMetricsForCustomMetrics(region, namespace string) ([]string, error) {
|
2020-07-24 05:34:56 -05:00
|
|
|
plog.Debug("Getting metrics for custom metrics", "region", region, "namespace", namespace)
|
2017-09-13 05:35:05 -05:00
|
|
|
metricsCacheLock.Lock()
|
|
|
|
defer metricsCacheLock.Unlock()
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
dsInfo := e.getDSInfo(region)
|
2020-07-24 01:37:24 -05:00
|
|
|
dsInfo.Namespace = namespace
|
2020-07-14 01:23:23 -05:00
|
|
|
|
2017-09-13 05:35:05 -05:00
|
|
|
if _, ok := customMetricsMetricsMap[dsInfo.Profile]; !ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
customMetricsMetricsMap[dsInfo.Profile] = make(map[string]map[string]*customMetricsCache)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
if _, ok := customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region]; !ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region] = make(map[string]*customMetricsCache)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
if _, ok := customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace]; !ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace] = &customMetricsCache{}
|
2017-09-13 05:35:05 -05:00
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = make([]string, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
if customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Expire.After(time.Now()) {
|
|
|
|
return customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, nil
|
|
|
|
}
|
2020-07-23 11:52:22 -05:00
|
|
|
result, err := e.getAllMetrics(region)
|
2017-09-13 05:35:05 -05:00
|
|
|
if err != nil {
|
|
|
|
return []string{}, err
|
|
|
|
}
|
2020-07-24 05:34:56 -05:00
|
|
|
|
2017-09-13 05:35:05 -05:00
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = make([]string, 0)
|
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Expire = time.Now().Add(5 * time.Minute)
|
|
|
|
|
|
|
|
for _, metric := range result.Metrics {
|
|
|
|
if isDuplicate(customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *metric.MetricName) {
|
|
|
|
continue
|
|
|
|
}
|
2020-07-24 05:34:56 -05:00
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = append(
|
|
|
|
customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *metric.MetricName)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return customMetricsMetricsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var dimensionsCacheLock sync.Mutex
|
|
|
|
|
2020-07-23 11:52:22 -05:00
|
|
|
func (e *cloudWatchExecutor) getDimensionsForCustomMetrics(region string) ([]string, error) {
|
2017-09-13 05:35:05 -05:00
|
|
|
dimensionsCacheLock.Lock()
|
|
|
|
defer dimensionsCacheLock.Unlock()
|
|
|
|
|
2020-07-14 01:23:23 -05:00
|
|
|
dsInfo := e.getDSInfo(region)
|
|
|
|
|
2017-09-13 05:35:05 -05:00
|
|
|
if _, ok := customMetricsDimensionsMap[dsInfo.Profile]; !ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
customMetricsDimensionsMap[dsInfo.Profile] = make(map[string]map[string]*customMetricsCache)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
if _, ok := customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region]; !ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region] = make(map[string]*customMetricsCache)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
if _, ok := customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace]; !ok {
|
2020-07-14 01:23:23 -05:00
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace] = &customMetricsCache{}
|
2017-09-13 05:35:05 -05:00
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = make([]string, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
if customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Expire.After(time.Now()) {
|
|
|
|
return customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, nil
|
|
|
|
}
|
2020-07-23 11:52:22 -05:00
|
|
|
result, err := e.getAllMetrics(region)
|
2017-09-13 05:35:05 -05:00
|
|
|
if err != nil {
|
|
|
|
return []string{}, err
|
|
|
|
}
|
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = make([]string, 0)
|
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Expire = time.Now().Add(5 * time.Minute)
|
|
|
|
|
|
|
|
for _, metric := range result.Metrics {
|
|
|
|
for _, dimension := range metric.Dimensions {
|
|
|
|
if isDuplicate(customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *dimension.Name) {
|
|
|
|
continue
|
|
|
|
}
|
2020-07-24 05:34:56 -05:00
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache = append(
|
|
|
|
customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, *dimension.Name)
|
2017-09-13 05:35:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return customMetricsDimensionsMap[dsInfo.Profile][dsInfo.Region][dsInfo.Namespace].Cache, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func isDuplicate(nameList []string, target string) bool {
|
|
|
|
for _, name := range nameList {
|
|
|
|
if name == target {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func isCustomMetrics(namespace string) bool {
|
|
|
|
return strings.Index(namespace, "AWS/") != 0
|
|
|
|
}
|