# Metric

A metric emitted by a service.

The metric is a combination of a metric identifier (namespace, name and dimensions)
and an aggregation function (statistic, period and unit).

It also contains metadata which is used only in graphs, such as color and label.
It makes sense to embed this in here, so that compound constructs can attach
that metadata to metrics they expose.

This class does not represent a resource, so hence is not a construct. Instead,
Metric is an abstraction that makes it easy to specify metrics for use in both
alarms and graphs.

Implements: [IMetric](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.IMetric.html)
Obtainable from: [GuardrailBase.metricAll](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailBase.html#metricall), [GuardrailBase.metricAllInvocationLatency](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailBase.html#metricallinvocationlatency), [GuardrailBase.metricAllInvocations](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailBase.html#metricallinvocations), [GuardrailBase.metricAllInvocationsIntervened](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailBase.html#metricallinvocationsintervened), [GuardrailBase.metricAllTextUnitCount](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailBase.html#metricalltextunitcount), [SlackChannelConfiguration.metricAll](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_chatbot.SlackChannelConfiguration.html#metricall), [VpnConnection.metricAll](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.VpnConnection.html#metricall), [VpnConnection.metricAllTunnelDataIn](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.VpnConnection.html#metricalltunneldatain), [VpnConnection.metricAllTunnelDataOut](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.VpnConnection.html#metricalltunneldataout), [VpnConnection.metricAllTunnelState](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.VpnConnection.html#metricalltunnelstate), [Function.metricAll](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#metricall), [Function.metricAllConcurrentExecutions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#metricallconcurrentexecutions), [Function.metricAllDuration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#metricallduration), [Function.metricAllErrors](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#metricallerrors), [Function.metricAllInvocations](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#metricallinvocations), [Function.metricAllThrottles](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#metricallthrottles), [Function.metricAllUnreservedConcurrentExecutions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#metricallunreservedconcurrentexecutions), [Schedule.metricAll](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricall), [Schedule.metricAllAttempts](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricallattempts), [Schedule.metricAllDropped](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricalldropped), [Schedule.metricAllErrors](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricallerrors), [Schedule.metricAllFailedToBeSentToDLQ](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricallfailedtobesenttodlq), [Schedule.metricAllSentToDLQ](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricallsenttodlq), [Schedule.metricAllSentToDLQTruncated](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricallsenttodlqtruncated), [Schedule.metricAllTargetThrottled](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricalltargetthrottled), [Schedule.metricAllThrottled](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.Schedule.html#metricallthrottled), [StateTransitionMetric.metric](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.StateTransitionMetric.html#metric), [StateTransitionMetric.metricConsumedCapacity](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.StateTransitionMetric.html#metricconsumedcapacity), [StateTransitionMetric.metricProvisionedBucketSize](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.StateTransitionMetric.html#metricprovisionedbucketsize), [StateTransitionMetric.metricProvisionedRefillRate](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.StateTransitionMetric.html#metricprovisionedrefillrate), [StateTransitionMetric.metricThrottledEvents](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.StateTransitionMetric.html#metricthrottledevents)
Returned by: [Activity.metric](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Activity.html#metric), [Activity.metricFailed](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Activity.html#metricfailed), Activity.metricHeartbeatTimedOut, Activity.metricRunTime, Activity.metricScheduleTime, Activity.metricScheduled, Activity.metricStarted, Activity.metricSucceeded, Activity.metricTime, Activity.metricTimedOut, ApplicationLoadBalancer.metric, ApplicationLoadBalancer.metricActiveConnectionCount, ApplicationLoadBalancer.metricClientTlsNegotiationErrorCount, ApplicationLoadBalancer.metricConsumedLCUs, ApplicationLoadBalancer.metricElbAuthError, ApplicationLoadBalancer.metricElbAuthFailure, ApplicationLoadBalancer.metricElbAuthLatency, ApplicationLoadBalancer.metricElbAuthSuccess, ApplicationLoadBalancer.metricHttpCodeElb, ApplicationLoadBalancer.metricHttpCodeTarget, ApplicationLoadBalancer.metricHttpFixedResponseCount, ApplicationLoadBalancer.metricHttpRedirectCount, ApplicationLoadBalancer.metricHttpRedirectUrlLimitExceededCount, ApplicationLoadBalancer.metricIpv6ProcessedBytes, ApplicationLoadBalancer.metricIpv6RequestCount, ApplicationLoadBalancer.metricNewConnectionCount, ApplicationLoadBalancer.metricProcessedBytes, ApplicationLoadBalancer.metricRejectedConnectionCount, ApplicationLoadBalancer.metricRequestCount, ApplicationLoadBalancer.metricRuleEvaluations, ApplicationLoadBalancer.metricTargetConnectionErrorCount, ApplicationLoadBalancer.metricTargetResponseTime, ApplicationLoadBalancer.metricTargetTLSNegotiationErrorCount, ApplicationTargetGroup.metric, ApplicationTargetGroup.metricHealthyHostCount, ApplicationTargetGroup.metricHttpCodeTarget, ApplicationTargetGroup.metricIpv6RequestCount, ApplicationTargetGroup.metricRequestCount, ApplicationTargetGroup.metricRequestCountPerTarget, ApplicationTargetGroup.metricTargetConnectionErrorCount, ApplicationTargetGroup.metricTargetResponseTime, ApplicationTargetGroup.metricTargetTLSNegotiationErrorCount, ApplicationTargetGroup.metricUnhealthyHostCount, BaseService.metric, BaseService.metricCpuUtilization, BaseService.metricMemoryUtilization, Canary.metricDuration, Canary.metricFailed, Canary.metricSuccessPercent, Cluster.metric, Cluster.metricCpuReservation, Cluster.metricCpuUtilization, Cluster.metricMemoryReservation, Cluster.metricMemoryUtilization, DatabaseCluster.metricACUUtilization, DatabaseCluster.metricServerlessDatabaseCapacity, DatabaseClusterFromSnapshot.metricACUUtilization, DatabaseClusterFromSnapshot.metricServerlessDatabaseCapacity, DatabaseInstanceMetrics.burstBalance, DatabaseInstanceMetrics.cpuUtilization, DatabaseInstanceMetrics.databaseConnections, DatabaseInstanceMetrics.diskQueueDepth, DatabaseInstanceMetrics.freeStorageSpace, DatabaseInstanceMetrics.freeableMemory, DatabaseInstanceMetrics.metric, DatabaseInstanceMetrics.networkReceiveThroughput, DatabaseInstanceMetrics.networkTransmitThroughput, DatabaseInstanceMetrics.readIOPS, DatabaseInstanceMetrics.readLatency, DatabaseInstanceMetrics.readThroughput, DatabaseInstanceMetrics.replicaLag, DatabaseInstanceMetrics.swapUsage, DatabaseInstanceMetrics.writeIOPS, DatabaseInstanceMetrics.writeLatency, DatabaseInstanceMetrics.writeThroughput, Distribution.metric, Distribution.metric401ErrorRate, Distribution.metric403ErrorRate, Distribution.metric404ErrorRate, Distribution.metric4xxErrorRate, Distribution.metric502ErrorRate, Distribution.metric503ErrorRate, Distribution.metric504ErrorRate, Distribution.metric5xxErrorRate, Distribution.metricBytesDownloaded, Distribution.metricBytesUploaded, Distribution.metricCacheHitRate, Distribution.metricOriginLatency, Distribution.metricRequests, Distribution.metricTotalErrorRate, IAgent.metricCount, IApi.metric, IApplication.metric, IApplication.metricBackPressuredTimeMsPerSecond, IApplication.metricBusyTimePerMsPerSecond, IApplication.metricCpuUtilization, IApplication.metricCurrentInputWatermark, IApplication.metricCurrentOutputWatermark, IApplication.metricDowntime, IApplication.metricFullRestarts, IApplication.metricHeapMemoryUtilization, IApplication.metricIdleTimeMsPerSecond, IApplication.metricKpus, IApplication.metricLastCheckpointDuration, IApplication.metricLastCheckpointSize, IApplication.metricManagedMemoryTotal, IApplication.metricManagedMemoryUsed, IApplication.metricManagedMemoryUtilization, IApplication.metricNumLateRecordsDropped, IApplication.metricNumRecordsIn, IApplication.metricNumRecordsInPerSecond, IApplication.metricNumRecordsOut, IApplication.metricNumRecordsOutPerSecond, IApplication.metricNumberOfFailedCheckpoints, IApplication.metricOldGenerationGCCount, IApplication.metricOldGenerationGCTime, IApplication.metricThreadsCount, IApplication.metricUptime, IApplicationLoadBalancerMetrics.activeConnectionCount, IApplicationLoadBalancerMetrics.clientTlsNegotiationErrorCount, IApplicationLoadBalancerMetrics.consumedLCUs, IApplicationLoadBalancerMetrics.custom, IApplicationLoadBalancerMetrics.elbAuthError, IApplicationLoadBalancerMetrics.elbAuthFailure, IApplicationLoadBalancerMetrics.elbAuthLatency, IApplicationLoadBalancerMetrics.elbAuthSuccess, IApplicationLoadBalancerMetrics.httpCodeElb, IApplicationLoadBalancerMetrics.httpCodeTarget, IApplicationLoadBalancerMetrics.httpFixedResponseCount, IApplicationLoadBalancerMetrics.httpRedirectCount, IApplicationLoadBalancerMetrics.httpRedirectUrlLimitExceededCount, IApplicationLoadBalancerMetrics.ipv6ProcessedBytes, IApplicationLoadBalancerMetrics.ipv6RequestCount, IApplicationLoadBalancerMetrics.newConnectionCount, IApplicationLoadBalancerMetrics.processedBytes, IApplicationLoadBalancerMetrics.rejectedConnectionCount, IApplicationLoadBalancerMetrics.requestCount, IApplicationLoadBalancerMetrics.ruleEvaluations, IApplicationLoadBalancerMetrics.targetConnectionErrorCount, IApplicationLoadBalancerMetrics.targetResponseTime, IApplicationLoadBalancerMetrics.targetTLSNegotiationErrorCount, IApplicationTargetGroupMetrics.custom, IApplicationTargetGroupMetrics.healthyHostCount, IApplicationTargetGroupMetrics.httpCodeTarget, IApplicationTargetGroupMetrics.ipv6RequestCount, IApplicationTargetGroupMetrics.requestCount, IApplicationTargetGroupMetrics.requestCountPerTarget, IApplicationTargetGroupMetrics.targetConnectionErrorCount, IApplicationTargetGroupMetrics.targetResponseTime, IApplicationTargetGroupMetrics.targetTLSNegotiationErrorCount, IApplicationTargetGroupMetrics.unhealthyHostCount, IBedrockAgentRuntime.metric (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricInvocations (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricInvocationsAggregated (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricLatency (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricSessionCount (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricSessionsAggregated (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricSystemErrors (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricThrottles (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricTotalErrors (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metricUserErrors (@aws-cdk/aws-bedrock-agentcore-alpha), IBedrockAgentRuntime.metric (aws_bedrockagentcore), IBedrockAgentRuntime.metricInvocations (aws_bedrockagentcore), IBedrockAgentRuntime.metricInvocationsAggregated (aws_bedrockagentcore), IBedrockAgentRuntime.metricLatency (aws_bedrockagentcore), IBedrockAgentRuntime.metricSessionCount (aws_bedrockagentcore), IBedrockAgentRuntime.metricSessionsAggregated (aws_bedrockagentcore), IBedrockAgentRuntime.metricSystemErrors (aws_bedrockagentcore), IBedrockAgentRuntime.metricThrottles (aws_bedrockagentcore), IBedrockAgentRuntime.metricTotalErrors (aws_bedrockagentcore), IBedrockAgentRuntime.metricUserErrors (aws_bedrockagentcore), IBridge.metric, IBridge.metricFailoverSwitches, IBridge.metricSourceBitrate, IBridge.metricSourcePacketLossPercent, IBrowserCustom.metric (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricErrorsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricInvocationsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricLatencyForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricSessionDuration (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricSystemErrorsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricTakeOverCount (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricTakeOverDuration (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricTakeOverReleaseCount (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricThrottlesForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metricUserErrorsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IBrowserCustom.metric (aws_bedrockagentcore), IBrowserCustom.metricErrorsForApiOperation (aws_bedrockagentcore), IBrowserCustom.metricForApiOperation (aws_bedrockagentcore), IBrowserCustom.metricInvocationsForApiOperation (aws_bedrockagentcore), IBrowserCustom.metricLatencyForApiOperation (aws_bedrockagentcore), IBrowserCustom.metricSessionDuration (aws_bedrockagentcore), IBrowserCustom.metricSystemErrorsForApiOperation (aws_bedrockagentcore), IBrowserCustom.metricTakeOverCount (aws_bedrockagentcore), IBrowserCustom.metricTakeOverDuration (aws_bedrockagentcore), IBrowserCustom.metricTakeOverReleaseCount (aws_bedrockagentcore), IBrowserCustom.metricThrottlesForApiOperation (aws_bedrockagentcore), IBrowserCustom.metricUserErrorsForApiOperation (aws_bedrockagentcore), ICertificate.metricDaysToExpiry, IChannel.metric (@aws-cdk/aws-medialive-alpha), IChannel.metricActiveAlerts (@aws-cdk/aws-medialive-alpha), IChannel.metricDroppedFrames (@aws-cdk/aws-medialive-alpha), IChannel.metricFillMsec (@aws-cdk/aws-medialive-alpha), IChannel.metricInputLossSeconds (@aws-cdk/aws-medialive-alpha), IChannel.metricInputVideoFrameRate (@aws-cdk/aws-medialive-alpha), IChannel.metricNetworkIn (@aws-cdk/aws-medialive-alpha), IChannel.metricNetworkOut (@aws-cdk/aws-medialive-alpha), IChannel.metricSvqTime (@aws-cdk/aws-medialive-alpha), IChannel.metric (@aws-cdk/aws-mediapackagev2-alpha), IChannel.metricEgressBytes (@aws-cdk/aws-mediapackagev2-alpha), IChannel.metricEgressRequestCount (@aws-cdk/aws-mediapackagev2-alpha), IChannel.metricEgressResponseTime (@aws-cdk/aws-mediapackagev2-alpha), IChannel.metricIngressBytes (@aws-cdk/aws-mediapackagev2-alpha), IChannel.metricIngressRequestCount (@aws-cdk/aws-mediapackagev2-alpha), IChannel.metricIngressResponseTime (@aws-cdk/aws-mediapackagev2-alpha), IChannelGroup.metric, IChannelGroup.metricEgressBytes, IChannelGroup.metricEgressRequestCount, IChannelGroup.metricEgressResponseTime, IChannelGroup.metricIngressBytes, IChannelGroup.metricIngressRequestCount, IChannelGroup.metricIngressResponseTime, ICodeInterpreterCustom.metric (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metricErrorsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metricForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metricInvocationsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metricLatencyForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metricSessionDuration (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metricSystemErrorsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metricThrottlesForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metricUserErrorsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), ICodeInterpreterCustom.metric (aws_bedrockagentcore), ICodeInterpreterCustom.metricErrorsForApiOperation (aws_bedrockagentcore), ICodeInterpreterCustom.metricForApiOperation (aws_bedrockagentcore), ICodeInterpreterCustom.metricInvocationsForApiOperation (aws_bedrockagentcore), ICodeInterpreterCustom.metricLatencyForApiOperation (aws_bedrockagentcore), ICodeInterpreterCustom.metricSessionDuration (aws_bedrockagentcore), ICodeInterpreterCustom.metricSystemErrorsForApiOperation (aws_bedrockagentcore), ICodeInterpreterCustom.metricThrottlesForApiOperation (aws_bedrockagentcore), ICodeInterpreterCustom.metricUserErrorsForApiOperation (aws_bedrockagentcore), IDatabaseCluster.metric (@aws-cdk/aws-neptune-alpha), IDatabaseCluster.metric (aws_rds), IDatabaseCluster.metricCPUUtilization (aws_rds), IDatabaseCluster.metricDatabaseConnections (aws_rds), IDatabaseCluster.metricDeadlocks (aws_rds), IDatabaseCluster.metricEngineUptime (aws_rds), IDatabaseCluster.metricFreeLocalStorage (aws_rds), IDatabaseCluster.metricFreeableMemory (aws_rds), IDatabaseCluster.metricNetworkReceiveThroughput (aws_rds), IDatabaseCluster.metricNetworkThroughput (aws_rds), IDatabaseCluster.metricNetworkTransmitThroughput (aws_rds), IDatabaseCluster.metricSnapshotStorageUsed (aws_rds), IDatabaseCluster.metricTotalBackupStorageBilled (aws_rds), IDatabaseCluster.metricVolumeBytesUsed (aws_rds), IDatabaseCluster.metricVolumeReadIOPs (aws_rds), IDatabaseCluster.metricVolumeWriteIOPs (aws_rds), IDatabaseInstance.metric (@aws-cdk/aws-neptune-alpha), IDatabaseInstance.metric (aws_rds), IDatabaseInstance.metricCPUUtilization (aws_rds), IDatabaseInstance.metricDatabaseConnections (aws_rds), IDatabaseInstance.metricFreeStorageSpace (aws_rds), IDatabaseInstance.metricFreeableMemory (aws_rds), IDatabaseInstance.metricReadIOPS (aws_rds), IDatabaseInstance.metricWriteIOPS (aws_rds), IDeliveryStream.metric, IDeliveryStream.metricBackupToS3Bytes, IDeliveryStream.metricBackupToS3DataFreshness, IDeliveryStream.metricBackupToS3Records, IDeliveryStream.metricIncomingBytes, IDeliveryStream.metricIncomingRecords, IDomain.metric (aws_elasticsearch), IDomain.metricAutomatedSnapshotFailure (aws_elasticsearch), IDomain.metricCPUUtilization (aws_elasticsearch), IDomain.metricClusterIndexWritesBlocked (aws_elasticsearch), IDomain.metricClusterStatusRed (aws_elasticsearch), IDomain.metricClusterStatusYellow (aws_elasticsearch), IDomain.metricFreeStorageSpace (aws_elasticsearch), IDomain.metricIndexingLatency (aws_elasticsearch), IDomain.metricJVMMemoryPressure (aws_elasticsearch), IDomain.metricKMSKeyError (aws_elasticsearch), IDomain.metricKMSKeyInaccessible (aws_elasticsearch), IDomain.metricMasterCPUUtilization (aws_elasticsearch), IDomain.metricMasterJVMMemoryPressure (aws_elasticsearch), IDomain.metricNodes (aws_elasticsearch), IDomain.metricSearchLatency (aws_elasticsearch), IDomain.metricSearchableDocuments (aws_elasticsearch), IDomain.metric (aws_opensearchservice), IDomain.metricAutomatedSnapshotFailure (aws_opensearchservice), IDomain.metricCPUUtilization (aws_opensearchservice), IDomain.metricClusterIndexWritesBlocked (aws_opensearchservice), IDomain.metricClusterStatusRed (aws_opensearchservice), IDomain.metricClusterStatusYellow (aws_opensearchservice), IDomain.metricFreeStorageSpace (aws_opensearchservice), IDomain.metricIndexingLatency (aws_opensearchservice), IDomain.metricJVMMemoryPressure (aws_opensearchservice), IDomain.metricKMSKeyError (aws_opensearchservice), IDomain.metricKMSKeyInaccessible (aws_opensearchservice), IDomain.metricMasterCPUUtilization (aws_opensearchservice), IDomain.metricMasterJVMMemoryPressure (aws_opensearchservice), IDomain.metricNodes (aws_opensearchservice), IDomain.metricSearchLatency (aws_opensearchservice), IDomain.metricSearchableDocuments (aws_opensearchservice), IEndpointInstanceProductionVariant.metric, IEndpointInstanceProductionVariant.metricCpuUtilization, IEndpointInstanceProductionVariant.metricDiskUtilization, IEndpointInstanceProductionVariant.metricGpuMemoryUtilization, IEndpointInstanceProductionVariant.metricGpuUtilization, IEndpointInstanceProductionVariant.metricInvocationResponseCode, IEndpointInstanceProductionVariant.metricInvocations, IEndpointInstanceProductionVariant.metricInvocationsPerInstance, IEndpointInstanceProductionVariant.metricMemoryUtilization, IEndpointInstanceProductionVariant.metricModelLatency, IEndpointInstanceProductionVariant.metricOverheadLatency, IFleet.metric, IFleet.metricActiveInstances, IFleet.metricDesiredInstances, IFleet.metricIdleInstances, IFleet.metricInstanceInterruptions, IFleet.metricMaxInstances, IFleet.metricMinInstances, IFleet.metricPercentIdleInstances, IFlow.metric, IFlow.metricSourceBitrate, IFlow.metricSourceConnected, IFlow.metricSourceDisconnections, IFlow.metricSourceDroppedPackets, IFlow.metricSourceJitter, IFlow.metricSourceNotRecoveredPackets, IFlow.metricSourcePacketLossPercent, IFlow.metricSourceRoundTripTime, IFlow.metricSourceSelected, IFlow.metricSourceTotalPackets, IFunction.metric, IFunction.metricDuration, IFunction.metricErrors, IFunction.metricInvocations, IFunction.metricThrottles, IGameServerGroup.metric, IGameSessionQueue.metric, IGameSessionQueue.metricAverageWaitTime, IGameSessionQueue.metricPlacementsCanceled, IGameSessionQueue.metricPlacementsFailed, IGameSessionQueue.metricPlacementsStarted, IGameSessionQueue.metricPlacementsSucceeded, IGameSessionQueue.metricPlacementsTimedOut, IGateway.metric (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metricDuration (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metricInvocations (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metricLatency (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metricSystemErrors (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metricTargetExecutionTime (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metricTargetType (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metricThrottles (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metricUserErrors (@aws-cdk/aws-bedrock-agentcore-alpha), IGateway.metric (@aws-cdk/aws-mediaconnect-alpha), IGateway.metricEgressBridgeDroppedPackets (@aws-cdk/aws-mediaconnect-alpha), IGateway.metricEgressBridgeTotalPackets (@aws-cdk/aws-mediaconnect-alpha), IGateway.metricIngressBridgeDroppedPackets (@aws-cdk/aws-mediaconnect-alpha), IGateway.metricIngressBridgeTotalPackets (@aws-cdk/aws-mediaconnect-alpha), IGateway.metric (aws_bedrockagentcore), IGateway.metricDuration (aws_bedrockagentcore), IGateway.metricInvocations (aws_bedrockagentcore), IGateway.metricLatency (aws_bedrockagentcore), IGateway.metricSystemErrors (aws_bedrockagentcore), IGateway.metricTargetExecutionTime (aws_bedrockagentcore), IGateway.metricTargetType (aws_bedrockagentcore), IGateway.metricThrottles (aws_bedrockagentcore), IGateway.metricUserErrors (aws_bedrockagentcore), IGuardrail.metric, IGuardrail.metricInvocationClientErrors, IGuardrail.metricInvocationLatency, IGuardrail.metricInvocationServerErrors, IGuardrail.metricInvocationThrottles, IGuardrail.metricInvocations, IGuardrail.metricInvocationsIntervened, IGuardrail.metricTextUnitCount, IHttpApi.metricClientError, IHttpApi.metricCount, IHttpApi.metricDataProcessed, IHttpApi.metricIntegrationLatency, IHttpApi.metricLatency, IHttpApi.metricServerError, IHttpStage.metricClientError, IHttpStage.metricCount, IHttpStage.metricDataProcessed, IHttpStage.metricIntegrationLatency, IHttpStage.metricLatency, IHttpStage.metricServerError, IJob.metric, IJob.metricFailure, IJob.metricSuccess, IJob.metricTimeout, ILogGroup.extractMetric, ILogGroup.metric, ILogGroup.metricIncomingBytes, ILogGroup.metricIncomingLogEvents, IMatchmakingConfiguration.metric, IMatchmakingConfiguration.metricCurrentTickets, IMatchmakingConfiguration.metricMatchesAccepted, IMatchmakingConfiguration.metricMatchesCreated, IMatchmakingConfiguration.metricMatchesPlaced, IMatchmakingConfiguration.metricMatchesRejected, IMatchmakingConfiguration.metricPlayersStarted, IMatchmakingConfiguration.metricTimeToMatch, IMatchmakingRuleSet.metric, IMatchmakingRuleSet.metricRuleEvaluationsFailed, IMatchmakingRuleSet.metricRuleEvaluationsPassed, IMemory.metric (@aws-cdk/aws-bedrock-agentcore-alpha), IMemory.metricErrorsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IMemory.metricEventCreationCount (@aws-cdk/aws-bedrock-agentcore-alpha), IMemory.metricForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IMemory.metricInvocationsForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IMemory.metricLatencyForApiOperation (@aws-cdk/aws-bedrock-agentcore-alpha), IMemory.metric (aws_bedrockagentcore), IMemory.metricErrorsForApiOperation (aws_bedrockagentcore), IMemory.metricEventCreationCount (aws_bedrockagentcore), IMemory.metricForApiOperation (aws_bedrockagentcore), IMemory.metricInvocationsForApiOperation (aws_bedrockagentcore), IMemory.metricLatencyForApiOperation (aws_bedrockagentcore), INetworkLoadBalancerMetrics.activeFlowCount, INetworkLoadBalancerMetrics.consumedLCUs, INetworkLoadBalancerMetrics.custom, INetworkLoadBalancerMetrics.newFlowCount, INetworkLoadBalancerMetrics.processedBytes, INetworkLoadBalancerMetrics.tcpClientResetCount, INetworkLoadBalancerMetrics.tcpElbResetCount, INetworkLoadBalancerMetrics.tcpTargetResetCount, INetworkTargetGroupMetrics.custom, INetworkTargetGroupMetrics.healthyHostCount, INetworkTargetGroupMetrics.unHealthyHostCount, IOriginEndpoint.metric, IOriginEndpoint.metricEgressBytes, IOriginEndpoint.metricEgressRequestCount, IOriginEndpoint.metricEgressResponseTime, IOriginEndpoint.metricIngressBytes, IOriginEndpoint.metricIngressRequestCount, IOriginEndpoint.metricIngressResponseTime, IPolicy.metric (@aws-cdk/aws-bedrock-agentcore-alpha), IPolicy.metricEvaluationLatency (@aws-cdk/aws-bedrock-agentcore-alpha), IPolicy.metricEvaluations (@aws-cdk/aws-bedrock-agentcore-alpha), IPolicy.metric (aws_bedrockagentcore), IPolicy.metricEvaluationLatency (aws_bedrockagentcore), IPolicy.metricEvaluations (aws_bedrockagentcore), IPolicyEngine.metric (@aws-cdk/aws-bedrock-agentcore-alpha), IPolicyEngine.metricAuthorizationLatency (@aws-cdk/aws-bedrock-agentcore-alpha), IPolicyEngine.metricDeniedRequests (@aws-cdk/aws-bedrock-agentcore-alpha), IPolicyEngine.metricErrors (@aws-cdk/aws-bedrock-agentcore-alpha), IPolicyEngine.metric (aws_bedrockagentcore), IPolicyEngine.metricAuthorizationLatency (aws_bedrockagentcore), IPolicyEngine.metricDeniedRequests (aws_bedrockagentcore), IPolicyEngine.metricErrors (aws_bedrockagentcore), IProject.metric, IProject.metricBuilds, IProject.metricDuration, IProject.metricFailedBuilds, IProject.metricSucceededBuilds, IQueue.metric, IQueue.metricApproximateAgeOfOldestMessage, IQueue.metricApproximateNumberOfMessagesDelayed, IQueue.metricApproximateNumberOfMessagesNotVisible, IQueue.metricApproximateNumberOfMessagesVisible, IQueue.metricNumberOfEmptyReceives, IQueue.metricNumberOfMessagesDeleted, IQueue.metricNumberOfMessagesReceived, IQueue.metricNumberOfMessagesSent, IQueue.metricSentMessageSize, IRouterInput.metric, IRouterInput.metricBitrate, IRouterInput.metricConnected, IRouterInput.metricContinuityCounterErrors, IRouterInput.metricFailoverSwitches, IRouterInput.metricLatency, IRouterInput.metricNotRecoveredPackets, IRouterInput.metricTotalPackets, IRouterOutput.metric, IRouterOutput.metricArqRequests, IRouterOutput.metricBitrate, IRouterOutput.metricConnected, IRouterOutput.metricTotalPackets, IScheduleGroup.metric, IScheduleGroup.metricAttempts, IScheduleGroup.metricDropped, IScheduleGroup.metricFailedToBeSentToDLQ, IScheduleGroup.metricSentToDLQ, IScheduleGroup.metricSentToDLQTruncated, IScheduleGroup.metricTargetErrors, IScheduleGroup.metricTargetThrottled, IScheduleGroup.metricThrottled, IServerlessCache.metric, IServerlessCache.metricActiveConnections, IServerlessCache.metricCacheHitCount, IServerlessCache.metricCacheHitRate, IServerlessCache.metricCacheMissCount, IServerlessCache.metricDataStored, IServerlessCache.metricNetworkBytesIn, IServerlessCache.metricNetworkBytesOut, IServerlessCache.metricProcessingUnitsConsumed, IServerlessCache.metricReadRequestLatency, IServerlessCache.metricWriteRequestLatency, ISlackChannelConfiguration.metric, IStage.metric, IStateMachine.metric, IStateMachine.metricAborted, IStateMachine.metricFailed, IStateMachine.metricStarted, IStateMachine.metricSucceeded, IStateMachine.metricThrottled, IStateMachine.metricTime, IStateMachine.metricTimedOut, IStream.metric, IStream.metricGetRecords, IStream.metricGetRecordsBytes, IStream.metricGetRecordsIteratorAgeMilliseconds, IStream.metricGetRecordsLatency, IStream.metricGetRecordsSuccess, IStream.metricIncomingBytes, IStream.metricIncomingRecords, IStream.metricPutRecordBytes, IStream.metricPutRecordLatency, IStream.metricPutRecordSuccess, IStream.metricPutRecordsBytes, IStream.metricPutRecordsFailedRecords, IStream.metricPutRecordsLatency, IStream.metricPutRecordsSuccess, IStream.metricPutRecordsSuccessfulRecords, IStream.metricPutRecordsThrottledRecords, IStream.metricPutRecordsTotalRecords, IStream.metricReadProvisionedThroughputExceeded, IStream.metricWriteProvisionedThroughputExceeded, ITable.metric, ITable.metricConditionalCheckFailedRequests, ITable.metricConsumedReadCapacityUnits, ITable.metricConsumedWriteCapacityUnits, ITable.metricSuccessfulRequestLatency, ITable.metricThrottledRequests, ITable.metricUserErrors, ITopic.metric, ITopic.metricNumberOfMessagesPublished, ITopic.metricNumberOfNotificationsDelivered, ITopic.metricNumberOfNotificationsFailed, ITopic.metricNumberOfNotificationsFilteredOut, ITopic.metricNumberOfNotificationsFilteredOutInvalidAttributes, ITopic.metricNumberOfNotificationsFilteredOutNoMessageAttributes, ITopic.metricPublishSize, ITopic.metricSMSMonthToDateSpentUSD, ITopic.metricSMSSuccessRate, IVpnConnection.metric, IVpnConnection.metricTunnelDataIn, IVpnConnection.metricTunnelDataOut, IVpnConnection.metricTunnelState, MemoryBase.metricMemoryRecordCreationCount (@aws-cdk/aws-bedrock-agentcore-alpha), MemoryBase.metricMemoryRecordCreationCount (aws_bedrockagentcore), Method.metric, Method.metricCacheHitCount, Method.metricCacheMissCount, Method.metricClientError, Method.metricCount, Method.metricIntegrationLatency, Method.metricLatency, Method.metricServerError, Metric.attachTo, Metric.with, MetricFilter.metric, NetworkLoadBalancer.metric, NetworkLoadBalancer.metricActiveFlowCount, NetworkLoadBalancer.metricConsumedLCUs, NetworkLoadBalancer.metricNewFlowCount, NetworkLoadBalancer.metricProcessedBytes, NetworkLoadBalancer.metricTcpClientResetCount, NetworkLoadBalancer.metricTcpElbResetCount, NetworkLoadBalancer.metricTcpTargetResetCount, NetworkTargetGroup.metricHealthyHostCount, NetworkTargetGroup.metricUnHealthyHostCount, PolicyEngineBase.metricAuthorizations (@aws-cdk/aws-bedrock-agentcore-alpha), PolicyEngineBase.metricAuthorizations (aws_bedrockagentcore), RestApiBase.metric, RestApiBase.metricCacheHitCount, RestApiBase.metricCacheMissCount, RestApiBase.metricClientError, RestApiBase.metricCount, RestApiBase.metricIntegrationLatency, RestApiBase.metricLatency, RestApiBase.metricServerError, StageBase.metric, StageBase.metricCacheHitCount, StageBase.metricCacheMissCount, StageBase.metricClientError, StageBase.metricCount, StageBase.metricIntegrationLatency, StageBase.metricLatency, StageBase.metricServerError, TableBase.metricSystemErrors, TableBase.metricThrottledRequestsForOperation, TableBaseV2.metricSystemErrors, TaskStateBase.metric, TaskStateBase.metricFailed, TaskStateBase.metricHeartbeatTimedOut, TaskStateBase.metricRunTime, TaskStateBase.metricScheduleTime, TaskStateBase.metricScheduled, TaskStateBase.metricStarted, TaskStateBase.metricSucceeded, TaskStateBase.metricTime, TaskStateBase.metricTimedOut

- Source: [`aws-cloudwatch/lib/metric.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts#L424)
- Type last changed: v2.204.0 · 4 Jul 2025

## Example

TypeScript:

```ts
declare const instance: rds.IDatabaseInstance;

const metrics = rds.DatabaseInstanceMetrics.fromDatabaseInstance(instance);

// How far a read replica lags behind its source (average over 5 minutes)
const replicaLag = metrics.replicaLag();

// The average amount of time taken per disk I/O read operation (average over 1 minute)
const readLatency = metrics.readLatency({ period: Duration.seconds(60) });

// Any other metric, such as an engine-specific one
const binLogDiskUsage = metrics.metric('BinLogDiskUsage', { statistic: 'Maximum' });
```

Python:

```python
# instance: rds.IDatabaseInstance

metrics = rds.DatabaseInstanceMetrics.from_database_instance(instance)

# How far a read replica lags behind its source (average over 5 minutes)
replica_lag = metrics.replica_lag()

# The average amount of time taken per disk I/O read operation (average over 1 minute)
read_latency = metrics.read_latency(period=Duration.seconds(60))

# Any other metric, such as an engine-specific one
bin_log_disk_usage = metrics.metric("BinLogDiskUsage", statistic="Maximum")
```

Java:

```java
IDatabaseInstance instance;

DatabaseInstanceMetrics metrics = DatabaseInstanceMetrics.fromDatabaseInstance(instance);

// How far a read replica lags behind its source (average over 5 minutes)
Metric replicaLag = metrics.replicaLag();

// The average amount of time taken per disk I/O read operation (average over 1 minute)
Metric readLatency = metrics.readLatency(MetricOptions.builder().period(Duration.seconds(60)).build());

// Any other metric, such as an engine-specific one
Metric binLogDiskUsage = metrics.metric("BinLogDiskUsage", MetricOptions.builder().statistic("Maximum").build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
IDatabaseInstance instance;

var metrics = DatabaseInstanceMetrics.FromDatabaseInstance(instance);

// How far a read replica lags behind its source (average over 5 minutes)
var replicaLag = metrics.ReplicaLag();

// The average amount of time taken per disk I/O read operation (average over 1 minute)
var readLatency = metrics.ReadLatency(new MetricOptions { Period = Duration.Seconds(60) });

// Any other metric, such as an engine-specific one
var binLogDiskUsage = metrics.Metric("BinLogDiskUsage", new MetricOptions { Statistic = "Maximum" });
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var instance IDatabaseInstance

metrics := rds.DatabaseInstanceMetrics_FromDatabaseInstance(instance)

// How far a read replica lags behind its source (average over 5 minutes)
replicaLag := metrics.ReplicaLag()

// The average amount of time taken per disk I/O read operation (average over 1 minute)
readLatency := metrics.ReadLatency(&MetricOptions{
	Period: awscdk.Duration_Seconds(jsii.Number(60)),
})

// Any other metric, such as an engine-specific one
binLogDiskUsage := metrics.Metric(jsii.String("BinLogDiskUsage"), &MetricOptions{
	Statistic: jsii.String("Maximum"),
})
```

## Initializer

TypeScript:

```ts
new Metric(props: MetricProps)
```

Python:

```python
Metric(props: MetricProps)
```

Java:

```java
new Metric(MetricProps props)
```

C# / .NET:

```csharp
new Metric(MetricProps props)
```

Golang:

```go
NewMetric(Props MetricProps)
```

## Properties

- `account`: string — Account which this metric comes from.

- `color`: string — The hex color code used when this metric is rendered on a graph.

- `dimensions`: { [key: string]: any } — Dimensions of this metric.

- `id`: string — Unique identifier for this metric when used in dashboard widgets.

- `label`: string — Label for this metric when added to a Graph in a Dashboard.

- `metricName`: string — Name of this metric.

- `namespace`: string — Namespace of this metric.

- `period`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — Period of this metric.

- `region`: string — Region which this metric comes from.

- `statistic`: string — Statistic of this metric.

- `unit`: [Unit](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Unit.html) — Unit of the metric.

- `visible`: boolean — Whether this metric should be visible in dashboard graphs.

- `warnings`: string[] — - use warningsV2

- `warningsV2`: { [key: string]: string } — Warnings attached to this metric.

## Methods

- `anomalyDetectionFor(props: AnomalyDetectionMetricOptions): MathExpression` (static) — Creates an anomaly detection metric from the provided metric.

  **Parameters**

  - `props` — The anomaly detection alarm properties.

  **Returns:** An anomaly detection metric

- `attachTo(scope: IConstruct): Metric // chainable` — Attach the metric object to the given construct scope.

  Returns a Metric object that uses the account and region from the Stack
  the given construct is defined in. If the metric is subsequently used
  in a Dashboard or Alarm in a different Stack defined in a different
  account or region, the appropriate 'region' and 'account' fields
  will be added to it.

  If the scope we attach to is in an environment-agnostic stack,
  nothing is done and the same Metric object is returned.

- `createAlarm(scope: Construct, id: string, props: CreateAlarmOptions): Alarm` — Make a new Alarm for this metric.

  Combines both properties that may adjust the metric (aggregation) as well
  as alarm properties.

- `grantPutMetricData(grantee: IGrantable): Grant` (static) — Grant permissions to the given identity to write metrics.

  **Parameters**

  - `grantee` — The IAM identity to give permissions to.

- `toMetricConfig(): MetricConfig` — Inspect the details of the metric object.

- `toString(): string` — Returns a string representation of an object.

- `with(props: MetricOptions): Metric // chainable` — Return a copy of Metric `with` properties changed.

  All properties except namespace and metricName can be changed.

  **Parameters**

  - `props` — The set of properties to change.
