Prometheus Metric Management and Usage Methods, Systems, Media, and Electronic Devices

By parsing the PromQL expression of the Prometheus metrics, oneData information is generated and rule descriptions are automatically generated, which solves the problem of manually adding descriptions by alert configurators, and standardized and complete rule configuration is achieved.

CN119311513BActive Publication Date: 2025-07-25SHANGHAI SHUHE INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411347690.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-07-25
Estimated Expiration
2044-09-26

AI Technical Summary

Technical Problem

When using Prometheus for monitoring alarms, the alarm configurator needs to manually add descriptions to explain the meaning of alarm configuration rules and metrics, which increases the workload.

Method used

By parsing the PromQL expression corresponding to the Prometheus metric, generate OneData information and generate the metric name based on the preset naming specification, save it to MySQL, and automatically generate rule descriptions to assist in understanding the configuration rules.

Benefits of technology

The workload of alarm configuration personnel is reduced, and the generated description is more standardized and complete, making it easier for users to understand configuration rules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311513B_ABST
    Figure CN119311513B_ABST
Patent Text Reader

Abstract

This application provides a Prometheus metric management and usage method, system, medium, and electronic device; the Prometheus metric management method includes: obtaining a first PromQL expression corresponding to a Prometheus metric; parsing the first PromQL expression based on OneData and ANTLR to obtain OneData information; generating a metric name based on a preset naming specification and the OneData information; saving the metric name, the OneData information, and the first PromQL expression to MySQL; in this application, by parsing the PromQL expression corresponding to the Prometheus metric, generating OneData information in reverse, and generating a metric name through this OneData information, when using the Prometheus metric subsequently, the metric name, OneData information, and this PromQL expression can be directly selected for use, and the configuration rules can be assisted in understanding through the metric name, OneData information, and this PromQL expression, eliminating the process of the alarm configurator manually adding descriptions and reducing the workload of the alarm configurator.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of data processing, and relates to a Prometheus, in particular to a method, system, medium, and electronic device for Prometheus metric management and use. Background Art

[0002] In the scenario of using Prometheus for monitoring and alerting, when an alert configurator configures a PromQL expression, since the alert notification recipient may not understand the PromQL expression and cannot understand the alert rule, it is necessary to manually add a description to explain the alert configuration rule and the meaning of the metric. This will undoubtedly increase the workload of the alert configurator. Summary of the Invention

[0003] The purpose of this application is to provide a method, system, medium, and electronic device for Prometheus metric management and use to solve the problems pointed out in the above background art.

[0004] In a first aspect, this application provides a Prometheus metric management method, and the Prometheus metric management method includes: obtaining a first PromQL expression corresponding to a Prometheus metric; parsing the first PromQL expression based on OneData and ANTLR to obtain OneData information; generating a metric name based on a preset naming specification and the OneData information; and saving the metric name, the OneData information, and the first PromQL expression to MySQL.

[0005] In this application, by parsing the PromQL expression corresponding to the Prometheus metric to reversely generate OneData information, and generating a metric name through this OneData information, when using the Prometheus metric subsequently, the metric name, OneData information, and this PromQL expression can be directly selected for use, and the configuration rule can be assisted in understanding through the metric name, OneData information, and this PromQL expression, saving the process of the alert configurator manually adding a description and reducing the workload of the alert configurator.

[0006] In an implementation manner of the first aspect, the first PromQL expression is written by a metric Owner according to the original metric.

[0007] In an implementation manner of the first aspect, the preset naming specification is: [Type Tag] Statistical Period_Atomic Index_Statistical Method_Suffix [Dimension Tag] [Business Limitation Tag]; where the [Type Tag] is used to indicate the type of the Prometheus metric; the suffix is the unique encoding corresponding to the first PromQL expression; the [Dimension Tag] is used to indicate the dimension of the Prometheus metric; and the [Business Limitation Tag] is used to indicate the business limitation of the Prometheus metric.

[0008] In a second aspect, the present application provides a method for using Prometheus metrics. The Prometheus metrics are the above-mentioned Prometheus metrics. The method for using Prometheus metrics includes: determining a target Prometheus metric, a target operator, a target threshold, and a target logical operator according to actual requirements; configuring a target rule according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator; determining a target PromQL expression corresponding to the target Prometheus metric based on a first PromQL expression; generating a second PromQL expression corresponding to the target rule based on the target operator, the target threshold, the target logical operator, and the target PromQL expression; and sending the second PromQL expression to Prometheus to make the target rule effective.

[0009] In the present application, a method for using Prometheus metrics is provided. In practical applications, according to actual requirements, the second PromQL expression corresponding to the target rule can be directly generated by selecting and using the first PromQL expression provided in the above-mentioned Prometheus metric management method.

[0010] In an implementation manner of the second aspect, the method for using Prometheus metrics further includes: generating a rule description according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator, and saving the rule description to MySQL; and / or saving the target rule to MySQL.

[0011] In this implementation manner, by automatically generating the rule description, the standardization and integrity of the description are ensured, the process of manual addition of the description by the alarm configurator is omitted, and by saving the rule description to MySQL, it is convenient for users to understand the target rule.

[0012] In an implementation of the second aspect, the method for using Prometheus metrics further includes: when Prometheus triggers the actual requirement, sending the target rule and the rule description to the recipient client.

[0013] In this implementation, the target rule and the rule description can assist the user in understanding the target rule.

[0014] In a third aspect, the present application provides a Prometheus metric management system. The Prometheus metric management system includes: a first acquisition module for acquiring a first PromQL expression corresponding to a Prometheus metric; a second acquisition module for parsing the first PromQL expression based on OneData and ANTLR to obtain OneData information; a generation module for generating a metric name based on a preset naming specification and the OneData information; and a storage module for storing the metric name, the OneData information, and the first PromQL expression in MySQL.

[0015] In a fourth aspect, the present application provides a Prometheus metric usage system. The Prometheus metric is the above-mentioned Prometheus metric. The Prometheus metric usage system includes: a first determination module for determining a target Prometheus metric, a target operator, a target threshold, and a target logical operator according to the actual requirement; a configuration module for configuring a target rule according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator; a second determination module for determining a target PromQL expression corresponding to the target Prometheus metric based on a first PromQL expression; a generation module for generating a second PromQL expression corresponding to the target rule based on the target operator, the target threshold, the target logical operator, and the target PromQL expression; and a sending module for sending the second PromQL expression to Prometheus to make the target rule effective.

[0016] In a fifth aspect, the present application provides an electronic device. The electronic device includes: a processor and a memory; the memory is used for storing a computer program; and the processor is used for executing the computer program stored in the memory so that the electronic device executes the above-mentioned Prometheus metric management method and / or the above-mentioned Prometheus metric usage method.

[0017] In a sixth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by an electronic device, the above-mentioned Prometheus metric management method and / or the above-mentioned Prometheus metric usage method are implemented.

[0018] As described above, the Prometheus metric management and usage methods, systems, media, and electronic devices of the present application have the following beneficial effects:

[0019] (1) Compared with the prior art, the present application uses the OneData theory to solve the problem that Prometheus metrics have no standardized naming and description. By parsing PromQL expressions to reverse-generate OneData information, it has the advantages of less workload and wider coverage.

[0020] (2) By saving the metric names, OneData information, and the first PromQL expression, it is convenient to directly select and use when using Prometheus metrics later, and it is beneficial for users to understand the target rules configured according to actual needs.

[0021] (3) By automatically generating rule descriptions, compared with the prior art where alarm configurators add descriptions subjectively, the descriptions are more standardized and complete. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It shows a flowchart of the Prometheus metric management method described in an embodiment of the present application.

[0023] Figure 2 It shows a schematic diagram of the principle of the Prometheus metric management method described in an embodiment of the present application.

[0024] Figure 3 It shows a flowchart of the Prometheus metric usage method described in an embodiment of the present application.

[0025] Figure 4 It shows a schematic structural diagram of the Prometheus metric management system described in an embodiment of the present application.

[0026] Figure 5 It shows a schematic structural diagram of the Prometheus metric usage system described in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0027] The following describes the implementation manners of the present application through specific examples. Those skilled in the art can easily understand other advantages and effects of the present application from the content disclosed in this specification. The present application can also be implemented or applied through other different specific implementation manners. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, without conflict, the following embodiments and the features in the embodiments can be combined with each other.

[0028] It should be noted that the diagrams provided in the following embodiments only illustrate the basic concept of the present application in a schematic manner. Therefore, only the components related to the present application are shown in the diagrams, rather than being drawn according to the number, shape, and size of the components in actual implementation. The type, quantity, and proportion of each component in actual implementation can be arbitrarily changed, and the component layout type may also be more complex.

[0029] Refer to Figures 1 to 5 The following embodiments of the present application provide a Prometheus metric management and usage method, system, medium, and electronic device. Compared with the prior art, the present application uses the OneData theory to solve the problem that Prometheus metrics have no standardized naming and description. By parsing the PromQL expression to reversely generate OneData information, it has the advantages of less workload and wider coverage. By saving the metric name, OneData information, and the first PromQL expression, it is convenient to directly select and use when using Prometheus metrics later, and it is beneficial for users to understand the target rules configured according to actual needs. By automatically generating rule descriptions, compared with the prior art where alarm configurators add descriptions subjectively, the descriptions are more standardized and complete.

[0030] Prometheus is an open-source system monitoring and alerting tool designed for modern cloud-native environments. Prometheus was developed internally at SoundCloud by former Google engineers and later released as an independent open-source project.

[0031] PromQL is the built-in data query language of Prometheus, which can implement querying, aggregating, logical operations, etc. on event sequence data. It is also widely used in the daily applications of Prometheus, including data querying, visualization, and alert handling.

[0032] Next, the technical solutions in the embodiments of the present application will be described in detail with reference to the accompanying drawings in the embodiments of the present application.

[0033] Such as Figure 1As shown in the figure, in one embodiment, the present application provides a Prometheus metric management method, and the Prometheus metric management method includes:

[0034] Step S101, obtain a first PromQL expression corresponding to the Prometheus metric.

[0035] In one embodiment, the first PromQL expression is written by the metric Owner according to the original metric.

[0036] It should be noted that the original metric refers to the most basic and original metric or variable for data collection or gathering, usually the data metric that has not undergone any processing or calculation and is directly obtained from the data source; the metric Owner (corresponding to the alarm configurator in the above background technology, that is, an administrator with corresponding professional knowledge who can write an accurate PromQL expression) is a professional in the enterprise responsible for a specific metric. They are not only managers of data and numbers, but also analysts and decision-makers of data. They need to be responsible for the collection, analysis, and interpretation of the metric to better assist the enterprise in decision-making and planning. At the same time, the metric Owner should have a profound understanding of the business and technical capabilities to better maintain and optimize the metric.

[0037] Specifically, when generating the original metric through an application or the like, the metric Owner supplements basic information for the original metric according to the actual situation. For example, for mysql_request_count, when generating it, the atomic metric: database request count, and the supplementary dimension Chinese name: application name, database instance, etc. are associated; then, the metric Owner adds a derived metric based on the original metric supplemented with basic information. For example:

[0038] sum(increase(mysql_request_count{springapp='metricplus',dataSourceInstance= ~ '.*aliyuncs.*'}

[0039] [5m])>0)by(dataSourceInstance).

[0040] It should be noted that what specific information the above basic information includes is not a condition for restricting the present application. In actual applications, it is determined by the metric Owner according to the actual situation.

[0041] The atomic metric is a measurement based on a certain business event behavior and is an indivisible metric in the business definition, with a clear business term, such as payment amount.

[0042] Derived indicator = one atomic indicator + multiple business restrictions (optional) + statistical period, which can be understood as the delineation of the business statistical scope of the atomic indicator. For example, for the atomic indicator: payment amount, the payment amount of overseas buyers in the most recent day is a derived indicator.

[0043] Dimension is the environment of measurement, used to reflect a class of attributes of the business. The set of such attributes constitutes a dimension, which can also be called an entity object. A dimension belongs to a data domain, such as the geographical dimension (including content at levels of country, region, province, and city), and the time dimension (including content at levels of year, quarter, month, week, day, etc.).

[0044] Statistical period is used to clarify the time range or time point for data statistics, such as the most recent 30 days, natural week, as of the current day, etc.

[0045] Business restriction is a key component used to refine and standardize the definition of data indicators. Business restrictions are the conditions used to filter out records that meet specific business rules in derived indicators.

[0046] Step S102: Parse the first PromQL expression based on OneData and ANTLR to obtain OneData information.

[0047] It should be noted that OneData is a methodology for data management and integration proposed by Alibaba Group, aiming to build a unified, standardized, and shareable global data system. Its goal is to solve common data management problems within large organizations; ANTLR (ANother Tool for Language Recognition) is a powerful open-source parser generator, mainly used to read, process, execute, or translate structured text or binary files, especially programming languages, domain-specific languages (DSLs), or any other context-free grammar (CFG).

[0048] The working principle of step S102 will be further explained and illustrated through specific embodiments below.

[0049] As Figure 2 shown, in one embodiment, the first PromQL expression is:

[0050] sum(increase(mysql_request_count{springapp='metricplus',dataSourceInstance= ~ '.*aliyuncs.*'}

[0051] [5m])>0) by (dataSourceInstance), after parsing it through ANTLR, the obtained OneData information includes:

[0052] Statistical method: sum;

[0053] Atomic metric: number of database requests;

[0054] Business restrictions: 1. Application name equals metricplus; 2. Database instance fuzzy match.*aliyuncs.*; 3. Value greater than 0;

[0055] Statistical period: the last 5 minutes;

[0056] Dimension: database instance.

[0057] Step S103, generate a metric name based on the preset naming convention and the OneData information.

[0058] Specifically, according to the preset naming convention, generate a metric name automatically based on the OneData information.

[0059] In one embodiment, the preset naming convention is: [Type label] Statistical period_Atomic metric_Statistical method_Suffix [Dimension label] [Business restriction label]; where

[0060] The [Type label] is used to indicate the type of the Prometheus metric; the suffix is the unique encoding corresponding to the first PromQL expression; the [Dimension label] is used to indicate the dimension of the Prometheus metric; specifically, the dimension of the Prometheus metric is displayed when the mouse hovers; the [Business restriction label] is used to indicate the business restriction of the Prometheus metric; specifically, the business restriction of the Prometheus metric is displayed when the mouse hovers.

[0061] In one embodiment, different symbols are used to represent different types of Prometheus metrics (as Figure 2 shown in, the symbol "D" is used to represent a derived metric).

[0062] In one embodiment, the suffix is a digital encoding automatically generated according to the first PromQL expression (such as Figure 2 "2315" in), and for each first PromQL expression, this suffix is unique.

[0063] It should be noted that the type label includes at least but is not limited to any one of the following: original metric, derived metric, composite metric.

[0064] The working principle of step S103 will be further explained and illustrated through specific embodiments below.

[0065] As Figure 2 shown, the generated metric name is:

D

Dimension (1)

Qualification (3)

Dimension (1)

Qualification (3)

[0066] In one embodiment, for metric names that do not conform to the preset naming convention, they are manually changed by the metric Owner.

[0067] Step S104, save the metric name, the OneData information, and the first PromQL expression to MySQL.

[0068] It should be noted that by saving the metric name, the OneData information, and the first PromQL expression to MySQL, it enables direct selection and use when using the metric subsequently, and is beneficial for users to better understand the configuration rules based on the metric name, the OneData information, and the first PromQL expression.

[0069] MySQL is a relational database management system developed by MySQL AB in Sweden and belongs to the products of Oracle. MySQL is one of the most popular relational database management systems. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) application software.

[0070] This application uses the OneData theory to solve the problem that Prometheus metrics do not have a standardized naming and description. By reverse generating OneData information by parsing the metric PromQL expression, it has the following advantages:

[0071] (1) Less workload. Compared with the prior art where OneData is used to generate metrics forward, it does not require very strict management of dimension information and dependent derived metrics.

[0072] (2) It has a wider coverage. As long as a PromQL expression can be written, it can be covered. If the OneData information cannot be automatically generated in some special cases, manual entry can be used as a backup; while if OneData generates metrics in the forward direction, in some special cases, it may not be possible to generate the PromQL expression for the metrics.

[0073] The protection scope of the Prometheus metric management method described in the embodiments of this application is not limited to the execution order of the steps listed in this embodiment. Any solution achieved by adding or subtracting steps of the prior art and replacing steps according to the principles of this application is included in the protection scope of this application.

[0074] Such as Figure 3 As shown, in one embodiment, this application provides a Prometheus metric usage method. The Prometheus metrics are the Prometheus metrics provided by the above Prometheus metric management method; the Prometheus metric usage method includes:

[0075] Step S301: Determine the target Prometheus metric, target operator, target threshold, and target logical operator according to actual requirements.

[0076] Specifically, the target operator includes at least, but is not limited to: >, =, <; the target logical operator includes at least, but is not limited to: and, or.

[0077] Step S302: Configure a target rule according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator.

[0078] Step S303: Determine the target PromQL expression corresponding to the target Prometheus metric based on the first PromQL expression.

[0079] Specifically, determine the target PromQL expression corresponding to the target Prometheus metric based on the first PromQL expression saved in step S104 above. That is, when using the target PromQL expression, it can be directly selected and used from the first PromQL expression saved in step S104, and this target PromQL expression can be reused. When configuring next time, this target PromQL expression can be selected again without having to rewrite this target PromQL expression, thus realizing metric reuse.

[0080] Step S304: Generate a second PromQL expression corresponding to the target rule based on the target operator, the target threshold, the target logical operator, and the target PromQL expression.

[0081] Step S305, send the second PromQL expression to Prometheus to make the target rule effective.

[0082] In one embodiment, the method for using Prometheus metrics further includes: generating a rule description according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator, and saving the rule description to MySQL.

[0083] It should be noted that by automatically generating the rule description, compared with the prior art where the configurator describes it subjectively, the rule description is more standardized and complete; at the same time, by saving the rule description to MySQL, it can assist users in understanding the target rule.

[0084] In one embodiment, the method for using Prometheus metrics further includes: saving the target rule to MySQL.

[0085] It should be noted that by saving the target rule, it is beneficial for users to understand Prometheus metrics.

[0086] In one embodiment, the method for using Prometheus metrics further includes: when Prometheus triggers the actual requirement, sending the target rule and the rule description to the recipient client.

[0087] It should be noted that by sending the target rule and the rule description to the recipient client, it is beneficial to assist the user (i.e., the recipient) in understanding the second PromQL expression.

[0088] The method for using Prometheus metrics provided by this application can be applied to various scenarios, such as in the monitoring and alerting scenario; specifically, when Prometheus triggers an alert (corresponding to the above-mentioned actual requirement), the method for using Prometheus metrics includes: receiving the alert event sent by Prometheus, and generating a corresponding second PromQL expression according to the alert event; at the same time, pushing the target rule and the rule description corresponding to the second PromQL expression to the recipient client.

[0089] The protection scope of the method for using Prometheus metrics described in the embodiments of this application is not limited to the execution order of the steps listed in this embodiment. Any solution achieved by adding or subtracting steps of the prior art and replacing steps according to the principle of this application is included in the protection scope of this application.

[0090] An embodiment of the present invention further provides an electronic device, which includes: a processor and a memory; the memory is used to store a computer program; the processor is used to execute the computer program stored in the memory, so that the electronic device executes the above-mentioned Prometheus metric management method and / or the above-mentioned Prometheus metric usage method.

[0091] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by an electronic device, it implements the above-mentioned Prometheus metric management method and / or the above-mentioned Prometheus metric usage method.

[0092] Those of ordinary skill in the art can understand that all or part of the steps in the methods of the above embodiments can be completed by instructing a processor through a program. The program can be stored in a computer-readable storage medium, and the storage medium is a non-transitory medium, such as a random access memory, a read-only memory, a flash memory, a hard disk, a solid-state drive, a magnetic tape, a floppy disk, an optical disc, and any combination thereof. The above storage medium can be any available medium that a computer can access or a data storage device such as a server or a data center that integrates one or more available media. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a digital video disc (DVD)), or a semiconductor medium (for example, a solid-state disk (SSD)), etc.

[0093] An embodiment of the present application further provides a Prometheus metric management system, which can implement the Prometheus metric management method described in the present application. However, the implementation device of the Prometheus metric management method described in the present application includes, but is not limited to, the structure of the Prometheus metric management system listed in this embodiment. Any structural deformation and replacement of the prior art made according to the principle of the present application are included in the protection scope of the present application.

[0094] As Figure 4 shown, in one embodiment, the present invention provides a Prometheus metric management system, which includes:

[0095] A first acquisition module 401, configured to acquire a first PromQL expression corresponding to a Prometheus metric.

[0096] The second acquisition module 402 is configured to parse the first PromQL expression based on OneData and ANTLR to obtain OneData information.

[0097] The generation module 403 is configured to generate a metric name based on a preset naming specification and the OneData information.

[0098] The saving module 404 is configured to save the metric name, the OneData information, and the first PromQL expression to MySQL.

[0099] It should be noted that the structures and principles of the first acquisition module 401, the second acquisition module 402, the generation module 403, and the saving module 404 correspond one by one to the steps (steps S101 to S104) in the above Prometheus metric management method. The specific working principles can also refer to the introduction of the Prometheus metric management method in the foregoing embodiments, so details are not described herein again.

[0100] The embodiment of the present application further provides a Prometheus metric usage system. The Prometheus metric usage system can implement the Prometheus metric usage method described in the present application. However, the implementation device of the Prometheus metric usage method described in the present application includes, but is not limited to, the structure of the Prometheus metric usage system listed in this embodiment. Any structural deformation and replacement of the prior art made according to the principles of the present application are included in the protection scope of the present application.

[0101] As Figure 5 shown, in an embodiment, the present invention provides a Prometheus metric usage system. The Prometheus metric is the Prometheus metric provided by the above Prometheus metric management method. The Prometheus metric usage system includes:

[0102] The first determination module 501 is configured to determine a target Prometheus metric, a target operator, a target threshold, and a target logical operator according to actual requirements.

[0103] The configuration module 502 is configured to configure a target rule according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator.

[0104] The second determination module 503 is configured to determine a target PromQL expression corresponding to the target Prometheus metric based on a first PromQL expression.

[0105] A generation module 504, configured to generate a second PromQL expression corresponding to the target rule based on the target operator, the target threshold, the target logical operator, and the target PromQL expression.

[0106] A sending module 505, configured to send the second PromQL expression to Prometheus so that the target rule becomes effective.

[0107] It should be noted that the structures and principles of the first determination module 501, the configuration module 502, the second determination module 503, the generation module 504, and the sending module 505 correspond one by one to the steps (steps S301 to S305) in the above Prometheus metric usage method. The specific working principle can also refer to the introduction of the Prometheus metric usage method in the foregoing embodiments, and thus will not be elaborated herein.

[0108] In several embodiments provided in the present application, it should be understood that the disclosed system, apparatus, or method can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of modules / units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces, and the indirect coupling or communication connection of the apparatus or module or unit can be in an electrical, mechanical, or other form.

[0109] The modules / units described as separate components may or may not be physically separated, and the components displayed as modules / units may or may not be physical modules, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules / units can be selected according to actual needs to achieve the purpose of the embodiments of the present application. For example, in each embodiment of the present application, the various functional modules / units can be integrated in a processing module, or each module / unit can exist physically alone, or two or more modules / units can be integrated in one module / unit.

[0110] Those of ordinary skill in the art should further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0111] The descriptions of the processes or structures corresponding to the above respective drawings each have their own focuses. For parts not detailed in a certain process or structure, reference can be made to the relevant descriptions of other processes or structures.

[0112] The above embodiments are only illustrative of the principles and effects of this application and are not used to limit this application. Any person familiar with this technology can modify or change the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or changes completed by those with ordinary knowledge in the technical field without departing from the spirit and technical ideas disclosed in this application should still be covered by the claims of this application.

Claims

1. A Prometheus metric management method, characterized in that, The Prometheus metric management method includes: Obtain the first PromQL expression corresponding to the Prometheus metric; Parse the first PromQL expression based on OneData and ANTLR to obtain OneData information; Generate a metric name based on a preset naming convention and the OneData information; the preset naming convention is: [Type Tag]_Statistical Period_Atomic Metric_Statistical Method_Suffix [Dimension Tag] [Business Limitation Tag]; where The [Type Tag] is used to indicate the type of the Prometheus metric; The suffix is the unique encoding corresponding to the first PromQL expression; The [Dimension Tag] is used to indicate the dimension of the Prometheus metric; The [Business Limitation Tag] is used to indicate the business limitation of the Prometheus metric; The atomic metric is a measurement based on business event behaviors, is an indivisible metric in business definitions, and has a noun with a clear business meaning; Save the metric name, the OneData information, and the first PromQL expression to MySQL.

2. The Prometheus metric management method according to claim 1, wherein The first PromQL expression is written by the metric Owner according to the original metric.

3. A method for using Prometheus metrics, characterized in that, The Prometheus metric is a Prometheus metric managed by using the Prometheus metric management method according to any one of claims 1 to 2; the method for using the Prometheus metric includes: Determine the target Prometheus metric, the target operator, the target threshold, and the target logical operator according to the actual requirements; Configure the target rule according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator; Determine the target PromQL expression corresponding to the target Prometheus metric based on the first PromQL expression; Generate the second PromQL expression corresponding to the target rule based on the target operator, the target threshold, the target logical operator, and the target PromQL expression; Send the second PromQL expression to Prometheus to make the target rule effective.

4. The method for using Prometheus metrics according to claim 3, characterized in that, The method for using the Prometheus metric further includes: generating a rule description according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator, and saving the rule description to MySQL; and / or Save the target rule to MySQL.

5. The method for using Prometheus metrics according to claim 4, wherein The method for using the Prometheus metric further includes: when Prometheus triggers the actual requirements, send the target rule and the rule description to the recipient client.

6. A Prometheus metric management system, characterized in that, The Prometheus metric management system includes: A first acquisition module, used to obtain the first PromQL expression corresponding to the Prometheus metric; A second acquisition module, configured to parse the first PromQL expression based on OneData and ANTLR to obtain OneData information; A generation module, configured to generate a metric name based on a preset naming convention and the OneData information; the preset naming convention is: [Type Tag]_Statistical Period_Atomic Metric_Statistical Method_Suffix [Dimension Tag] [Business Limitation Tag]; where the [Type Tag] is used to indicate the type of the Prometheus metric; the suffix is the unique encoding corresponding to the first PromQL expression; the [Dimension Tag] is used to indicate the dimension of the Prometheus metric; the [Business Limitation Tag] is used to indicate the business limitation of the Prometheus metric; the atomic metric is a measurement based on business event behavior, is an indivisible metric in business definition, and has a noun with clear business meaning; A storage module, configured to store the metric name, the OneData information, and the first PromQL expression into MySQL.

7. A Prometheus metric usage system, characterized in that, The Prometheus metric is a Prometheus metric managed by using the Prometheus metric management method according to any one of claims 1 to 2; the Prometheus metric usage system includes: A first determination module, configured to determine a target Prometheus metric, a target operator, a target threshold, and a target logical operator according to actual requirements; A configuration module, configured to configure a target rule according to the target Prometheus metric, the target operator, the target threshold, and the target logical operator; A second determination module, configured to determine a target PromQL expression corresponding to the target Prometheus metric based on a first PromQL expression; A generation module, configured to generate a second PromQL expression corresponding to the target rule based on the target operator, the target threshold, the target logical operator, and the target PromQL expression; A sending module, configured to send the second PromQL expression to Prometheus to make the target rule effective.

8. An electronic device, characterized in that, The electronic device includes: a processor and a memory; the memory is used to store a computer program; the processor is used to execute the computer program stored in the memory, so that the electronic device executes the Prometheus metric management method according to any one of claims 1 to 2, and / or the Prometheus metric usage method according to any one of claims 3 to 5.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the electronic device, it implements the Prometheus metric management method according to any one of claims 1 to 2, and / or the Prometheus metric usage method according to any one of claims 3 to 5.

Citation Information

Patent Citations

  • Internet of Things equipment monitoring index dynamic management and data analysis method and device

    CN114064699A

  • Index data analysis engine, index data calculation device and calculation method

    CN117910850A