r/PrometheusMonitoring • u/Second_Shift58 • Sep 14 '23
Azure App Service web application - scaled out - how to collect Prometheus metrics?
Hello,
I am trying to use Prometheus to scrape & store metrics for a web application I am building and deploying in Azure. Several of the architectural choices are a given for me; I've been asked to find out if the below is possible, and to implement it.
We have an application tus - resumable file uploads we are deploying to Azure as an Azure App Service; a custom linux container. TusD exposes an endpoint /metrics that Prometheus is meant to scrape. Our App Service plan is set to rules-based scaling between 2 and 30 instances depending on load and traffic. The Azure Firewall is configured to not allow inbound connections to anything except via the load balancer (API management?).
We are hosting Prometheus in another infrastructure cluster, outside of the Azure scope and space. The task is to scrape tus' metrics from the App Service in Azure into the Prometheus instance hosted locally. Right now I have the prometheusstatic_config pointing to the <azure-app-name>.azurewebsites.net/metrics URL, and predictably my requests are being load balanced resulting in sinusoidal metric plots. I've found that the instance in Azure service the request does not tag the response payload (body, head, or headers) with any kind of UUID or identifier to separate the responses.
I have read on StackOverflow and elsewhere that Prometheus is really designed to have direct access to the metrics targets; that load balancing requests like I'm trying to do is implicitly not supported. So my options are to either run Promtheus inside Azure, with network peering access to the tus App Service, or somehow set up a proxy of some kind so that Prometheus can connect to the targets. I've read about a Prometheus Agent, but not very much documentation exists on how to set this up, or if this is right for my use case.
My question is: has anybody had to face this similar architectural challenge? How does one get metrics out of an Azure App Service (that is scaled out) into Prometheus? I'm not able to make code changes directly to tusD (we are trying not to maintain a fork) - is there anything I can do to our infrastructure to allow metrics collection?
