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.
Creating a Metrics Destination
Section titled “Creating a Metrics Destination”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"], }), }, ],});Custom Metrics
Section titled “Custom Metrics”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"], }), }, ],});