DEV Community

Anuj Tyagi
Anuj Tyagi

Posted on

Collect AWS Lambda@Edge metrics with Prometheus

This post is about the problem I worked 2 years ago but should be still valid. Why? As I solved the problem internally back in past but forgot to create PR in the official public YACE github repo. If you don't undestand what I am talking about. I will expand this blog in future.

Let me explain from the beginning.

I was working on implementing monitoring for a enterprise infrastructure. I was using Prometheus with YACE (yet another cloudwatch exporter) to collect metrics.

What is YACE exporter?
It's like a plugin used with Prometheus to collect metrics from AWS. We have another option, CloudWatch exporter for the same use case but I am going ahead with YACE exporter.

Image description

From the examples, collecting metrics was straightforward but then I was stuck when I had to collect metrics from Lambda edge but unlike other examples, YACE was not supporting metrics discovery through AWS Lambda edge .

So, I created a Github Issue in YACE repo: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/issues/876

I received response, Lambda@edge don't support tags so it's metrics can't be collected via service discovery. This was blocking my project so I have to somehow solve this problem.

How I solved this problem?

I figure out another approach to collect metrics by using static configuration if you know which regions are you using to collect metrics via Lambda@edge.

How to collect metrics via Static approach?

 apiVersion: v1alpha1
  static:
    - name: us-east-1.<edge_lambda_function_name>
      namespace: AWS/Lambda
      regions:
        - eu-central-1
        - us-east-1
        - us-west-2
        - ap-southeast-1
      period: 600
      length: 600
      metrics:
        - name: Invocations
          statistics: [Sum]
        - name: Errors
          statistics: [Sum]
        - name: Throttles
          statistics: [Sum]
        - name: Duration
          statistics: [Average, Maximum, Minimum, p90]
Enter fullscreen mode Exit fullscreen mode

As you can see, I added all regions my Lambda@edge is using. I also created PR for this in YACE repo.

Hope this helps someone.

Top comments (0)