Monitoring methods and related products based on Prometheus system
By obtaining and managing the target label value and threshold of the k8s cluster in the Prometheus system, and controlling the target cardinality in the storage component, the problem of high cardinality in the Prometheus system when monitoring the k8s cluster is solved, and the system stability and Query efficiency.
Patent Information
- Application Number
- CN202311260717.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2043-09-26
AI Technical Summary
The Prometheus system is prone to high cardinality problems when monitoring k8s clusters, resulting in system instability and low index query efficiency.
By obtaining the target tag value of the target tag and the threshold in the monitoring configuration file, the target base number of the target tag in the storage component does not exceed the target threshold, and changes or discards the tag value when the threshold is reached, using a Bloom filter to determine the number of tag values, Report abnormal indicators in a timely manner.
It effectively reduces the probability of high cardinality in the Prometheus system, improves the refined management and prevention capabilities of indicators and tags, and avoids system instability and low query efficiency caused by high cardinality.
Smart Images

Figure CN117290182B
Abstract
Description
Technical Field
[0001] The present application relates to the field of cluster monitoring technology, and in particular to a monitoring method based on a Prometheus system and related products. Background Art
[0002] The Prometheus system is an open source monitoring system. The Prometheus system can monitor whether the server cluster is running normally, and can issue an alarm prompt when the server cluster runs abnormally, thereby reducing the security risks of the server cluster system. It is common to monitor the Kubernetes (k8s) cluster through the Prometheus system. However, in actual applications, the Prometheus system's monitoring of the k8s cluster is prone to high cardinality problems, which in turn leads to instability of the Prometheus system and low efficiency of querying the collected metrics. Therefore, it is of great significance to reduce the probability of high cardinality in the Prometheus system when monitoring the k8s cluster through the Prometheus system. Summary of the invention
[0003] The present application provides a monitoring method based on the Prometheus system and related products, wherein the related products include a monitoring device based on the Prometheus system, a monitoring device of a server cluster, an electronic device, and a computer-readable storage medium.
[0004] In a first aspect, a monitoring method based on a Prometheus system is provided, wherein the monitoring method is used to monitor a k8s cluster through the Prometheus system, and the method includes:
[0005] Obtaining the target label value of the target label by monitoring the k8s cluster through the Prometheus system;
[0006] Obtain a monitoring configuration file, where the monitoring configuration file includes a threshold value of a monitoring tag, where the monitoring tag is a tag of an indicator that the Prometheus system needs to monitor;
[0007] Determining a target threshold of the target tag from the thresholds of the monitoring tags;
[0008] The target tag value is stored in a storage component based on the target threshold value, such that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value.
[0009] In combination with any implementation manner of the present application, after obtaining the target label value by monitoring the k8s cluster through the Prometheus system, the method further includes:
[0010] Performing garbled code detection on the target tag value to obtain a detection result;
[0011] When the detection result shows that the target tag value has garbled characters, changing the target tag value to a first predetermined value;
[0012] Serializing the first predetermined value to obtain a first serialization result;
[0013] The first serialization result is stored in the storage component.
[0014] In combination with any implementation manner of the present application, the step of performing garbled code detection on the target tag value to obtain a detection result includes:
[0015] The detection result is obtained by performing garbled code detection on the label value of the target label in a sampling detection manner to determine whether garbled code appears in the target label value.
[0016] In combination with any embodiment of the present application, when the detection result is that there is no garbled code in the target tag value, storing the target tag value to the storage component based on the target threshold so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold includes:
[0017] Determine the number of tag values of the target tag stored in the storage component to obtain the target cardinality;
[0018] If the target cardinality does not reach the target threshold, storing the target label value in the storage component;
[0019] When the target cardinality reaches the target threshold, changing the target label value to a second predetermined value;
[0020] Serializing the second predetermined value to obtain a second serialization result;
[0021] The second serialization result is stored in the storage component.
[0022] In combination with any embodiment of the present application, the determining the number of tag values of the target tag stored in the storage component to obtain the target cardinality includes:
[0023] The number of tag values of the target tag stored in the storage component is determined based on the Bloom filter as the target cardinality.
[0024] In combination with any embodiment of the present application, the method further includes:
[0025] When the target tag value is the first predetermined value or the second predetermined value, determining that an indicator corresponding to the target tag is abnormal;
[0026] In the event that an abnormality occurs to the target tag, the metadata of the indicator corresponding to the target tag is reported to the registration service;
[0027] The registration service sends a prompt message to the observable management terminal indicating that an abnormality exists in the indicator corresponding to the target tag.
[0028] In combination with any embodiment of the present application, the monitoring tag includes a whitelist, the threshold of the monitoring tag includes a whitelist threshold of the tag in the whitelist and a non-whitelist threshold of the tag in the non-whitelist, and the whitelist threshold is greater than the non-whitelist threshold;
[0029] The step of determining a target threshold of the target tag from the threshold of the monitoring tag includes:
[0030] When the target tag is a tag in the whitelist, determining the whitelist threshold to be the target threshold;
[0031] In the case where the target tag is a tag in the non-whitelist, the target threshold is determined from the non-whitelist thresholds.
[0032] In combination with any implementation manner of the present application, when the target tag is a tag in the whitelist, after determining that the whitelist threshold is the target threshold, the method further includes:
[0033] When the target cardinality reaches the target threshold, determining at least two target indicators corresponding to the target tag;
[0034] Determine the cardinality of the target label for each of the at least two target indicators.
[0035] In combination with any embodiment of the present application, the method further includes:
[0036] When an update instruction for the monitoring configuration file is received, the monitoring configuration file is updated in a hot update manner according to the update instruction.
[0037] In a second aspect, a method for monitoring a server cluster is provided, the method comprising:
[0038] Obtain the target tag value of the target tag by monitoring the server cluster;
[0039] Obtaining a monitoring configuration file, wherein the monitoring configuration file includes a threshold value of a monitoring tag, and the monitoring tag is a tag of an indicator to be monitored in the server cluster;
[0040] Determining a target threshold of the target tag from the thresholds of the monitoring tags;
[0041] The target tag value is stored in a storage component based on the target threshold value, such that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value.
[0042] In a third aspect, a monitoring device based on the Prometheus system is provided, wherein the monitoring device is used to monitor the k8s cluster through the Prometheus system, and the device includes:
[0043] An acquisition unit, used for acquiring a target label value of a target label by monitoring the k8s cluster through the Prometheus system;
[0044] The acquisition unit is used to acquire a monitoring configuration file, where the monitoring configuration file includes a threshold value of a monitoring tag, where the monitoring tag is a tag of an indicator that the Prometheus system needs to monitor;
[0045] A determination unit, configured to determine a target threshold of the target tag from the threshold of the monitoring tag;
[0046] A storage unit is used to store the target tag value in a storage component based on the target threshold value, so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value.
[0047] In combination with any embodiment of the present application, the monitoring device further includes:
[0048] A detection unit, used to perform garbled code detection on the target tag value to obtain a detection result;
[0049] a changing unit, configured to change the target tag value to a first predetermined value when the detection result shows that the target tag value has garbled characters;
[0050] A serialization unit, used for serializing the first predetermined value to obtain a first serialization result;
[0051] A storage unit is used to store the first serialization result in the storage component.
[0052] In combination with any embodiment of the present application, the detection unit is used to perform garbled code detection on the label value of the target label by sampling detection, determine whether garbled code appears in the target label value, and obtain the detection result.
[0053] In combination with any embodiment of the present application, the storage unit is used to:
[0054] Determine the number of tag values of the target tag stored in the storage component to obtain the target cardinality;
[0055] If the target cardinality does not reach the target threshold, storing the target label value in the storage component;
[0056] When the target cardinality reaches the target threshold, changing the target label value to a second predetermined value;
[0057] Serializing the second predetermined value to obtain a second serialization result;
[0058] The second serialization result is stored in the storage component.
[0059] In combination with any implementation manner of the present application, the determining unit is used to:
[0060] The number of tag values of the target tag stored in the storage component is determined based on the Bloom filter as the target cardinality.
[0061] In combination with any embodiment of the present application, the determining unit is further configured to determine that an abnormality occurs in the indicator corresponding to the target tag when the target tag value is the first predetermined value or the second predetermined value;
[0062] The monitoring device further comprises:
[0063] A reporting unit, configured to report metadata of the indicator corresponding to the target tag to a registration service when an abnormality occurs to the target tag;
[0064] A sending unit, wherein the registration service sends a prompt message indicating that an abnormality exists in the indicator corresponding to the target tag to the observable management terminal through the sending unit.
[0065] In combination with any embodiment of the present application, the monitoring tag includes a whitelist, the threshold of the monitoring tag includes a whitelist threshold of the tag in the whitelist and a non-whitelist threshold of the tag in the non-whitelist, and the whitelist threshold is greater than the non-whitelist threshold;
[0066] The determining unit is used for:
[0067] When the target tag is a tag in the whitelist, determining the whitelist threshold to be the target threshold;
[0068] In the case where the target tag is a tag in the non-whitelist, the target threshold is determined from the non-whitelist thresholds.
[0069] In combination with any implementation manner of the present application, the determining unit is further configured to:
[0070] When the target cardinality reaches the target threshold, determining at least two target indicators corresponding to the target tag;
[0071] Determine the cardinality of the target label for each of the at least two target indicators.
[0072] In combination with any embodiment of the present application, the monitoring device further includes: an updating unit, which is used to update the monitoring configuration file in a hot update manner according to the update instruction when an update instruction for the monitoring configuration file is received.
[0073] In a fourth aspect, a monitoring device for a server cluster is provided, the device comprising:
[0074] An acquisition unit, used for acquiring a target tag value of a target tag by monitoring a server cluster;
[0075] The acquisition unit is used to acquire a monitoring configuration file, wherein the monitoring configuration file includes a threshold value of a monitoring tag, and the monitoring tag is a tag of an indicator to be monitored in the server cluster;
[0076] A determination unit, configured to determine a target threshold of the target tag from the threshold of the monitoring tag;
[0077] A storage unit is used to store the target tag value in a storage component based on the target threshold value, so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value.
[0078] In a fifth aspect, an electronic device is provided, comprising: a processor and a memory, the memory being used to store computer program code, the computer program code comprising computer instructions, and when the processor executes the computer instructions, the electronic device executes the method as in the first aspect above and any one of its possible implementation methods; when the processor executes the computer instructions, the electronic device either executes the method as in the second aspect above.
[0079] In the sixth aspect, another electronic device is provided, comprising: a processor, a sending device, an input device, an output device and a memory, wherein the memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device executes the first aspect and any implementation method thereof; when the processor executes the computer instructions, the electronic device may execute the method of the second aspect.
[0080] In the seventh aspect, a computer-readable storage medium is provided, in which a computer program is stored. The computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to execute the first aspect and any one of its implementation modes described above; when the program instructions are executed by the processor, the processor is caused to execute the method of the second aspect.
[0081] In an eighth aspect, a computer program product is provided, which includes a computer program or instructions, and when the computer program or instructions are run on a computer, the computer executes the above-mentioned first aspect and any one of its embodiments; when the computer program or instructions are run on a computer, the computer executes the method of the second aspect.
[0082] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application.
[0083] In this application, after the monitoring device obtains the target tag value of the target tag through the monitoring of the k8s cluster by the Prometheus system and obtains the monitoring configuration file, it determines the target threshold of the target tag from the monitoring tag of the monitoring configuration file. Then, based on the target threshold, the target tag value is stored in the storage component so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold, thereby reducing the probability of high cardinality in the Prometheus system.
[0084] Moreover, compared with the method of reducing the probability of high cardinality in the Prometheus system by pre-aggregating the indicators monitored by Prometheus, the technical solution provided in the embodiment of the present application can reduce the probability of high cardinality in the Prometheus system without the need to pre-aggregate the indicators, thereby improving the refined management and prevention and control of indicators and indicator labels. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.
[0086] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0087] Figure 1 A schematic diagram of the architecture of a monitoring system provided in an embodiment of the present application;
[0088] Figure 2 A flowchart of a monitoring method based on the Prometheus system provided in an embodiment of the present application;
[0089] Figure 3 A monitoring technology architecture diagram based on the Prometheus system provided in an embodiment of the present application;
[0090] Figure 4 A flowchart of another monitoring method based on the Prometheus system provided in an embodiment of the present application;
[0091] Figure 5 A flow chart of a method for monitoring a server cluster provided in an embodiment of the present application;
[0092] Figure 6 A schematic diagram of the structure of a monitoring device based on the Prometheus system provided in an embodiment of the present application;
[0093] Figure 7 A schematic diagram of the structure of a monitoring device for a server cluster provided in an embodiment of the present application;
[0094] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0095] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0096] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0097] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0098] The Prometheus system is an open source monitoring system. Through the Prometheus system, you can monitor whether the server cluster is running normally, and you can issue an alarm when the server cluster runs abnormally, thereby reducing the potential safety hazards of the server cluster system. It is common to monitor the Kubernetes cluster through the Prometheus system. However, in actual applications, the Prometheus system's monitoring of the k8s cluster is prone to high cardinality problems, which in turn leads to instability of the Prometheus system and low efficiency of the indicators collected by querying the query component. The query component is optional. vmselect. Therefore, it is of great significance to reduce the probability of high cardinality in the Prometheus system when monitoring the k8s cluster through the Prometheus system.
[0099] Based on this, the embodiment of the present application provides a monitoring method based on the Prometheus system, which is used to monitor the k8s cluster through the Prometheus system. The execution subject of the embodiment of the present application is a monitoring device based on the Prometheus system (hereinafter referred to as the monitoring device), wherein the monitoring device can be any electronic device that can execute the technical solution disclosed in the embodiment of the method of the present application. Optionally, the monitoring device can be one of the following: a computer, a server.
[0100] See also Figure 1 , Figure 1 The diagram is a schematic diagram of the architecture of a monitoring system provided by an embodiment of the present application, wherein the monitoring system 1 includes an observable management terminal 11, a monitoring device 12, and a k8s cluster 13, wherein the observable management terminal 11 can be any electronic device having a communication connection with the monitoring device 12, and the observable management terminal 11 can transmit data to the monitoring device 12 through the communication connection, for example, transmit the configuration information required for monitoring, and the observable management terminal 11 can also obtain the monitoring results of the monitoring device 12 through the communication connection, and visualize the monitoring results. Optionally, the observable management terminal is a computer. The monitoring device 12 monitors the k8s cluster 13 by running the monitoring method based on the Prometheus system provided by an embodiment of the present application.
[0101] It should be understood that the method embodiment of the present application can also be implemented by a processor executing a computer program code. The monitoring method based on the Prometheus system provided by the embodiment of the present application is described below in conjunction with the drawings in the embodiment of the present application. Figure 2 , Figure 2 It is a flow chart of a monitoring method based on the Prometheus system provided in an embodiment of the present application.
[0102] 201. Obtain the target label value of the target label through the monitoring of the above k8s cluster by the above Prometheus system.
[0103] By monitoring the k8s cluster through the Prometheus system, the indicators of the k8s cluster can be collected, and the operating status of the k8s cluster can be determined based on the indicators, where the indicators include labels and label values of labels. The high cardinality problem of the Prometheus system is usually caused by too many label values.
[0104] In the embodiment of the present application, the label of the indicator that the Prometheus system needs to monitor the k8s cluster is called a monitoring label, the target label is any one of the monitoring labels, and the target label value is the label value of the target label collected by Prometheus. For example, the target indicator is the central processing unit (CPU) utilization of server a in the k8s cluster, and the target label value is 60%.
[0105] 202. Obtain a monitoring configuration file.
[0106] In the implementation of the present application, the monitoring configuration file includes a threshold value of a monitoring tag, wherein the threshold value of the monitoring tag is the upper limit of the storage of the cardinality of the monitoring tag, that is, the upper limit of the storage of the tag value of the monitoring tag. For example, the threshold value of the monitoring tag is 1000, that is, the upper limit of the number of tag values of the stored monitoring tag is 1000. It should be understood that the tag values all have timestamps, and tag values with different timestamps are different tag values.
[0107] In an implementation of obtaining a monitoring configuration file, a monitoring device receives a monitoring configuration file input by a user through an input component, wherein the input component includes: a keyboard, a mouse, a touch screen, and a touch pad.
[0108] In another implementation of obtaining a monitoring configuration file, the monitoring device receives the monitoring configuration file sent by the terminal. Optionally, the terminal may be any one of the following: a mobile phone, a computer, a tablet computer, or a server.
[0109] 203. Determine a target threshold of the target tag from the thresholds of the monitoring tags.
[0110] In the embodiment of the present application, the target threshold is the threshold of the target label.
[0111] 204. Store the target tag value in a storage component based on the target threshold, so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold.
[0112] In the embodiment of the present application, the storage component is a component for storing the tag value of the monitoring tag, and optionally, the storage component is vmstorage. The target cardinality is the number of tag values of the target tag stored in the storage component. If the target cardinality does not exceed the target threshold, the probability of high cardinality in the Prometheus system can be reduced.
[0113] In a possible implementation, the monitoring device stores the target label value in the storage component when the target cardinality does not reach the target threshold. The monitoring device marks the target label value as a high cardinality label value and stores it in the storage component when the target cardinality has reached the target threshold. The monitoring device ensures that the target cardinality does not exceed the target threshold by marking the target label value as a high cardinality label value and storing it in the storage component instead of storing it in the storage component as the label value of the target label.
[0114] In another possible implementation, the monitoring device stores the target label value in the storage component when the target cardinality does not reach the target threshold. The monitoring device discards the target label value when the target cardinality has reached the target threshold. The monitoring device discards the target label value and does not store the target label value in the storage component, thereby ensuring that the target cardinality does not exceed the target threshold.
[0115] In another possible implementation, the monitoring device stores the target tag value in the storage component when the target cardinality does not reach the target threshold. When the target cardinality has reached the target threshold, the monitoring device stores the target tag value in the storage component and deletes the tag value with the smallest timestamp among the tag values of the target tag stored in the storage component, so that the latest tag value of the target tag can be stored in the storage component and the target cardinality can be guaranteed not to exceed the target threshold.
[0116] The monitoring device stores the target tag and the target tag value in the form of a key-value pair in the storage component. Specifically, the target tag is used as the key (key) and the target tag value is used as the value (value) and stored in the storage component, and the target tag value stored in the storage component has a timestamp.
[0117] In the embodiment of the present application, after the monitoring device obtains the target tag value of the target tag through the monitoring of the k8s cluster by the Prometheus system and obtains the monitoring configuration file, it determines the target threshold of the target tag from the monitoring tag of the monitoring configuration file. Then, based on the target threshold, the target tag value is stored in the storage component so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold, thereby reducing the probability of high cardinality in the Prometheus system.
[0118] Moreover, compared with the method of reducing the probability of high cardinality in the Prometheus system by pre-aggregating the indicators monitored by Prometheus, the technical solution provided in the embodiment of the present application can reduce the probability of high cardinality in the Prometheus system without the need to pre-aggregate the indicators, thereby improving the refined management and prevention and control of indicators and indicator labels.
[0119] As an optional implementation, after the monitoring device obtains the target label value through the Prometheus system monitoring the k8s cluster, it further performs the following steps:
[0120] 3001. Perform garbled code detection on the target label value to obtain a detection result.
[0121] In the embodiment of the present application, the monitoring device can determine whether there is garbled code in the tag value to be detected by performing garbled code detection on the target tag value. The detection result includes whether there is garbled code in the target tag value or whether there is no garbled code in the target tag value.
[0122] In one possible implementation, the monitoring device performs garbled code detection on the label value of the target label by sampling detection to determine whether the target label value has garbled code and obtain a detection result. In this implementation, the monitoring device samples the label value of the target label, and then performs garbled code detection on the sampled label value. Therefore, when the sampled label value is the target label value, the target label value is subjected to garbled code detection to obtain a detection result. In this way, the number of label values that need to be detected for garbled code can be reduced, thereby reducing the computing resources consumed by garbled code detection. Optionally, the sampling is one of the following: random sampling, uniform sampling.
[0123] 3002. When the detection result shows that the target tag value contains garbled characters, change the target tag value to a first predetermined value.
[0124] In the embodiment of the present application, the first predetermined value may be any value. By changing the target tag value to the first predetermined value, the monitoring device can truncate the target tag value, thereby reducing the number of tag values of the target tag.
[0125] 3003. Serialize the first predetermined value to obtain a first serialization result.
[0126] Optionally, the monitoring device obtains a first sequence result by reorganizing and serializing the first predetermined value.
[0127] 3004. Store the first serialization result in the storage component.
[0128] In this embodiment, after obtaining the target tag value, the monitoring device first performs a garbled code detection on the target tag value to obtain a detection result. Then, if the detection result shows that the target tag value has garbled code, the target tag value is changed to a first predetermined value, which can have the effect of truncating the target tag value, thereby reducing the number of tag values of the target tag. Finally, the first predetermined value is serialized to obtain a first serialization result, and the first serialization result is stored in the storage component, which can reduce the probability of high cardinality in the Prometheus system.
[0129] As an optional implementation, if the detection result is that there is no garbled code in the target tag value, the monitoring device performs the following steps during the execution of step 204:
[0130] 4001. Determine the number of tag values of the target tag stored in the storage component to obtain the target cardinality.
[0131] In a possible implementation, the target tag is bound to a Bloom filter. Optionally, the Bloom filter of the target tag can be generated by the user when configuring the target tag. After obtaining the target tag value, the monitoring device can determine that the tag to which the target tag value belongs is the target tag, and then determine the number of tag values of the target tag stored in the storage component based on the Bloom filter of the target tag as the target cardinality.
[0132] 4002. When the target cardinality does not reach the target threshold, the target label value is stored in the storage component.
[0133] The target cardinality does not reach the target threshold, indicating that continuing to store the tag value of the target tag in the storage component will not cause a high cardinality problem. Therefore, the monitoring device stores the target tag in the storage component when the target cardinality does not reach the target threshold.
[0134] 4003. When the target cardinality reaches the target threshold, change the target label value to a second predetermined value.
[0135] In the embodiment of the present application, the second predetermined value can be any value, and the first predetermined value and the second predetermined value can be the same or different, and the present application does not limit this. The target cardinality has reached the target threshold, indicating that the probability of generating a high cardinality problem by continuing to store the tag value of the target tag in the storage component is high. Therefore, the monitoring device changes the target tag value to the second predetermined value to truncate the target tag value, thereby reducing the number of tag values of the target tag.
[0136] 4004. Serialize the second predetermined value to obtain a second serialization result.
[0137] 4005. Store the second serialization result in the storage component.
[0138] In this embodiment, after obtaining the target tag value, the monitoring device first performs a garbled code detection on the target tag value to obtain a detection result. Then, when the detection result is that there is no garbled code in the target tag value, it is further determined whether to truncate the target tag value based on whether the target cardinality reaches the target threshold. Specifically, when the target cardinality does not reach the target threshold, the target tag value is stored in the storage component, and when the target cardinality reaches the target threshold, the target tag value is changed to a second predetermined value, thereby achieving the effect of truncating the target tag value, thereby reducing the number of tag values of the target tag, and then serializing the second predetermined value to obtain a second serialization result, and storing the second serialization result in the storage component, which can reduce the probability of high cardinality in the Prometheus system.
[0139] As an optional implementation, the monitoring device further performs the following steps:
[0140] 5001. When the target tag value is the first predetermined value or the second predetermined value, determine that an indicator corresponding to the target tag is abnormal.
[0141] If the target tag value is the first predetermined value, it means that there are garbled characters in the target tag value, that is, the target tag has a garbled tag value. If the target tag value is the second predetermined value, it means that the number of tag values of the target tag stored in the storage component has reached the storage limit. Continuing to store the tag value of the target tag in the storage component may cause a high cardinality problem in the Prometheus system. Therefore, when the target tag value is the first predetermined value or the second predetermined value, the monitoring device determines that the indicator corresponding to the target tag is abnormal.
[0142] 5002. In the event that an abnormality occurs to the target tag, the metadata of the indicator corresponding to the target tag is reported to the registration service.
[0143] In the embodiment of the present application, the registration service is a service run by the monitoring device. The monitoring device reports the metadata of the indicator corresponding to the target tag to the registration service, so that the registration service can locate the abnormal indicator.
[0144] 5003. The registration service sends a prompt message to the observable management terminal indicating that an abnormality exists in the indicator corresponding to the target tag.
[0145] In the embodiment of the present application, the observable management end may be any electronic device that has a communication connection with the monitoring device, and optionally, the observable management end is a computer. The registration service sends a prompt message indicating that the target tag is abnormal to the observable management end, so that the observable management end can visualize the prompt message to enable the user to observe the prompt message of the abnormal storage of the indicator corresponding to the target tag.
[0146] In this embodiment, when the target tag value is the first predetermined value or the second predetermined value, the monitoring device determines that the target tag is abnormal, and when the target tag is abnormal, the metadata of the indicator corresponding to the target tag is reported to the registration service. The registration service sends a prompt message to the observable management end indicating that the indicator corresponding to the target tag is abnormal, so that the observable management end outputs the prompt message to inform the user that the indicator corresponding to the target tag is abnormal, and then the abnormal situation can be handled in time, thereby reducing safety hazards.
[0147] As an optional implementation, the monitoring tags include a whitelist and a non-whitelist, the threshold of the tags in the whitelist is called the whitelist threshold, and the tags in the non-whitelist are called the non-whitelist threshold. The threshold of the monitoring tags includes the whitelist threshold and the non-whitelist threshold. Optionally, the tags in the whitelist are tags related to the inherent properties of the k8s cluster system, the non-whitelist tags are tags related to the business, and the whitelist threshold is greater than the non-whitelist threshold.
[0148] In this embodiment, the monitoring device determines the target threshold from the threshold of the monitoring tag by executing the following steps: when the target tag is a tag in the whitelist, the whitelist threshold is determined as the target threshold. When the target tag is a tag in the non-whitelist, the threshold of the target tag (i.e., the target threshold) is determined from the non-whitelist threshold.
[0149] In the embodiment of the present application, the thresholds of the labels in the whitelist are all the same, that is, the labels in the whitelist are all whitelist thresholds. The labels in the non-whitelist all have corresponding thresholds. For example, the whitelist includes labels a and labels b, and the non-whitelist includes labels c and labels d. Then the threshold of label a and the threshold of label b are both whitelist thresholds, and the threshold of label c may be different from the threshold of label d. Therefore, when the target label is a label in the whitelist, the monitoring device determines the whitelist threshold as the target threshold, and when the target label is a label in the non-whitelist, the target threshold is further determined from the non-whitelist threshold.
[0150] In this embodiment, the monitoring tags include a whitelist and a non-whitelist. The thresholds of the tags in the whitelist are all whitelist thresholds, and the thresholds of the tags in the non-whitelist need to be set separately. Therefore, when the target tag is a tag in the whitelist, the monitoring device determines the whitelist threshold as the target threshold; when the target tag is a tag in the non-whitelist, the monitoring device determines the target threshold from the non-whitelist threshold.
[0151] Moreover, the whitelist threshold is larger than the non-whitelist threshold, that is, the whitelist threshold is larger than the threshold of any tag in the non-whitelist. In this way, tags that require high cardinality can be added to the whitelist, and tags related to the business can be added to the non-whitelist, which does not affect the monitoring of tags that require high cardinality, and can achieve targeted management of tags related to the business through the differentiation of the thresholds of tags related to the business, thereby reducing the probability that tags related to the business may cause high cardinality.
[0152] As an optional implementation, when the target tag is a tag in the whitelist, after determining that the whitelist threshold is the target threshold, the monitoring device further performs the following steps: 6001. When the above-mentioned target base reaches the above-mentioned target threshold, determine at least two target indicators corresponding to the above-mentioned target tag.
[0153] For the k8s cluster, different indicators may have the same label, for example, both indicator a and indicator b have the CPU utilization indicator. Therefore, if the indicator with the target label is called the target indicator, the number of target indicators may exceed 1. When the target cardinality reaches the target threshold, the target label value of the target label is obtained through the Prometheus system, indicating that the number of target labels obtained through the monitoring of the Prometheus system has exceeded the target threshold (that is, the sum of the target cardinality and the number of target label values has exceeded the target threshold), so the probability of the target label having a high cardinality problem is high. In the case where the target indicator exceeds 1, if the target label has a high cardinality problem, it will be impossible to determine which target indicator has a high cardinality, where the cardinality of the target indicator is the number of label values of the target label of the target indicator. Therefore, when the target cardinality reaches the target threshold, the monitoring device first determines at least two target indicators corresponding to the target label, so that the cardinality of the target label of each target indicator can be determined separately later.
[0154] 6002. Determine the cardinality of the target label of each of the at least two target indicators.
[0155] The monitoring device determines the cardinality of the target label of each indicator of at least two target indicators respectively, and can further determine the cardinality of each target indicator, which is conducive to reducing the cardinality of the target label in a targeted manner.
[0156] In the embodiment of the present application, the thresholds of the labels in the whitelist are all whitelist thresholds. Therefore, when the number of target indicators with target labels is greater than 1, and the number of target labels obtained through the monitoring of the Prometheus system has exceeded the target threshold, it is impossible to determine which specific target indicator has too many label values of the target label, resulting in the number of target labels obtained exceeding the target threshold. Therefore, when the target cardinality reaches the target threshold, the monitoring device determines at least two target indicators corresponding to the target label, and then determines the cardinality of the target label of each indicator in the at least two target indicators, which is conducive to further reducing the cardinality of the target label in a targeted manner.
[0157] As an optional implementation, the monitoring device further performs the following steps: upon receiving an update instruction for the monitoring configuration file, the monitoring configuration file is updated in a hot update manner according to the update instruction. In this implementation, the monitoring device updates the monitoring configuration file in a hot update manner, which can achieve the effect of updating the configuration file in real time, and can complete the update of the configuration file without affecting the normal operation of the monitoring of the Prometheus system.
[0158] In one possible implementation, there is a communication connection between the monitoring device and the observable management end. When the monitoring device receives an instruction to update the configuration file, the observable management end displays a page for updating the configuration file, so that the user can then input the content to be updated through the page. The observable management end generates an update instruction based on the content to be updated input by the user, and sends the update instruction to the monitoring device, so that the monitoring device updates the monitoring configuration file based on the update instruction.
[0159] See also Figure 3 , Figure 3 The following is a diagram of a monitoring technology architecture based on the Prometheus system provided in an embodiment of the present application. Figure 3 As shown in the figure, the technical architecture includes monitoring targets (Prometheus-targets), Prometheus services, indicator storage and forwarding agents (vmproxy), registration services (Registry), observable management terminals, insertion components, and storage components.
[0160] The Prometheus service obtains the label value of the monitoring label by monitoring the monitoring target of the Prometheus system, wherein the Prometheus service can run the Prometheus system. After obtaining the label value of the monitoring label through the Prometheus service, the label value of the monitoring label is transmitted to the indicator storage and forwarding agent, wherein the indicator storage and forwarding agent includes the following processing: label high cardinality detection, garbled code detection, statistical information reporting, blacklist and whitelist, and request forwarding.
[0161] Specifically, the high cardinality detection of a tag refers to detecting whether the monitoring tag has a high cardinality problem. The implementation of this process can refer to the process of high cardinality detection of the target tag in the previous step 4001 to step 4005. In steps 4001 to 4005, if the target cardinality does not reach the target threshold, it means that the target tag does not have a high cardinality, and then the target tag value can be stored in the storage component. Correspondingly, when it is determined that the monitoring tag does not have a high cardinality through the high cardinality detection of the tag, the tag value of the acquired monitoring tag can be stored in the storage component through the insertion component. If the target cardinality reaches the target threshold, it means that the target tag does not have a high cardinality, and then the target tag value is changed to a second predetermined value, and the second predetermined value is serialized to obtain a second serialization result, and finally the second serialization result is stored in the storage component. Correspondingly, when it is determined that the monitoring tag has a high cardinality through the high cardinality detection of the tag, the tag value of the acquired monitoring tag can be changed to a second predetermined value, and the second predetermined value is serialized to obtain a second serialization result, and finally the second serialization result is stored in the storage component. Optionally, the insertion component is vminsert and the storage component is vmstorage.
[0162] Garbled code detection refers to detecting whether the tag value of the acquired monitoring tag contains garbled codes. The implementation of this process can refer to the process of performing garbled code detection on the target tag value in the previous steps 3001 to 3004. In steps 3001 to 3004, if the detection result is that the target tag value contains garbled codes, the target tag value is changed to a first predetermined value, and then the first predetermined value is serialized to obtain a first serialization result, and the first serialization result is stored in the storage component. Correspondingly, if it is determined that the tag value contains garbled codes by performing garbled code detection on the tag value of the acquired monitoring indicator, the tag value of the acquired monitoring indicator can be changed to a first predetermined value, and then the first predetermined value is serialized to obtain a first serialization result, and the first serialization result is stored in the storage component.
[0163] Statistical information reporting refers to reporting at least one of the following information to the registration service: monitoring indicators with high cardinality and monitoring indicators corresponding to garbled label values. In this way, the registration service can visualize the reported information through the observable management terminal.
[0164] Black and white lists refer to the processing of white lists and non-white lists mentioned above. Specifically, the monitoring tags include white lists and non-white lists, the white list threshold of the tags in the white list is greater than the non-white list threshold of the tags in the non-white list, and the tag isolation achieved by steps 6001 and 6002, that is, when a tag with a high cardinality is a tag in the white list, the cardinality of the tags of each indicator can be determined separately. According to the real-time traffic, the cardinality of the target tag is controlled not to exceed the target threshold, thereby reducing the probability of high cardinality.
[0165] Request forwarding refers to forwarding data that needs to be stored in the storage component to the plug-in component to request the plug-in component to store the data in the storage component.
[0166] based on Figure 3 The technical architecture shown in the figure, the embodiment of the present application also provides another monitoring method based on the Prometheus system. Figure 4 , Figure 4 FIG. 2 is a flow chart of another monitoring method based on the Prometheus system provided in an embodiment of the present application. Figure 4 As shown, users apply for indicators and tags through the registration service, and the registration service then sends the indicators and tags applied by users (i.e. Figure 4 The user-applied indicator + label in the heartbeat packet is sent to the indicator-level label detection module through the heartbeat packet, so that the indicators and labels applied by the user are dynamically added to the indicator-level label detection module. It should be understood that the label applied by the user belongs to the label in the non-whitelist mentioned above. Therefore, when applying for a label, the user can set the threshold of the label, and the registration service will also dynamically add the threshold to the indicator-level label detection module through the heartbeat packet, so that the indicator-level label detection module can perform indicator-level label detection.
[0167] like Figure 4 As shown in the figure, for the label value of the monitoring label obtained through the Prometheus system, the global label detection module will first be used to detect whether the monitoring label is a global label, and the label value of the monitoring label will be garbled through sampling. Among them, the global label is the label in the above whitelist. Figure 4 As shown, for a label value determined to have garbled characters through garbled character detection, the indicator corresponding to the label value is determined to be a sampling hit indicator, and the sampling hit indicator is counted through garbled character statistics, and metadata of the sampling hit indicator is counted.
[0168] Each tag in the global tag detection module has a Bloom filter, such as Figure 4 As shown, label 1, label 2, ..., label N all have Bloom filters. Based on the label Bloom filters, it can be determined whether the label is a global label. For global labels, the label high cardinality detection will be further performed on the label to determine whether the global label has a high cardinality. For global labels with high cardinality (i.e. Figure 4 For tags that are not in the whitelist through global tag detection, the tag can be dynamically added to the indicator-level tag detection module, such as Figure 4 As shown, indicator X+label X and Bloom filter are dynamically added to the indicator level label detection module.
[0169] The indicator-level label detection module performs indicator-level detection by using the label threshold to detect whether the label has a cardinality exceeding the limit. Specifically, for labels that are not in the whitelist, each label has a threshold, so the indicator-level label detection module can use the label threshold to detect whether the label has a cardinality exceeding the limit. For global labels with labels exceeding the limit, the indicator-level detection module can determine all indicators corresponding to the global label, and then determine the cardinality of each indicator (the implementation of this process can be seen in steps 6001 and 6002), and finally, the threshold of each indicator can be used to detect whether the cardinality of each indicator exceeds the limit.
[0170] like Figure 4 As shown, for labels whose cardinality does not exceed the limit (i.e., the cardinality is normal), the label value is stored in the storage component by forwarding a serialization request for the label value, wherein the serialization request forwarding includes first serializing and then requesting to insert the component to store it in the storage component. For labels whose cardinality exceeds the limit, high cardinality restriction, garbled code discarding, and label truncation are performed. Specifically, high cardinality restriction refers to changing the label value exceeding the threshold to a second predetermined value, garbled code discarding, and label truncation refer to changing the label value to a first predetermined value. For indicators corresponding to labels whose label values are the first predetermined value or the second predetermined value, statistical information will be detected to count the indicators with high cardinality and the metadata of these indicators. At the same time, for label values whose values are the first predetermined value or the second predetermined value (i.e., data reorganization), the label value is stored in the storage component by forwarding a serialization request for the label value.
[0171] See also Figure 5 , Figure 5 It is a flow chart of a server cluster monitoring method provided in an embodiment of the present application.
[0172] 501. Obtain a target tag value of a target tag by monitoring the server cluster.
[0173] In the embodiment of the present application, the server cluster includes multiple servers, and the server cluster can be any server cluster, for example, the server cluster can be a microservice cluster, and the server cluster can also be a distributed cluster. By monitoring the server cluster, the index of the server cluster can be collected, and then the operating status of the server cluster can be determined based on the index, wherein the index includes a tag and a tag value of the tag.
[0174] In the embodiment of the present application, the label of the indicator that needs to be monitored for the server cluster is called a monitoring label, the target label is any one of the monitoring labels, and the target label value is the label value of the target label collected from the server cluster. For example, the target indicator is the CPU utilization of server a in the k8s cluster, and the target label value is 60%.
[0175] 502. Obtain monitoring configuration file.
[0176] In the implementation of the present application, the monitoring configuration file includes a threshold value of a monitoring tag, wherein the threshold value of the monitoring tag is the upper limit of the storage of the cardinality of the monitoring tag, that is, the upper limit of the storage of the tag value of the monitoring tag. For example, the threshold value of the monitoring tag is 1000, that is, the upper limit of the number of tag values of the stored monitoring tag is 1000. It should be understood that the tag values all have timestamps, and tag values with different timestamps are different tag values.
[0177] In one implementation of obtaining a monitoring configuration file, the monitoring device receives the monitoring configuration file input by a user through an input component. In another implementation of obtaining a monitoring configuration file, the monitoring device receives the monitoring configuration file sent by a terminal.
[0178] 503. Determine a target threshold of the target tag from the thresholds of the monitoring tags.
[0179] 504. Store the target tag value in a storage component based on the target threshold, so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold.
[0180] In the embodiment of the present application, the storage component is a component for storing the tag value of the monitoring tag, and optionally, the storage component is vmstorage. The target cardinality is the number of tag values of the target tag stored in the storage component. If the target cardinality does not exceed the target threshold, the probability of a high cardinality can be reduced.
[0181] In a possible implementation, the monitoring device stores the target label value in the storage component when the target cardinality does not reach the target threshold. The monitoring device marks the target label value as a high cardinality label value and stores it in the storage component when the target cardinality has reached the target threshold. The monitoring device ensures that the target cardinality does not exceed the target threshold by marking the target label value as a high cardinality label value and storing it in the storage component instead of storing it in the storage component as the label value of the target label.
[0182] In another possible implementation, the monitoring device stores the target label value in the storage component when the target cardinality does not reach the target threshold. The monitoring device discards the target label value when the target cardinality has reached the target threshold. The monitoring device discards the target label value and does not store the target label value in the storage component, thereby ensuring that the target cardinality does not exceed the target threshold.
[0183] In another possible implementation, the monitoring device stores the target tag value in the storage component when the target cardinality does not reach the target threshold. When the target cardinality has reached the target threshold, the monitoring device stores the target tag value in the storage component and deletes the tag value with the smallest timestamp among the tag values of the target tag stored in the storage component, so that the latest tag value of the target tag can be stored in the storage component and the target cardinality can be guaranteed not to exceed the target threshold.
[0184] The monitoring device stores the target tag and the target tag value in the form of a key-value pair to the storage component. Specifically, the target tag is used as the key and the target tag value is used as the value to store in the storage component, and the target tag value stored in the storage component has a timestamp.
[0185] In the embodiment of the present application, after the monitoring device obtains the target tag value of the target tag by monitoring the server cluster and obtains the monitoring configuration file, it determines the target threshold of the target tag from the monitoring tag of the monitoring configuration file. Then, based on the target threshold, the target tag value is stored in the storage component so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold, thereby reducing the probability of a high cardinality in the process of monitoring the server cluster.
[0186] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0187] The method of the embodiment of the present application is described in detail above, and the device of the embodiment of the present application is provided below.
[0188] See also Figure 6 , Figure 6 A structural schematic diagram of a monitoring device based on a Prometheus system provided in an embodiment of the present application, wherein the monitoring device 2 based on the Prometheus system is used to monitor the k8s cluster through the Prometheus system, and the monitoring device 2 based on the Prometheus system includes: an acquisition unit 21, a determination unit 22, and a storage unit 23. Optionally, the monitoring device 2 based on the Prometheus system also includes: a detection unit 24, a change unit 25, a serialization unit 26, a reporting unit 27, a sending unit 28, and an update unit 29. Specifically:
[0189] An acquisition unit 21 is used to acquire a target label value of a target label by monitoring the k8s cluster through the Prometheus system;
[0190] The acquisition unit 21 is used to acquire a monitoring configuration file, wherein the monitoring configuration file includes a threshold value of a monitoring tag, and the monitoring tag is a tag of an indicator that the Prometheus system needs to monitor;
[0191] A determination unit 22, configured to determine a target threshold of the target tag from the threshold of the monitoring tag;
[0192] The storage unit 23 is used to store the target tag value in a storage component based on the target threshold value, so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value.
[0193] In combination with any embodiment of the present application, the monitoring device 2 based on the Prometheus system further includes:
[0194] A detection unit 24, configured to perform garbled code detection on the target tag value to obtain a detection result;
[0195] A changing unit 25, configured to change the target tag value to a first predetermined value when the detection result shows that the target tag value has garbled characters;
[0196] A serialization unit 26, configured to serialize the first predetermined value to obtain a first serialization result;
[0197] The storage unit 23 is used to store the first serialization result in the storage component.
[0198] In combination with any embodiment of the present application, the detection unit 24 is used to perform garbled code detection on the tag value of the target tag by sampling detection to determine whether garbled code appears in the target tag value to obtain the detection result.
[0199] In combination with any embodiment of the present application, the storage unit 23 is used to:
[0200] Determine the number of tag values of the target tag stored in the storage component to obtain the target cardinality;
[0201] If the target cardinality does not reach the target threshold, storing the target label value in the storage component;
[0202] When the target cardinality reaches the target threshold, changing the target label value to a second predetermined value;
[0203] Serializing the second predetermined value to obtain a second serialization result;
[0204] The second serialization result is stored in the storage component.
[0205] In combination with any implementation manner of the present application, the determining unit 22 is used to:
[0206] The number of tag values of the target tag stored in the storage component is determined based on the Bloom filter as the target cardinality.
[0207] In combination with any embodiment of the present application, the determining unit 22 is further configured to determine that an abnormality occurs in the indicator corresponding to the target tag when the target tag value is the first predetermined value or the second predetermined value;
[0208] The monitoring device 2 based on the Prometheus system further includes:
[0209] A reporting unit 27 is used to report metadata of the indicator corresponding to the target tag to the registration service when an abnormality occurs to the target tag;
[0210] The sending unit 28, the registration service sends a prompt message indicating that an abnormality exists in the indicator corresponding to the target tag to the observable management terminal through the sending unit 28.
[0211] In combination with any embodiment of the present application, the monitoring tag includes a whitelist, the threshold of the monitoring tag includes a whitelist threshold of the tag in the whitelist and a non-whitelist threshold of the tag in the non-whitelist, and the whitelist threshold is greater than the non-whitelist threshold;
[0212] The determining unit 22 is used to:
[0213] When the target tag is a tag in the whitelist, determining the whitelist threshold to be the target threshold;
[0214] In the case where the target tag is a tag in the non-whitelist, the target threshold is determined from the non-whitelist thresholds.
[0215] In combination with any implementation manner of the present application, the determining unit 22 is further configured to:
[0216] When the target cardinality reaches the target threshold, determining at least two target indicators corresponding to the target tag;
[0217] Determine the cardinality of the target label for each of the at least two target indicators.
[0218] In combination with any embodiment of the present application, the monitoring device 2 based on the Prometheus system further includes: an updating unit 29, which is used to update the monitoring configuration file in a hot update manner according to the update instruction when an update instruction for the monitoring configuration file is received.
[0219] In the embodiment of the present application, after the monitoring device obtains the target tag value of the target tag through the monitoring of the k8s cluster by the Prometheus system and obtains the monitoring configuration file, it determines the target threshold of the target tag from the monitoring tag of the monitoring configuration file. Then, based on the target threshold, the target tag value is stored in the storage component so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold, thereby reducing the probability of high cardinality in the Prometheus system.
[0220] Moreover, compared with the method of reducing the probability of high cardinality in the Prometheus system by pre-aggregating the indicators monitored by Prometheus, the technical solution provided in the embodiment of the present application can reduce the probability of high cardinality in the Prometheus system without the need to pre-aggregate the indicators, thereby improving the refined management and prevention and control of indicators and indicator labels.
[0221] See also Figure 7 , Figure 7 A schematic diagram of the structure of a monitoring device for a server cluster provided in an embodiment of the present application. The monitoring device 3 for the server cluster includes: an acquisition unit 31, a determination unit 32, and a storage unit 33. Specifically:
[0222] An acquisition unit 31 is used to acquire a target tag value of a target tag by monitoring a server cluster;
[0223] The acquisition unit 31 is used to acquire a monitoring configuration file, wherein the monitoring configuration file includes a threshold value of a monitoring tag, and the monitoring tag is a tag of an indicator to be monitored in the server cluster;
[0224] A determination unit 32, configured to determine a target threshold of the target tag from the threshold of the monitoring tag;
[0225] The storage unit 33 is used to store the target tag value in a storage component based on the target threshold value, so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value.
[0226] In the embodiment of the present application, after the monitoring device obtains the target tag value of the target tag by monitoring the server cluster and obtains the monitoring configuration file, it determines the target threshold of the target tag from the monitoring tag of the monitoring configuration file. Then, based on the target threshold, the target tag value is stored in the storage component so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold, thereby reducing the probability of a high cardinality in the process of monitoring the server cluster.
[0227] In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.
[0228] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device 4 includes a processor 41 and a memory 42. Optionally, the electronic device 4 also includes an input device 43 and an output device 44. The processor 41, the memory 42, the input device 43 and the output device 44 are coupled via a connector, and the connector includes various interfaces, transmission lines or buses, etc., which are not limited in the embodiments of the present application. It should be understood that in each embodiment of the present application, coupling refers to mutual connection in a specific manner, including direct connection or indirect connection through other devices, for example, it can be connected through various interfaces, transmission lines, buses, etc.
[0229] The processor 41 may include one or more processors, for example, one or more central processing units (CPUs). When the processor is a CPU, the CPU may be a single-core CPU or a multi-core CPU. Optionally, the processor 41 may be a processor group consisting of multiple CPUs, and the multiple processors are coupled to each other through one or more buses. Optionally, the processor may also be other types of processors, etc., which are not limited in the embodiments of the present application.
[0230] The memory 42 can be used to store computer program instructions and various computer program codes including the program code for executing the program code of the present application. Optionally, the memory includes but is not limited to random access memory (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM), or portable read only memory (CD-ROM), which is used for related instructions and data.
[0231] The input device 43 is used to input data and / or signals, and the output device 44 is used to output data and / or signals. The input device 43 and the output device 44 can be independent devices or an integrated device.
[0232] It can be understood that in the embodiment of the present application, the memory 42 can be used not only to store relevant instructions, but also to store relevant data. The embodiment of the present application does not limit the specific data stored in the memory.
[0233] Understandably, Figure 8 Only a simplified design of an electronic device is shown. In practical applications, the electronic device may also include other necessary components, including but not limited to any number of input / output devices, processors, memories, etc., and all electronic devices that can implement the embodiments of the present application are within the protection scope of the present application.
[0234] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0235] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. Those skilled in the art can also clearly understand that the descriptions of the various embodiments of the present application have different focuses. For the convenience and brevity of description, the same or similar parts may not be repeated in different embodiments. Therefore, for parts not described or not described in detail in a certain embodiment, refer to the records of other embodiments.
[0236] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0237] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0238] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0239] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0240] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
Claims
1. A monitoring method based on the Prometheus system, It is characterized in that The monitoring method is used to monitor the k8s cluster through the Prometheus system, and the method includes: Obtaining the target label value of the target label by monitoring the k8s cluster through the Prometheus system; Obtain a monitoring configuration file, where the monitoring configuration file includes a threshold value of a monitoring tag, where the monitoring tag is a tag of an indicator that the Prometheus system needs to monitor; Determining a target threshold of the target tag from the thresholds of the monitoring tags; storing the target tag value to a storage component based on the target threshold value so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value; Performing garbled code detection on the target tag value to obtain a detection result; When the detection result shows that the target tag value has garbled characters, changing the target tag value to a first predetermined value; Serializing the first predetermined value to obtain a first serialization result; The first serialization result is stored in the storage component.
2. The method according to claim 1, It is characterized in that The performing garbled code detection on the target tag value to obtain a detection result includes: The detection result is obtained by performing garbled code detection on the label value of the target label in a sampling detection manner to determine whether garbled code appears in the target label value.
3. The method according to claim 1 or 2, It is characterized in that When the detection result is that there is no garbled code in the target tag value, storing the target tag value in a storage component based on the target threshold so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold includes: Determine the number of tag values of the target tag stored in the storage component to obtain the target cardinality; If the target cardinality does not reach the target threshold, storing the target label value in the storage component; When the target cardinality reaches the target threshold, changing the target label value to a second predetermined value; Serializing the second predetermined value to obtain a second serialization result; The second serialization result is stored in the storage component.
4. The method according to claim 3, It is characterized in that The determining the number of tag values of the target tag stored in the storage component to obtain the target cardinality includes: The number of tag values of the target tag stored in the storage component is determined based on the Bloom filter as the target cardinality.
5. The method according to claim 3, It is characterized in that The method further comprises: When the target tag value is the first predetermined value or the second predetermined value, determining that an indicator corresponding to the target tag is abnormal; In the event that an abnormality occurs to the target tag, the metadata of the indicator corresponding to the target tag is reported to the registration service; The registration service sends a prompt message to the observable management terminal indicating that an abnormality exists in the indicator corresponding to the target tag.
6. The method according to claim 1 or 2, It is characterized in that The monitoring tag includes a whitelist, and the threshold of the monitoring tag includes a whitelist threshold of the tag in the whitelist and a non-whitelist threshold of the tag in the non-whitelist, and the whitelist threshold is greater than the non-whitelist threshold; The step of determining a target threshold of the target tag from the threshold of the monitoring tag includes: When the target tag is a tag in the whitelist, determining the whitelist threshold to be the target threshold; In the case where the target tag is a tag in the non-whitelist, the target threshold is determined from the non-whitelist thresholds.
7. The method according to claim 6, It is characterized in that In the case where the target tag is a tag in the whitelist, after determining that the whitelist threshold is the target threshold, the method further includes: When the target cardinality reaches the target threshold, determining at least two target indicators corresponding to the target tag; Determine the cardinality of the target label for each of the at least two target indicators.
8. The method according to claim 1 or 2, It is characterized in that The method further comprises: When an update instruction for the monitoring configuration file is received, the monitoring configuration file is updated in a hot update manner according to the update instruction.
9. A monitoring method for a server cluster, It is characterized in that The method comprises: Obtain the target tag value of the target tag by monitoring the server cluster; Obtaining a monitoring configuration file, wherein the monitoring configuration file includes a threshold value of a monitoring tag, and the monitoring tag is a tag of an indicator to be monitored in the server cluster; Determining a target threshold of the target tag from the thresholds of the monitoring tags; storing the target tag value to a storage component based on the target threshold value so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value; Performing garbled code detection on the target tag value to obtain a detection result; When the detection result shows that the target tag value has garbled characters, changing the target tag value to a first predetermined value; Serializing the first predetermined value to obtain a first serialization result; The first serialization result is stored in the storage component.
10. A monitoring device based on the Prometheus system, It is characterized in that The monitoring device is used to monitor the k8s cluster through the Prometheus system, and the device includes: An acquisition unit, used for acquiring a target label value of a target label by monitoring the k8s cluster through the Prometheus system; The acquisition unit is used to acquire a monitoring configuration file, where the monitoring configuration file includes a threshold value of a monitoring tag, where the monitoring tag is a tag of an indicator that the Prometheus system needs to monitor; A determination unit, configured to determine a target threshold of the target tag from the threshold of the monitoring tag; A storage unit, configured to store the target tag value in a storage component based on the target threshold value, so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value; A detection unit, used to perform garbled code detection on the target tag value to obtain a detection result; a changing unit, configured to change the target tag value to a first predetermined value when the detection result shows that the target tag value has garbled characters; A serialization unit, used for serializing the first predetermined value to obtain a first serialization result; A storage unit is used to store the first serialization result in the storage component.
11. A monitoring device for a server cluster, It is characterized in that The device comprises: An acquisition unit, used for acquiring a target tag value of a target tag by monitoring a server cluster; The acquisition unit is used to acquire a monitoring configuration file, wherein the monitoring configuration file includes a threshold value of a monitoring tag, and the monitoring tag is a tag of an indicator to be monitored in the server cluster; A determination unit, configured to determine a target threshold of the target tag from the threshold of the monitoring tag; A storage unit, configured to store the target tag value in a storage component based on the target threshold value, so that the target cardinality of the target tag stored in the storage component does not exceed the target threshold value; A detection unit, used to perform garbled code detection on the target tag value to obtain a detection result; a changing unit, configured to change the target tag value to a first predetermined value when the detection result shows that the target tag value has garbled characters; A serialization unit, used for serializing the first predetermined value to obtain a first serialization result; A storage unit is used to store the first serialization result in the storage component.
12. An electronic device, It is characterized in that include: A processor and a memory, the memory being used to store computer program codes, the computer program codes comprising computer instructions, and when the processor executes the computer instructions, the electronic device executes the method according to any one of claims 1 to 8; Or when the processor executes the computer instructions, the electronic device performs the method as claimed in claim 9.
13. A computer-readable storage medium, It is characterized in that The computer readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 8; Or when the program instructions are executed by a processor, the processor is caused to execute the method according to claim 9.
