Skip to content

MetricsDestination

Source: src/AWS/RUM/MetricsDestination.ts

A destination for CloudWatch RUM extended and custom metrics — sends metrics that a RUM app monitor derives from its telemetry events to CloudWatch or to a CloudWatch Evidently experiment, including the metric definitions themselves.

const monitor = yield* RUM.AppMonitor("SiteMonitor", {
domain: "example.com",
});
const metrics = yield* RUM.MetricsDestination("SiteMetrics", {
appMonitorName: monitor.appMonitorName,
destination: "CloudWatch",
// extended metrics require the event pattern matching the metric
metricDefinitions: [
{
name: "SessionCount",
eventPattern: JSON.stringify({
event_type: ["com.amazon.rum.session_start_event"],
}),
},
],
});
const metrics = yield* RUM.MetricsDestination("CustomMetrics", {
appMonitorName: monitor.appMonitorName,
destination: "CloudWatch",
metricDefinitions: [
{
name: "Checkouts",
namespace: "MyApp",
unitLabel: "Count",
eventPattern: JSON.stringify({
event_type: ["com.example.checkout"],
}),
},
],
});