@Generated(value="jsii-pacmak/1.73.0 (build 6faeda3)", date="2023-01-31T18:36:51.298Z") @Stability(value=Stable) 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. |
software.amazon.jsii.JsiiObject.InitializationModeIMetric.Jsii$Default, IMetric.Jsii$Proxy| Modifier | Constructor and Description |
|---|---|
protected |
Metric(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Metric(software.amazon.jsii.JsiiObjectRef objRef) |
|
Metric(MetricProps props) |
| 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,
String id,
CreateAlarmOptions props)
Make a new Alarm for this metric.
|
String |
getAccount()
Account which this metric comes from.
|
String |
getColor()
The hex color code used when this metric is rendered on a graph.
|
Map<String,Object> |
getDimensions()
Dimensions of this metric.
|
String |
getLabel()
Label for this metric when added to a Graph in a Dashboard.
|
String |
getMetricName()
Name of this metric.
|
String |
getNamespace()
Namespace of this metric.
|
Duration |
getPeriod()
Period of this metric.
|
String |
getRegion()
Region which this metric comes from.
|
String |
getStatistic()
Statistic of this metric.
|
Unit |
getUnit()
Unit of the metric.
|
List<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.
|
String |
toString()
Returns a string representation of an object.
|
Metric |
with(MetricOptions props)
Return a copy of Metric `with` properties changed.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected Metric(software.amazon.jsii.JsiiObjectRef objRef)
protected Metric(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public Metric(@NotNull
MetricProps props)
props - This parameter is required.@Stability(value=Stable) @NotNull public static Grant grantPutMetricData(@NotNull IGrantable grantee)
grantee - The IAM identity to give permissions to. This parameter is required.@Stability(value=Stable) @NotNull public Metric attachTo(@NotNull 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.@Stability(value=Stable) @NotNull public Alarm createAlarm(@NotNull Construct scope, @NotNull String id, @NotNull 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.@Stability(value=Deprecated) @Deprecated @NotNull public MetricAlarmConfig toAlarmConfig()
toAlarmConfig in interface IMetric@Stability(value=Deprecated) @Deprecated @NotNull public MetricGraphConfig toGraphConfig()
toGraphConfig in interface IMetric@Stability(value=Stable) @NotNull public MetricConfig toMetricConfig()
toMetricConfig in interface IMetric@Stability(value=Stable) @NotNull public String toString()
@Stability(value=Stable) @NotNull public Metric with(@NotNull MetricOptions props)
All properties except namespace and metricName can be changed.
props - The set of properties to change. This parameter is required.@Stability(value=Stable) @NotNull public String getMetricName()
@Stability(value=Stable) @NotNull public String getNamespace()
@Stability(value=Stable) @NotNull public Duration getPeriod()
@Stability(value=Stable) @NotNull public String getStatistic()
@Stability(value=Stable) @Nullable public String getAccount()
@Stability(value=Stable) @Nullable public String getColor()
@Stability(value=Stable) @Nullable public Map<String,Object> getDimensions()
@Stability(value=Stable) @Nullable public String getLabel()
@Stability(value=Stable) @Nullable public String getRegion()
@Stability(value=Stable) @Nullable public Unit getUnit()
@Stability(value=Stable) @Nullable public List<String> getWarnings()
getWarnings in interface IMetricCopyright © 2023. All rights reserved.