# Cost-Profiling Microservice Applications Using an APM Stack
## 1 Introduction
Having access to both low-level system data and being able to correlate them with application-level macro-metrics such as transactions per minute is ideal for breaking down the operational expenses of each individual microservice. Doing so provides the means to achieve two goals. First, it is necessary for identifying and resolving issues with inefficiencies in the selection of infrastructure through over-provisioning or overtly costly services with respect to their criticality in the overall architecture. Second, it is also essential towards establishing an efficient price model for the microservices themselves when and where these are exposed to third parties. It is our position in this work that building on existing APM solutions offers the necessary information that prior works such as CostHat ([PERSON], 2016) assumed to be available for cost-profiling microservice applications. Unfortunately, however, many of the existing solutions for this purpose are either closed-source (such as the ones mentioned above) or cloud service provider-specific. Closed-source solutions are also frequently offered as a service with a free tier for, e.g., the first 100 GB of data. In practice, these free tiers are not suitable for production-strength systems and make sense only for evaluation purposes. While powerful in their own rights, such solutions very quickly become costly for their adopters. Cloud provider-specific solutions, on the other hand, such as the combination of AWS X-Ray ([[https://aws.amazon.com/xray/](https://aws.amazon.com/xray/)]([https://aws.amazon.com/xray/](https://aws.amazon.com/xray/)) (accessed on 1 December 2022)) with CloudWatch ([[https://aws.amazon.com/cloudwatch/](https://aws.amazon.com/cloudwatch/)]([https://aws.amazon.com/cloudwatch/](https://aws.amazon.com/cloudwatch/)) (accessed on 1 December 2022)), the Application Insights overview extension of Azure Monitor ([[https://azure.microsoft.com/en-us/products/monitor/](https://azure.microsoft.com/en-us/products/monitor/)]([https://azure.microsoft.com/en-us/products/monitor/](https://azure.microsoft.com/en-us/products/monitor/)) (accessed on 1 December 2022)), or Google Cloud Platform's Operations Suite ([[https://cloud.google.com/products/operations](https://cloud.google.com/products/operations)]([https://cloud.google.com/products/operations](https://cloud.google.com/products/operations)) (accessed on 1 December 2022)) (formerly known as Stackdriver), provide end-to-end views of requests as they are resolved through applications and can be easily leveraged for analyzing microservice applications. They are, however, specific to each cloud service provider, and they tend to organize information around the cloud services used rather than the application itself. Furthermore, they charge users similarly to any other cloud service. Thankfully, a number of open-source alternatives do provide APM capabilities. A well-known package is OpenTelemetry, already mentioned above, a Cloud Native Computing Foundation (CNCF) project specific to tracing that works together with external storage backends such as Prometheus ([[https://prometheus.io/](https://prometheus.io/)]([https://prometheus.io/](https://prometheus.io/)) (accessed on 1 December 2022)) or Jaeger and which can receive input from multiple APM solutions. Another very popular solution is the Elasticsearch, Logstash and Kibana (ELK) stack, jointly offered in an observability package known as the Elastic Stack ([[https://www.elastic.co/elastic-stack/](https://www.elastic.co/elastic-stack/)]([https://www.elastic.co/elastic-stack/](https://www.elastic.co/elastic-stack/)) (accessed on 1 December 2022)). The stack is widely known for its proven capability to handle large amounts of data and is used by many companies for both its search engine functionality and its APM capabilities. Elastic has some premium functionality that is offered as a service in the cloud, but the core remains open-source.