Skip to content

MetricStream

Source: src/AWS/CloudWatch/MetricStream.ts

A CloudWatch metric stream — continuously exports CloudWatch metrics to a Kinesis Data Firehose delivery stream (and on to S3, Datadog, etc.).

Firehose Delivery Stream

const stream = yield* MetricStream("MetricsExport", {
FirehoseArn: "arn:aws:firehose:us-east-1:123456789012:deliverystream/example",
RoleArn: "arn:aws:iam::123456789012:role/example",
OutputFormat: "json",
});

Stream Only Selected Namespaces

const stream = yield* MetricStream("LambdaMetricsExport", {
FirehoseArn: firehose.deliveryStreamArn,
RoleArn: role.roleArn,
OutputFormat: "json",
IncludeFilters: [{ Namespace: "AWS/Lambda" }],
});
// init — bind the stream to the function (see GetMetricStream)
const getMetricStream = yield* AWS.CloudWatch.GetMetricStream(stream);
// runtime
const result = yield* getMetricStream();
const state = result.State; // "running" | "stopped"