How to setup prometheus client for AWS Lambda integration?
See original GitHub issueIs 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:
- Created a year ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Please watch #1534 for more updates here.
One problem: you’re using
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.