Example 1.
When we select data from the last 30 days to show and we collect data every 15 seconds, we will see 30 results (not 4 60 24 * 30 = 172 800 results) in a graph taken at a specific hour; e.g.
Date | Quantity |
21.02.2020 12:12:12 | 23 |
22.02.2020 12:12:12 | 25 |
23.02.2020 12:12:12 | 28 |
… | … |
Example 2.
We want to see the last 5 minutes with a step time of one minute and application-collected data every 15 seconds.
Collected data:
Date | Quantity |
24.02.2020 12:12:00 | 12 |
24.02.2020 12:12:15 | 1 |
24.02.2020 12:12:30 | 4 |
24.02.2020 12:12:45 | 16 |
24.02.2020 12:13:00 | 8 |
24.02.2020 12:13:15 | 1 |
24.02.2020 12:13:30 | 3 |
24.02.2020 12:13:45 | 11 |
24.02.2020 12:14:00 | 5 |
… | … |
We will see 5 results with data from the specified peak:
Date | Quantity |
24.02.2020 12:12:00 | 12 |
24.02.2020 12:13:00 | 8 |
24.02.2020 12:14:00 | … |
24.02.2020 12:15:00 | … |
24.02.2020 12:16:00 | … |
not summary like this
Date | Quantity | Explanation |
12:12:00 | 33 | because we collected in 60 seconds 12+1+4+16 |
12:13:00 | 23 | because we collected in 60 seconds 8+1+3+11 |
… | … |
If we collected data between these taken peaks, the graph will not show it.
Don’t use these metrics to check if a specific endpoint/place in the code is used or not.
Just put there a normal log (and check after a minimum of one month if it was logged) and talk with the business if the functionality is supported. Also, remember that some jobs may be executed once per year etc.
Usually, you need to check data for the last 7 days. We decided to collect data every 2 minutes. To clarify how it worked:
…
request 17:11:11 counter 1
request 17:11:12 counter 2
request 17:11:12 counter 3
…
request 17:12:13 counter 58
…
If we ask the controller for data we will get counter 58. So we have only one data row which represents data for 58 requests in two minutes. It’s much easier to prepare a report for the business on how their application works.
That’s it! We have everything that is needed in the application’s code to get data using Prometheus.
Authors
Grzegorz Matuszak
DevOps Engineer with deep interest in code optimization. He's studying the stories behind the legacy code he gets to work with. Big fan of bass instruments.
Kamil Rosenberger
DevOps specialist with over 6 years of experience. Skilled with various databases and environments (Windows, Linux). Always follows latest cloud tech trends. When he doesn't work, he likes spending time with his family most.
