@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-28T21:34:20.181Z") public class Metric extends software.amazon.jsii.JsiiObject implements IMetric
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());
Modifier and Type | Class and Description |
---|---|
static class |
Metric.Builder
A fluent builder for
Metric . |
IMetric.Jsii$Default, IMetric.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
Metric(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Metric(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
Metric |
attachTo(software.constructs.IConstruct scope)
Attach the metric object to the given construct scope.
|
Alarm |
createAlarm(Construct scope,
java.lang.String id,
CreateAlarmOptions props)
Make a new Alarm for this metric.
|
java.lang.String |
getAccount()
Account which this metric comes from.
|
java.lang.String |
getColor()
The hex color code used when this metric is rendered on a graph.
|
java.util.Map<java.lang.String,java.lang.Object> |
getDimensions()
Dimensions of this metric.
|
java.lang.String |
getLabel()
Label for this metric when added to a Graph in a Dashboard.
|
java.lang.String |
getMetricName()
Name of this metric.
|
java.lang.String |
getNamespace()
Namespace of this metric.
|
Duration |
getPeriod()
Period of this metric.
|
java.lang.String |
getRegion()
Region which this metric comes from.
|
java.lang.String |
getStatistic()
Statistic of this metric.
|
Unit |
getUnit()
Unit of the metric.
|
java.util.List<java.lang.String> |
getWarnings()
Warnings attached to this metric.
|
static Grant |
grantPutMetricData(IGrantable grantee)
Grant permissions to the given identity to write metrics.
|
MetricAlarmConfig |
toAlarmConfig()
Deprecated.
use toMetricConfig()
|
MetricGraphConfig |
toGraphConfig()
Deprecated.
use toMetricConfig()
|
MetricConfig |
toMetricConfig()
Inspect the details of the metric object.
|
java.lang.String |
toString()
Returns a string representation of an object.
|
Metric |
with(MetricOptions props)
Return a copy of Metric `with` properties changed.
|
protected Metric(software.amazon.jsii.JsiiObjectRef objRef)
protected Metric(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public static Grant grantPutMetricData(IGrantable grantee)
grantee
- The IAM identity to give permissions to. This parameter is required.public Metric attachTo(software.constructs.IConstruct 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.
scope
- This parameter is required.public Alarm createAlarm(Construct scope, java.lang.String id, CreateAlarmOptions props)
Combines both properties that may adjust the metric (aggregation) as well as alarm properties.
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.@Deprecated public MetricAlarmConfig toAlarmConfig()
toAlarmConfig
in interface IMetric
@Deprecated public MetricGraphConfig toGraphConfig()
toGraphConfig
in interface IMetric
public MetricConfig toMetricConfig()
toMetricConfig
in interface IMetric
public java.lang.String toString()
public Metric with(MetricOptions props)
All properties except namespace and metricName can be changed.
props
- The set of properties to change. This parameter is required.public java.lang.String getMetricName()
public java.lang.String getNamespace()
public Duration getPeriod()
public java.lang.String getStatistic()
public java.lang.String getAccount()
public java.lang.String getColor()
public java.util.Map<java.lang.String,java.lang.Object> getDimensions()
public java.lang.String getLabel()
public java.lang.String getRegion()
public Unit getUnit()
public java.util.List<java.lang.String> getWarnings()
getWarnings
in interface IMetric