I have an application that I have to monitor every 5 mins. However, that application does not have a /metrics port for Prometheus to directly scrape from and I don't have any control over that application.
As a workaround, I wrote a python program to manually scrape the data, and transforms those data to my own metrics such as gauge and counters. Then I pushed those metrics to pushgateway for Prometheus to scrape from.
Everything worked fine at local. Now, I want to take a step further by using the AWS Lambda function to pull data and generate metrics for me every 5 mins(so I don't have to keep the python program running on my laptop).
My question would be, instead of using:
push_to_gateway(gateway='localhost:9091', job="Monitor", registry=registry)
to push my metrics to pushgateway, what would this be in the lambda function? Also, I believe the pushgateway should be hosted somewhere for AWS to access. How do we achieve that?
You can create the lambda and run it every 5 minutes with a cloudwatch rule. Inside the lambda, instead of calling push_to_gateway, you can just curl the pushgateway. see and example here. Make sure that the gateway is accessible from the lambda - either behind a public ELB or have them both in the same vpc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With