Method for realizing Prometheus automatic monitoring in micro-service scene

Through the system parameter configuration and automatic update mechanism, the Nacos Registration Center and Prometheus API are used to realize the automated configuration and dynamic update of Prometheus monitoring, solving the cumbersome and inflexible problems of manual configuration, improving monitoring efficiency and accuracy, and adapting to micro Dynamic changes in service scenarios.

CN119127620APending Publication Date: 2024-12-13BEIYIN FINANCIAL TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411372002.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

In the microservice scenario, manually configuring Prometheus monitoring has high maintenance costs, high error risks, and lack of flexibility. Especially in the Kubernetes environment, the automatic discovery mechanism has high cost of entry, difficult debugging and strong dependency, making it difficult to adapt to dynamically changing resources. Especially in the Kubernetes environment, the automatic discovery mechanism has high cost of entry, difficult debugging and strong dependency, making it difficult to adapt to dynamically changing resources. .

Method used

Through system parameter configuration, relevant configurations are loaded and monitoring lists are automatically updated. The Nacos registration center is used to realize automatic discovery and dynamic configuration updates of microservices, combined with Prometheus' overloaded API and Targets interface, to realize automated monitoring configuration and exception detection.

Benefits of technology

Reduces manual intervention, improves the efficiency and accuracy of monitoring configuration, ensures high availability and performance of the system, adapts to dynamically changing environments, and reduces maintenance costs and error risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119127620A_ABST
    Figure CN119127620A_ABST
Patent Text Reader

Abstract

The invention discloses a method for realizing Prometheus automatic monitoring in a micro-service scene. The automatic monitoring method comprises the following steps: configuring system parameters; related configuration is loaded, and monitoring is completed; and automatically updating the service state to update the monitoring list. Tediousness of manual configuration is avoided, and efficiency and accuracy of configuration monitoring are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing and container technologies, and in particular to a method for implementing Prometheus automatic monitoring in a microservice scenario. Background Art

[0002] With the development of cloud computing and container technology, microservice architecture has become the mainstream model of modern software development. Microservice architecture splits complex applications into multiple small, independent service units that can be independently developed, deployed, and expanded. However, this distributed nature also brings challenges to system monitoring, because it is necessary to continuously monitor the performance and health of many distributed services.

[0003] Prometheus is an open source system monitoring and alerting toolkit that is widely used to record real-time time series data. It grabs metrics from monitored components via the HTTP protocol and stores these data for subsequent queries and graphical presentations. Prometheus is particularly suitable for monitoring systems that store large amounts of time series data, such as monitoring in microservice architectures.

[0004] Although Prometheus provides powerful monitoring capabilities, manually configuring monitoring for each service is still a time-consuming and error-prone task in a microservice environment. As the number of services increases, manual management of monitoring targets and configurations becomes unscalable and difficult to adapt to the rapidly changing production environment.

[0005] Therefore, a Prometheus automatic monitoring method is implemented in the microservice scenario to reduce manual intervention, improve monitoring efficiency and accuracy, and ensure high availability and performance of the system. This method should be able to automatically discover new services, update monitoring configurations, and seamlessly integrate into the existing Prometheus monitoring system.

[0006] Manually configuring Prometheus is a common strategy, but it has its drawbacks:

[0007] 1. High maintenance cost: Manual configuration requires detailed settings and adjustments for each monitoring target. When the monitoring target changes, the configuration file needs to be manually updated, which increases the workload and complexity of maintenance.

[0008] 2. Risk of error: Manual configuration is prone to errors, especially in large-scale monitoring systems. Incorrect configuration may lead to inaccurate or lost monitoring data, thus affecting the accuracy and reliability of monitoring.

[0009] 3. Lack of flexibility: Manual configuration is usually only applicable to static environments and cannot adapt to dynamically changing resources. For example, in a Kubernetes environment, since Pods and services can be created, deleted, and updated frequently, manual configuration may not be able to adapt to these changes in a timely manner.

[0010] Disadvantages of Prometheus in configuring automatic discovery monitoring in Kubernetes environment:

[0011] High entry cost: Application deployment based on cloud services introduces k8s services, which requires corresponding service upgrades and cloud environment deployment.

[0012] Difficult debugging: Autodiscovery can make debugging more difficult because errors can originate from multiple places, including the Kubernetes cluster, the Prometheus configuration, or the target itself.

[0013] Dependency: Prometheus's automatic discovery mechanism depends on the health and stability of the Kubernetes cluster. If there is a problem with the Kubernetes cluster, it may affect Prometheus's monitoring capabilities. Summary of the invention

[0014] In view of the above problems, the present invention is proposed to provide a method for implementing Prometheus automatic monitoring in a microservice scenario that overcomes the above problems or at least partially solves the above problems.

[0015] According to one aspect of the present invention, a method for implementing Prometheus automatic monitoring in a microservice scenario is provided, and the automatic monitoring method includes:

[0016] System parameter configuration;

[0017] Load relevant configurations and complete monitoring;

[0018] Automatically update the service status to update the monitoring list.

[0019] Optionally, the system parameter configuration specifically includes:

[0020] The service operation manager configures the microservice related parameters that need to be monitored based on the management interface;

[0021] The first step is to configure the prometheus service parameters, including server IP, username, password, and installation and deployment path information;

[0022] The second step is the nacos parameters, including address, username, password, namespace, service name, and supports multiple prometheus and nacos configurations, associated configurations of prometheus and nacos, and completes all nacos services that prometheus wants to monitor.

[0023] Optionally, the loading of related configurations to complete monitoring specifically includes:

[0024] The service is based on the relevant configuration parameters. First, load all prometheus parameter lists, analyze the corresponding nacos configuration parameters one by one, and subscribe to relevant service information according to the nacos service subscription list. The service information is processed and modified into the monitoring configuration format file of prometheus. After all files are generated, they are uploaded to the specified path according to the parameter information of prometheus, and this interface is called according to the overload api of prometheus to complete the reloading of the configuration. After waiting for 1 minute, the targets interface is called to query the monitoring list of prometheus and compare it with the previous service list file. If they are consistent, it means that the system monitoring is normal. If they are inconsistent, find out the inconsistent information and put it into the database for the operation and maintenance personnel to check the abnormality.

[0025] Optionally, the automatic update service status update monitoring list specifically includes:

[0026] The scheduled update task refreshes the monitoring list. The service will subscribe to the service change events of the nacos service registration center based on the subscribed nacos service list information, monitor the new online or offline events of the service, dynamically obtain the change information, and update the local monitoring service file. Upload it to the corresponding monitoring service prometheus server, continue to call the overload API interface and targets interface, and complete the configuration update and exception comparison.

[0027] Optionally, the system parameter configuration also includes:

[0028] When configuring microservice monitoring, service operation managers set key parameters of Prometheus and Nacos services through the management interface;

[0029] The configuration of the Prometheus service is the basis. Enter the IP address of the server to ensure accurate data collection, and set the username and password to ensure access security.

[0030] The installation and deployment path is related to the operating environment of the Prometheus service;

[0031] Administrators need to configure Nacos services in detail, including entering the service address to connect to the Nacos cluster, configuring the username and password for authentication, defining namespaces to distinguish different service environments, and specifying the specific service names that need to be monitored.

[0032] When facing multi-tenant or large-scale service deployment, the system provides powerful multi-instance configuration capabilities, allowing administrators to configure multiple Nacos services for each Prometheus instance;

[0033] Through intelligent association configuration, administrators can easily associate Prometheus with Nacos services;

[0034] The system also provides advanced monitoring features that automatically trigger alarms based on preset performance indicator thresholds to promptly notify managers of potential problems;

[0035] Data visualization tools help managers intuitively understand the performance of services, displaying key performance indicators through charts and dashboards;

[0036] The system also supports historical data analysis, enabling managers to track changing trends in service performance and provide data support for optimizing services.

[0037] Optionally, the loading of related configurations and completing monitoring further includes:

[0038] During the operation of the service, it operates according to the preset relevant configurations and parameters;

[0039] First, load all Prometheus parameter lists. The service will analyze the corresponding Nacos configuration parameters one by one. By analyzing the Nacos configuration parameters, the service obtains the service information that needs to be subscribed.

[0040] The service subscribes to relevant service information according to the service subscription list of Nacos; service information is the key to system operation, including the operation status and IP port information of various services;

[0041] After subscribing to the service information, the service processes the information;

[0042] The processing method is to modify the service information into the monitoring configuration format file of Prometheus;

[0043] After the file is generated, the service uploads the file to the specified path according to the parameter information of Prometheus;

[0044] After the file is uploaded, the service calls this interface according to the Prometheus reload API to complete the configuration reload;

[0045] After waiting for 1 minute, the service will call the Targets interface to query the Prometheus monitoring list and compare it with the previous service list file;

[0046] If the two are consistent, the system monitoring is normal and no operation is required; if they are inconsistent, the service finds the inconsistent information and stores it in the database, waiting for the operation and maintenance personnel to check for abnormalities.

[0047] Optionally, the automatic update service status update monitoring list specifically includes:

[0048] The service subscribes to the service change events of the nacos service registration center based on the subscribed nacos service list information;

[0049] Monitor new online or offline events of services, dynamically obtain change information, update local monitoring service files, and upload the updated files to the corresponding monitoring service prometheus server;

[0050] Continue to call the overload API interface and targets interface to complete configuration updates and exception comparisons;

[0051] The service subscribes to the service change events of the nacos service registration center according to the subscribed nacos service list information;

[0052] When a new service is launched or an existing service is offline, the service will immediately monitor the event;

[0053] After listening to the event, the service dynamically obtains the change information;

[0054] By subscribing to the service change events of the nacos service registration center, the service can dynamically obtain change information and update the local monitoring service file;

[0055] Upload the updated file to the corresponding monitoring service prometheus server.

[0056] The present invention provides a method for implementing Prometheus automatic monitoring in a microservice scenario, the method comprising: system parameter configuration; loading relevant configurations to complete monitoring; and automatically updating the service status and monitoring list. The method avoids the tediousness of manual configuration and improves the efficiency and accuracy of monitoring configuration.

[0057] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0059] Figure 1 A schematic diagram of system parameter configuration provided by an embodiment of the present invention;

[0060] Figure 2 A schematic diagram of loading-related configuration provided by an embodiment of the present invention;

[0061] Figure 3 A schematic diagram of automatic updating provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0062] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0063] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.

[0064] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0065] A method for implementing Prometheus automatic monitoring in a microservice scenario includes:

[0066] System parameter configuration; load relevant configuration and complete monitoring; automatically update service status and update monitoring list.

[0067] The first step is system parameter configuration. The service operation manager configures the microservice related parameters that need to be monitored based on the management interface. The first step is to configure the prometheus service parameters, including server IP, user name, password, installation and deployment path and other information. The second step is the nacos parameters, including address, user name, password, namespace, service name, and supports multiple prometheus and nacos configurations, associated configurations of prometheus and nacos, and completes all nacos services that prometheus wants to monitor.

[0068] The second step is to load the relevant configuration. The service is based on the relevant configuration parameters. First, load all the prometheus parameter lists, analyze the corresponding nacos configuration parameters one by one, and subscribe to the relevant service information according to the nacos service subscription list. Process the service information and modify it to the prometheus monitoring configuration format file. After all files are generated, upload them to the specified path according to the prometheus parameter information, call this interface according to the prometheus overload api, complete the configuration reload, wait for 1 minute, call the targets interface, query the prometheus monitoring list and compare it with the previous service list file. If it is consistent, it means that the system monitoring is normal. If it is inconsistent, find out the inconsistent information and put it into the database for the operation and maintenance personnel to check the abnormality.

[0069] The third step is to refresh the monitoring list by regularly updating the task. The service will subscribe to the service change events of the nacos service registration center based on the subscribed nacos service list information. Once the new online or offline events of the service are monitored, the change information will be dynamically obtained, and the local monitoring service file will be updated. Then it will be uploaded to the corresponding monitoring service prometheus server, and the overloaded api interface and targets interface will continue to be called to complete the configuration update and exception comparison.

[0070] like Figure 1 As shown, system parameter configuration:

[0071] When configuring microservice monitoring, service operation managers set key parameters of Prometheus and Nacos services through the management interface. The configuration of the Prometheus service is the basis. You need to enter the IP address of the server to ensure accurate data collection, and set the username and password to ensure access security. The installation and deployment path is related to the operating environment of the Prometheus service. Managers need to configure the Nacos service in detail, including entering the service address to connect to the Nacos cluster, configuring the username and password for authentication, defining namespaces to distinguish different service environments, and clearly specifying the specific service names that need to be monitored.

[0072] When facing multi-tenant or large-scale service deployment, the system provides powerful multi-instance configuration capabilities, allowing administrators to configure multiple Nacos services for each Prometheus instance. This flexibility enables the monitoring system to scale to adapt to the growing number and complexity of services. Through intelligent association configuration, administrators can easily associate Prometheus with Nacos services to ensure the accuracy and integrity of monitoring data.

[0073] The system also provides advanced monitoring features, such as custom alarm rules, which can automatically trigger alarms based on preset performance indicator thresholds to promptly notify managers of potential problems. Data visualization tools can help managers intuitively understand the performance of services, displaying key performance indicators through charts and dashboards. At the same time, the system also supports historical data analysis, allowing managers to track the changing trends of service performance and provide data support for optimizing services.

[0074] like Figure 2 As shown, load the relevant configuration:

[0075] During the operation of the service, it will operate according to the preset related configurations and parameters. First, all Prometheus parameter lists are loaded, and the service will analyze the Nacos configuration parameters corresponding to these parameters one by one. By analyzing the Nacos configuration parameters, the service can obtain the service information that needs to be subscribed.

[0076] The service will subscribe to the relevant service information according to the service subscription list of Nacos. These service information are the key to the operation of the system, and they contain the operation status and IP port information of various services.

[0077] After subscribing to the service information, the service will process the information. The processing method is to modify the service information into the monitoring configuration format file of Prometheus. This is because Prometheus has its own unique configuration file format. Only in this format can Prometheus correctly read and parse the configuration file.

[0078] After the files are generated, the service will upload them to the specified path according to the parameter information of Prometheus. This path is where Prometheus reads the configuration files. Only when the files are uploaded here can Prometheus read the new configuration information.

[0079] After the file is uploaded, the service will call this interface according to the Prometheus reload API to complete the configuration reload. This is because after Prometheus reads the new configuration file, it needs to reload the configuration for the new configuration to take effect.

[0080] After waiting for 1 minute, the service will call the Targets interface to query the Prometheus monitoring list and compare it with the previous service list file. If the two are consistent, it means that the system monitoring is normal and no operation is required. If they are inconsistent, the service will find the inconsistent information and store it in the database for the operation and maintenance personnel to check for abnormalities.

[0081] like Figure 3 As shown, automatically update:

[0082] The service will subscribe to the service change events of the nacos service registration center based on the subscribed nacos service list information. Once the new online or offline events of the service are monitored, the change information will be dynamically obtained, and the local monitoring service file will be updated, and the updated file will be uploaded to the corresponding monitoring service prometheus server. Continue to call the reload api interface and targets interface to complete the configuration update and exception comparison.

[0083] In this process, the service will subscribe to the service change events of the nacos service registration center according to the subscribed nacos service list information. This means that when a new service is launched or an existing service is offline, the service will immediately monitor these events. Once these events are monitored, the service will dynamically obtain change information to keep abreast of the current status of the service.

[0084] By subscribing to the service change events of the nacos service registry, the service can dynamically obtain change information and update the local monitoring service file. Then, the updated file is uploaded to the corresponding monitoring service prometheus server for further configuration updates and exception comparisons. This ensures that the service is always up to date and any problems can be discovered and resolved in a timely manner.

[0085] Beneficial effects: 1. Automatic service discovery mechanism: The service interface of the Nacos registration center is used to realize automatic discovery of microservices. When a new microservice instance is registered to Nacos, it can be immediately identified and included in the monitoring scope.

[0086] 2. Dynamic configuration update: Prometheus monitoring configuration can be dynamically updated according to the online and offline events of the service. This avoids the tedious manual configuration and improves the efficiency and accuracy of monitoring configuration.

[0087] 3. Compatibility: It is specially designed for the Prometheus monitoring scenarios under the currently popular Spring Cloud Alibaba framework in China. It is suitable for most application services that have not yet been upgraded to the cloud-native architecture, solving the monitoring problems under the traditional architecture.

[0088] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for implementing Prometheus automatic monitoring in a microservice scenario, characterized in that: The automatic monitoring method comprises: System parameter configuration; Load relevant configurations and complete monitoring; Automatically update the service status to update the monitoring list.

2. According to a method for implementing Prometheus automatic monitoring in a microservice scenario according to claim 1, it is characterized in that: The system parameter configuration specifically includes: The service operation manager configures the microservice related parameters that need to be monitored based on the management interface; The first step is to configure the prometheus service parameters, including server IP, username, password, and installation and deployment path information; The second step is the nacos parameters, including address, username, password, namespace, service name, and supports multiple prometheus and nacos configurations, associated configurations of prometheus and nacos, and completes all nacos services that prometheus wants to monitor.

3. According to a method for implementing Prometheus automatic monitoring in a microservice scenario according to claim 1, it is characterized in that: The loading of related configurations and completion of monitoring specifically include: The service is based on the relevant configuration parameters. First, load all prometheus parameter lists, analyze the corresponding nacos configuration parameters one by one, and subscribe to relevant service information according to the nacos service subscription list. The service information is processed and modified into the monitoring configuration format file of prometheus. After all files are generated, they are uploaded to the specified path according to the parameter information of prometheus, and this interface is called according to the overload api of prometheus to complete the reloading of the configuration. After waiting for 1 minute, the targets interface is called to query the monitoring list of prometheus and compare it with the previous service list file. If they are consistent, it means that the system monitoring is normal. If they are inconsistent, find out the inconsistent information and put it into the database for the operation and maintenance personnel to check the abnormality.

4. According to a method for implementing Prometheus automatic monitoring in a microservice scenario according to claim 1, it is characterized in that: The automatic update service status update monitoring list specifically includes: The scheduled update task refreshes the monitoring list. The service will subscribe to the service change events of the nacos service registration center based on the subscribed nacos service list information, monitor the new online or offline events of the service, dynamically obtain the change information, and update the local monitoring service file. Upload it to the corresponding monitoring service prometheus server, continue to call the overload API interface and targets interface, and complete the configuration update and exception comparison.

5. According to a method for implementing Prometheus automatic monitoring in a microservice scenario according to claim 1, it is characterized in that: The system parameter configuration also includes: When configuring microservice monitoring, service operation managers set key parameters of Prometheus and Nacos services through the management interface; The configuration of the Prometheus service is the basis. Enter the IP address of the server to ensure accurate data collection, and set the username and password to ensure access security. The installation and deployment path is related to the operating environment of the Prometheus service; Administrators need to configure Nacos services in detail, including entering the service address to connect to the Nacos cluster, configuring the username and password for authentication, defining namespaces to distinguish different service environments, and specifying the specific service names that need to be monitored. When facing multi-tenant or large-scale service deployment, the system provides powerful multi-instance configuration capabilities, allowing administrators to configure multiple Nacos services for each Prometheus instance; Through intelligent association configuration, administrators can easily associate Prometheus with Nacos services; The system also provides advanced monitoring features that automatically trigger alarms based on preset performance indicator thresholds to promptly notify managers of potential problems; Data visualization tools help managers intuitively understand the performance of services, displaying key performance indicators through charts and dashboards; The system also supports historical data analysis, enabling managers to track changing trends in service performance and provide data support for optimizing services.

6. According to a method for implementing Prometheus automatic monitoring in a microservice scenario according to claim 1, it is characterized in that: The loading of related configurations and completion of monitoring also include: During the operation of the service, it operates according to the preset relevant configurations and parameters; First, load all Prometheus parameter lists. The service will analyze the corresponding Nacos configuration parameters one by one. By analyzing the Nacos configuration parameters, the service obtains the service information that needs to be subscribed. The service subscribes to relevant service information according to the service subscription list of Nacos; service information is the key to system operation, including the operation status and IP port information of various services; After subscribing to the service information, the service processes the information; The processing method is to modify the service information into the monitoring configuration format file of Prometheus; After the file is generated, the service uploads the file to the specified path according to the parameter information of Prometheus; After the file is uploaded, the service calls this interface according to the Prometheus reload API to complete the configuration reload; After waiting for 1 minute, the service will call the Targets interface to query the Prometheus monitoring list and compare it with the previous service list file; If the two are consistent, the system monitoring is normal and no operation is required; if they are inconsistent, the service finds the inconsistent information and stores it in the database, waiting for the operation and maintenance personnel to check for abnormalities.

7. According to a method for implementing Prometheus automatic monitoring in a microservice scenario according to claim 1, it is characterized in that: The automatic update service status update monitoring list specifically includes: The service subscribes to the service change events of the nacos service registration center based on the subscribed nacos service list information; Monitor new online or offline events of services, dynamically obtain change information, update local monitoring service files, and upload the updated files to the corresponding monitoring service prometheus server; Continue to call the overload API interface and targets interface to complete configuration updates and exception comparisons; The service subscribes to the service change events of the nacos service registration center according to the subscribed nacos service list information; When a new service is launched or an existing service is offline, the service will immediately monitor the event; After listening to the event, the service dynamically obtains the change information; By subscribing to the service change events of the nacos service registration center, the service can dynamically obtain change information and update the local monitoring service file; Upload the updated file to the corresponding monitoring service prometheus server.

Citation Information

Cited By

  • Method for monitoring service in IP (Internet Protocol) network and related device

    CN119728760A