question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to setup prometheus client for AWS Lambda integration?

See original GitHub issue

Is your feature request related to a problem? Please describe. I have a small POC setup to evaluate our team’s use of APM. As far as the getting started tutorial goes, all is well. What I’m trying to achieve now is to have user-defined metrics but I cannot seem to get it working.

Please see the below code snippet, we’re expecting to use AWS Lambda as our runtime. I’m not able to determine from existing docs whether this is not yet supported… happy to be be pointed to the right link.

import json
from elasticapm import capture_serverless
from elasticapm import Client
from elasticapm.metrics.base_metrics import MetricsRegistry
from elasticapm.metrics.sets.prometheus import PrometheusMetrics
# import requests

client = Client()
metrics = PrometheusMetrics(MetricsRegistry(client))

@capture_serverless()
def lambda_handler(event, context):
    metrics.counter("request_count").inc()
    return {
        "statusCode": 200,
        "body": json.dumps({
            "message": "hello world",
            # "location": ip.text.replace("\n", "")
        }),
    }

Describe the solution you’d like Need clarification/guidance. How should I setup the prometheus client to push metrics through the APM agent? Is the above the right way to use the API?

Describe alternatives you’ve considered Hoping to achieve the entire setup with the python APM agent library without the need to setup additional services (eg: MetricBeat). We’re currently on Elastic SaaS and I’m using Terraform to provision and configure the required environment variables.

Additional context ELASTIC_APM_API_KEY = “youdon’tneedthis” ELASTIC_APM_SERVER_URL = “some url” ELASTIC_APM_SERVICE_NAME = “helloworld-test-apm” ELASTIC_APM_PROMETHEUS_METRICS = True

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
basepicommented, Apr 21, 2022

Please watch #1534 for more updates here.

0reactions
basepicommented, Apr 6, 2022

One problem: you’re using

ELASTIC_APM_SERVER_URL="[https://itsasecret.apm.ap-southeast-1.aws.cloud.es.io:443](https://itsasecret.apm.ap-southeast-1.aws.cloud.es.io/)"

which means that the agent will send directly do your cloud instance instead of to the extension. You should remove that environment variable or set it to localhost:8200 (which is the default). That should help your timeout issues.

Environment variables do override inline config, so you can use ELASTIC_APM_METRICS_INTERVAL to set it back to a non-zero value. But this is not officially supported at this time, so I’m not sure if things will break.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guide to Monitoring AWS Lambda Metrics with Prometheus ...
A guide to AWS Lambda metrics with Prometheus & Logz.io ... Now that we know which metrics to monitor, let's set up some...
Read more >
Monitoring AWS Lambda with Prometheus and Sysdig
BACK TO blog. In this post, we will show how it's easily possible to monitor AWS Lambda with Sysdig Monitor.
Read more >
AWS Distro for OpenTelemetry adds Prometheus and Lambda ...
Today's release of the AWS Distro for OpenTelemetry (ADOT) now brings support for Prometheus and AWS Lambda and adds AWS X-Ray support in...
Read more >
Monitoring AWS Lambda with Prometheus - PromCat
Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set...
Read more >
Serverless Monitoring with Prometheus and Asserts
To monitor your AWS Lambda applications with Asserts, you must install the Asserts Exporter which will export the metrics to Asserts Cloud.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found