'Is it possible to enable EnableEnhancedMonitoring for AWS Kinesis via CDK?

We would like to log enhanced (per shard) metrics for kinesis using CDK. For standard metrics we're doing this:

  const throughput = new cloudwatch.GraphWidget({
    height: CHART_HEIGHT,
    width: CHART_WIDTH,
    title: "Throughput Exceptions",
  });
  throughput.addLeftMetric(
    stream.metric("ReadProvisionedThroughputExceeded", { statistic: "avg" })
  );

Could not find an obvious way to do it for enhanced metrics from the docs, but perhaps I missed something.

Does anyone know a way?



Solution 1:[1]

Not as far as I can tell. I've pulled down the CDK for aws-kinesis and modified the constructs to do what I want. Ideally you don't have to do this, however sometimes the less supported services like kinesis require this. cloudwatch allows you to specify other ones that are not out of the box with cdk. That's the simpler solution if you're not planning to modify the construct and own that code.

TL;DR

var params = {
  ShardLevelMetrics: [ /* required */
    IncomingBytes | IncomingRecords | OutgoingBytes | OutgoingRecords | WriteProvisionedThroughputExceeded | ReadProvisionedThroughputExceeded | IteratorAgeMilliseconds | ALL,
    /* more items */
  ],
  StreamName: 'STRING_VALUE' /* required */
};
kinesis.enableEnhancedMonitoring(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

run that lambda once

  • or modify the construct if you're super keen. That's assuming CloudFormation allows it which doesn't appear to be the case.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lloyd