Class Metric
- All Implemented Interfaces:
IMetric
,software.amazon.jsii.JsiiSerializable
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.
Example:
Function fn; Metric minuteErrorRate = fn.metricErrors(MetricOptions.builder() .statistic("avg") .period(Duration.minutes(1)) .label("Lambda failure rate") .build());
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.cloudwatch.IMetric
IMetric.Jsii$Default, IMetric.Jsii$Proxy
-
Constructor Summary
ModifierConstructorDescriptionMetric
(MetricProps props) protected
Metric
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Metric
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionattachTo
(software.constructs.IConstruct scope) Attach the metric object to the given construct scope.createAlarm
(Construct scope, String id, CreateAlarmOptions props) Make a new Alarm for this metric.Account which this metric comes from.getColor()
The hex color code used when this metric is rendered on a graph.Dimensions of this metric.getLabel()
Label for this metric when added to a Graph in a Dashboard.Name of this metric.Namespace of this metric.Period of this metric.Region which this metric comes from.Statistic of this metric.getUnit()
Unit of the metric.Warnings attached to this metric.static Grant
grantPutMetricData
(IGrantable grantee) Grant permissions to the given identity to write metrics.Deprecated.use toMetricConfig()Deprecated.use toMetricConfig()Inspect the details of the metric object.toString()
Returns a string representation of an object.with
(MetricOptions props) Return a copy of Metricwith
properties changed.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Metric
protected Metric(software.amazon.jsii.JsiiObjectRef objRef) -
Metric
protected Metric(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Metric
- Parameters:
props
- This parameter is required.
-
-
Method Details
-
grantPutMetricData
Grant permissions to the given identity to write metrics.- Parameters:
grantee
- The IAM identity to give permissions to. This parameter is required.
-
attachTo
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.
- Parameters:
scope
- This parameter is required.
-
createAlarm
@Stability(Stable) @NotNull public Alarm createAlarm(@NotNull Construct scope, @NotNull String id, @NotNull CreateAlarmOptions props) Make a new Alarm for this metric.Combines both properties that may adjust the metric (aggregation) as well as alarm properties.
- Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
toAlarmConfig
Deprecated.use toMetricConfig()(deprecated) Turn this metric object into an alarm configuration.- Specified by:
toAlarmConfig
in interfaceIMetric
-
toGraphConfig
Deprecated.use toMetricConfig()(deprecated) Turn this metric object into a graph configuration.- Specified by:
toGraphConfig
in interfaceIMetric
-
toMetricConfig
Inspect the details of the metric object.- Specified by:
toMetricConfig
in interfaceIMetric
-
toString
Returns a string representation of an object. -
with
Return a copy of Metricwith
properties changed.All properties except namespace and metricName can be changed.
- Parameters:
props
- The set of properties to change. This parameter is required.
-
getMetricName
Name of this metric. -
getNamespace
Namespace of this metric. -
getPeriod
Period of this metric. -
getStatistic
Statistic of this metric. -
getAccount
Account which this metric comes from. -
getColor
The hex color code used when this metric is rendered on a graph. -
getDimensions
Dimensions of this metric. -
getLabel
Label for this metric when added to a Graph in a Dashboard. -
getRegion
Region which this metric comes from. -
getUnit
Unit of the metric. -
getWarnings
Warnings attached to this metric.- Specified by:
getWarnings
in interfaceIMetric
-