# Cost-Profiling Microservice Applications Using an APM Stack
## 3 Design and Implementation
### APM Stack Selection  
Looking into the requirements discussed in the previous section and the existing solutions discussed in the introductory section, we were able to select a suitable APM stack to use for the basis of our proposal by the process of elimination. More specifically, cloud=service-provider-specific tools such as AWS X-ray were very quickly deemed not applicable because they both do not offer a complete observability proposition (Requirement \(\mathrm{NFR}_{3}\)), are not platform-agnostic (Requirement \(\mathrm{NFR}_{2}\)), and they are not open-source (Requirement \(\mathrm{NFR}_{6}\)). Closed-source solutions such as NewRelic, Datalog, Splunk, and Dynatrace were similarly eliminated for the latter reason. Open-source APM solutions such as OpenZipkin and OpenTelemetry, on the other hand, do not have (sufficient) integration options for metrics and/or logs (Requirement \(\mathrm{FR}_{1}\)). The most attractive APM stack for our purposes, therefore, was the Elastic Stack. \begin{table}
\begin{tabular}{l c c} \hline \hline
**Category** & **Requirement** \\ \hline \multirow{6}{*}{Functional} & \multirow{2}{*}{\(\mathrm{FR}_{1}\)} & Storage of logs, metrics and traces is supported \\  & & \(\bullet\) & Data retention rate should be configurable \\  & & \(\bullet\) & Newer data to be accessed faster than older ones \\  & & \(\bullet\) & Different storage solutions must be supported \\  & \(\mathrm{FR}_{2}\) & The solution is ISO-270001-compliant \\  & & \(\bullet\) & Automated backups are enabled \\  & & \(\bullet\) & Restoring data from external snapshots is possible \\  & & \(\bullet\) & Alerts are to be sent for critical events \\  & \(\mathrm{FR}_{3}\) & The metrics are visualized in a dashboard \\  & & \(\bullet\) & Role-based access control to the dashboard is supported \\  & & \(\bullet\) & The creation of new and the customization of existing data visualizations is supported \\  & & \(\bullet\) & Visualization can be embeddable in other applications or shareable externally \\ \hline \multirow{6}{*}{Non-functional} & \multirow{2}{*}{\(\mathrm{NFR}_{3}\)} & The system should be: \\  & \(\mathrm{NFR}_{1}\) & Able to ingest data at the rate they are produced by the monitoring \\  & & \(\mathrm{agents}\) \\  & \(\mathrm{NFR}_{2}\) & Cloud-provider agnostic, i.e., the solution should work across different cloud providers \\  & \(\mathrm{NFR}_{3}\) & Integrated in a complete observability environment instead of being offered as a stand-alone cost-profiling tool \\  & \(\mathrm{NFR}_{4}\) & Able to scale with demand as the number and complexity of the monitored applications grows \\  & \(\mathrm{NFR}_{5}\) & Designed with fault tolerance and high availability in mind \\  & \(\mathrm{NFR}_{6}\) & Offered as an open-source solution \\ \hline \multirow{6}{*}{Technical} & \multirow{2}{*}{\(\mathrm{TR}_{1}\)} & Integrated context view should be offered, allowing for switching between different data views seamlessly \\  & & The solution should act as a single source of truth for all monitoring \\ \cline{1-1}  & \(\mathrm{TR}_{2}\) & Data presentation should focus on usability, preferring a single page view for fast exploration \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Elicited requirements for the CPT solution from the case study. Figure 2 provides an overview of the Elastic Stack architecture. As can be seen in the figure, Elastic Stack combines multiple open-source software tools to offer a complete monitoring solution. The search and analytics engine Elasticsearch is at the heart of the stack. It allows for data ingestion and the indexing of diverse types of both structured and unstructured data and offers simple APIs for integration with other systems. Logstash provides the functionality to keep track of application and APM logs. Kibana wraps around the Elasticsearch API to offer a user-friendly UI for managing the Elastic Stack and visualizing Elasticsearch data.