sensu / sensu-cloudwatch-check

AWS Cloudwatch plugin for Sensu Go (including AWS service presets)
MIT License
0 stars 2 forks source link

Add queries + preset for AWS CloudFront #3

Open calebhailey opened 2 years ago

calebhailey commented 2 years ago

See first comment for specs.

thoward commented 2 years ago

My part of this is to spec the MVP set of CloudFront (CF) metric names, as queried from CloudWatch(CW). To do that I analyzed Sumo Logic's existing CF dashboards, Telegraf's CF/CW support, Prometheus' CF/CW support, and DataDog's CF support.

Reference Links:

TLDR; Metric Names

MVP Metrics

Stretch: Support for CloudFront "Additional Metrics"

Stretch: Lambda Edge metrics

Tags

DataDog

This is the only product that gives CloudFront-specific metric names in their documentation (rather than just providing a generalized CloudWatch collector).

The list of metrics is here.

The naming convention differs from Prometheus/Telegraf in that it is less generalized to CloudWatch, and more specific to CloudFront. Metrics names follow this structure: aws.cloudfront.<metric-name>. Notably, the concept of statistics is not included (e.g. no sum/average/etc.) is described.

For example, aws.cloudfront.requests

Also, they include support for CloudFront's "Additional Metrics", and for Lambda Edge.

Tags

Per their docs: "Each of the metrics retrieved from AWS are assigned the same tags that appear in the AWS console, including but not limited to aws_account, region, and distributionid."

Prometheus Exporter

The docs for cloudwatch_exporter don't mention CloudFront specifically, but give general information on CloudWatch metrics, with some examples.

It seems that they follow naming convention like: aws_<product-namespace>_<metric-name>_<statistic>

For example, the ELB RequestCount metric, using Sum statistic is produced as:

aws_elb_request_count_sum

Statistic suffixes are mapped as such in the code:

For CloudFront the namespace is AWS/CloudFront, so the prefix for Promethus metric names would be aws_cloudfront_*

Tags

Tags in cloudwatch_exporter are derived from what the AWS docs calls dimensions, and vary by the metric. They are converted to snake case before being used as tags.

For CloudFront that looks like the tags would be:

Telegraf

Telegraf provides a Cloudwatch input plugin, and the metric names it produces are similar to the Prometheus cloudwatch_exporter... However it uses an additional prefix of cloudwatch_*, so the example above would look like cloudwatch_aws_elb_request_count_sum rather than aws_elb_request_count_sum.

Otherwise, behaviour/metric names/tags seem the same as Prometheus.

Sumo Logic Dashboards

The existing Sumo CloudFront dashboards work from logs, parsing out CSV data from individual log lines. I reviewed each observable to see if we might be able to replace those with a metrics based approach, but unfortunately none of the current dashboard observables are able to be replaced by what is available from CloudWatch.

Rather, it's my suggestion that we create a news metrics-based Sumo Logic dashboards for CloudFront that surfaces the metrics described above in three dashboards: "AWS CloudFront - Overview", "AWS CloudFront - Additional Metrics", and "AWS CloudFront - Lambda@Edge"

thoward commented 2 years ago

Since there is an existing CloudFront preset implemented, I reviewed that code to see what needs to change to get the desired output. As far as I can tell right now the code outputs metric names similar to DataDogs. Which means the change may only need to be as simple as changing the . separators to _s. Unfortunately there is no example output provided in our documentation, and I don't have CloudWatch/CloudFront to test it against, so I have no way to verify the current metric naming.

The measurement string in the CloudFront preset includes the MVP and Additional Metrics sets, but doesn't seem to include Lambda Edge metrics.