Prometheus Development Best Practices¶
There are a series of developer best practices recommended to ensure the highest efficiency.
Data collection, snippet capability, connection, and code simplicity are just some of the areas that benefit from the following Development Best Practices.
Best Practices¶
Prometheus supports many binary operators (like arithmetic, trigonometric, comparison, etc) and aggregation operations (like sum, min, max, avg, etc). Before defining a custom step to perform these operations with the collected data, consider using the operators as part of your query.
Prometheus supports several functions to operate on data. Before you define a custom step to do something similar, consider using the function as part of your query.
The Snippet Framework truncates indices if they are longer than 512 characters. As a result of this truncation, a new index will be generated, with the first original 50 characters of the index followed by a unique identifier. If possible, try to reduce the index by using the key
labels
of the PromQL syntax.
Design Checklist for Prometheus Dynamic Applications¶
Before you start to write your Dynamic Applications, think through your process.
Model
What does the data that you want to collect look like?
Collection Objects
What data do you want to collect?
Query
What metrics do you need to collect?
Ensure to use appropriate operators and functions to get desired data.
Labels
If you find an opportunity to reduce the labels, use the key labels to select only the labels of interest.