MicroProfile Metrics with Prometheus and Grafana
- December 02, 2020
- 2080 Unique Views
- < 1 min read
In a distributed microservices architecture, it is important to have an overview of your systems in terms of CPU, memory management and other important metrics.
This is called Observability, measuring the internal state of a system, in this case, the micro-services instances.
These metrics are gathered centrally, so that you can instantly have an overview of all the values and it allows the determination (mostly automated based on some rules) of the health of the instances.
MicroProfile Metrics allows you to expose some custom defined metrics, but also exposes system metrics, related to CPU and memory, for example.
In this short video Rudy de Busscher shows how to connect MicroProfile Metrics with Prometheus and Grafana to produce useful graphics and to help investigate your microservice architecture.
The goal of MicroProfile Metrics is to expose monitoring data from the implementation in a unified way. It also defines a Java API so that the developer can define and supply his own values.
Prometheus is one of the most popular Open source solutions for gathering metrics. Created in 2012 by SoundCloud (online audio distribution platform and music sharing) and in 2018 graduated at the Cloud Native Computing Foundation. It can be used as a database for storing time series but has many more features:
- Multi-dimensional data model with time series
- Query Language
- Pull data from metric sources
- Alert Manager
Therefore, MicroProfile Metrics exposes the values in the Prometheus format by default. So it can be consumed easily by the scrapers.
Grafana is a multi-platform open source solution for running data analytics, pulling up metrics that make sense of the massive amount of data, and monitoring apps through customizable dashboards.
Republished with permission from the original author - Rudy De Busscher
Don’t Forget to Share This Post!
Comments (2)
Tobiloba
3 years agoI see that you save the point of interest as text in the DB but the response gotten from ChatGPT is JSON. Does this mean you convert the response into string using libraries like gson before saving it in the database?
Denis Magda
3 years agoHey, The response is a String object in the JSON format [1]. The repository takes this JSON string as is and stores to the database [2]. Presently, Spring Data auto-generates the CREATE TABLE statement on the startup and sets the "point of interest" column's type to "text" (or "varchar", don't remember). However, it's always possible to ask Spring Data to use the "json" or "jsonb" type for the column if you wish to query the JSON at the database level. Finally, Vaadin displays a list of PointsOfInterests. Those are generated using the org.json library [3]. Let me know if you have other questions. Hope this helps. [1] https://github.com/YugabyteDB-Samples/budget-journey-gpt/blob/main/src/main/java/com/yugabyte/com/TripsAdvisorService.java#L103 [2] https://github.com/YugabyteDB-Samples/budget-journey-gpt/blob/main/src/main/java/com/yugabyte/com/TripsAdvisorService.java#L74 [3] https://github.com/YugabyteDB-Samples/budget-journey-gpt/blob/main/src/main/java/com/yugabyte/com/TripsAdvisorService.java#L114