Interface monitoring method and device, equipment, storage medium and product

Through the automated interface monitoring method, the combination of interface orchestration scripts and remote configuration tools, the problem of inefficient interface monitoring in the existing technology is solved, and fast response and efficient operation and maintenance are achieved.

CN119415357APending Publication Date: 2025-02-11中移信息技术有限公司 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411500804.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The existing K8s interface monitoring method is inefficient, making it difficult to ensure the comprehensiveness and timeliness of monitoring, resulting in long failure response time, poor operation and maintenance efficiency and stability, and waste of resources and high operation and maintenance costs.

Method used

An interface monitoring method is proposed, by receiving interface monitoring tasks, determining interface orchestration scripts, generating execution command scripts, performing parameter configurations, obtaining target interface orchestration scripts, and executing the script through preset remote configuration tools to obtain interface monitoring results.

Benefits of technology

It realizes the automation of interface monitoring, shortens fault response time, improves the operation and maintenance efficiency and stability of large-scale clusters, and reduces resource waste and operation and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415357A_ABST
    Figure CN119415357A_ABST
Patent Text Reader

Abstract

The invention discloses an interface monitoring method and device, equipment, a storage medium and a product, and relates to the technical field of computers.The interface monitoring method comprises the steps that an interface monitoring task is received, and an interface arrangement script is determined according to the interface monitoring task; generating an execution command script based on the interface monitoring task, and performing parameter configuration on the interface arrangement script according to the execution command script to obtain a target interface arrangement script; and executing the target interface arrangement script according to a preset remote configuration tool to obtain an interface monitoring result. Compared with an existing mode that the log is checked manually and regularly for interface monitoring, the method has the advantages that the interface monitoring can be automatically carried out, the fault response time is greatly shortened, the operation and maintenance efficiency and stability of a large-scale cluster are effectively improved, and the resource waste and the operation and maintenance cost are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an interface monitoring method, device, equipment, storage medium and product. Background Art

[0002] As the scale of Kubernetes (K8s) clusters continues to expand and business complexity increases, it becomes critical to ensure the stability and health of these interfaces. Any instability or performance degradation of the K8s interface will quickly spread to the entire service chain, resulting in service unavailability, increased response delays, reduced user experience, and even an avalanche effect, causing the entire system to crash. Especially in industries such as communications and finance that have strict requirements for high availability and low latency, any slight fluctuation in the K8s interface may cause huge economic losses and damage to brand reputation. In related technologies, the monitoring of K8s interfaces generally adopts manual monitoring, with operation and maintenance personnel regularly logging into the console to view logs and manually executing command lines to check the interface status.

[0003] In the increasingly complex and dynamically changing cloud computing environment, traditional manual monitoring methods are stretched to the limit. Faced with the huge K8s cluster and numerous external capability interfaces, relying on operation and maintenance personnel to regularly log in to the console to check logs and manually execute command lines to check interface status is not only time-consuming and inefficient, but also difficult to ensure the comprehensiveness and timeliness of monitoring. Summary of the invention

[0004] The main purpose of this application is to provide an interface monitoring method, device, equipment, storage medium and product, aiming to solve the technical problems that the existing interface monitoring methods are inefficient and difficult to ensure the comprehensiveness and timeliness of monitoring.

[0005] To achieve the above object, the present application proposes an interface monitoring method, which includes:

[0006] Receiving an interface monitoring task, and determining an interface orchestration script according to the interface monitoring task;

[0007] Generate an execution command script based on the interface monitoring task, and configure parameters of the interface orchestration script according to the execution command script to obtain a target interface orchestration script;

[0008] The target interface orchestration script is executed according to a preset remote configuration tool to obtain an interface monitoring result.

[0009] Optionally, the step of executing the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result includes:

[0010] Determining an operating system file according to the interface monitoring task;

[0011] Connecting to the target host using the operating system file through a preset remote configuration tool;

[0012] When the connection is successful, the target interface orchestration script is executed on the target host to obtain the interface monitoring result.

[0013] Optionally, the step of determining the operating system file according to the interface monitoring task includes:

[0014] Determining the encrypted operating system file according to the interface monitoring task;

[0015] The encrypted operating system file is decrypted by a preset symmetric decryption algorithm to obtain the operating system file, and the operating system file is saved.

[0016] Optionally, the step of receiving an interface monitoring task and determining an interface orchestration script according to the interface monitoring task includes:

[0017] Receiving an interface monitoring task sent by a distributed scheduling tool based on a preset encryption protocol, and determining an interface orchestration script according to the interface monitoring task;

[0018] The interface monitoring task is generated by the distributed scheduling tool according to the task configuration information sent by the monitoring backend.

[0019] Optionally, after the step of executing the target interface orchestration script according to the preset remote configuration tool to obtain the interface monitoring result, the step further includes:

[0020] Encapsulate the interface monitoring result to obtain a response body;

[0021] The response body is sent to the monitoring backend through a preset encryption protocol, and the response body includes at least one of the following: execution status, execution log, execution start time, execution end time and error cause.

[0022] Optionally, the step of executing the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result includes:

[0023] Execute the target interface orchestration script according to a preset remote configuration tool and monitor the execution process;

[0024] Determining whether an execution exception occurs according to the execution process;

[0025] When an execution exception occurs, the preset rollback mechanism is called to perform rollback and generate interface monitoring results.

[0026] In addition, to achieve the above purpose, the present application also proposes an interface monitoring device, the interface monitoring device comprising:

[0027] A receiving module, used for receiving an interface monitoring task and determining an interface orchestration script according to the interface monitoring task;

[0028] A parameter configuration module, used to generate an execution command script based on the interface monitoring task, and perform parameter configuration on the interface orchestration script according to the execution command script to obtain a target interface orchestration script;

[0029] The execution module is used to execute the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result.

[0030] In addition, to achieve the above objectives, the present application also proposes an interface monitoring device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the interface monitoring method described above.

[0031] In addition, to achieve the above objectives, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the interface monitoring method described above are implemented.

[0032] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the interface monitoring method described above are implemented.

[0033] The present application receives an interface monitoring task, determines an interface orchestration script according to the interface monitoring task; generates an execution command script based on the interface monitoring task, and configures the interface orchestration script according to the execution command script to obtain a target interface orchestration script; executes the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result. Since the present application determines an interface orchestration script according to an interface monitoring task, and then generates an execution command script, configures the interface orchestration script according to the execution command script to obtain a target interface orchestration script, executes the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result. Compared with the existing method of manually checking logs regularly for interface monitoring, the above method of the present application can automatically monitor the interface, greatly shorten the fault response time, effectively improve the operation and maintenance efficiency and stability of large-scale clusters, and reduce resource waste and operation and maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0036] Figure 1 A flowchart of the first embodiment of the interface monitoring method of the present application is provided;

[0037] Figure 2 A schematic diagram of the system architecture provided for the first embodiment of the interface monitoring method of the present application;

[0038] Figure 3 A schematic diagram of a script example provided for the first embodiment of the interface monitoring method of this application;

[0039] Figure 4 A flowchart of the second embodiment of the interface monitoring method of the present application is provided;

[0040] Figure 5 A monitoring flow diagram provided for the second embodiment of the interface monitoring method of this application;

[0041] Figure 6 This is a schematic diagram of the module structure of the interface monitoring device according to an embodiment of the present application;

[0042] Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the interface monitoring method in the embodiment of the present application.

[0043] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0044] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0045] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0046] The main solution of the embodiment of the present application is: receiving an interface monitoring task, and determining an interface orchestration script according to the interface monitoring task; generating an execution command script based on the interface monitoring task, and configuring parameters of the interface orchestration script according to the execution command script to obtain a target interface orchestration script; executing the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result.

[0047] Since this application determines the interface orchestration script according to the interface monitoring task, and then generates an execution command script, configures the interface orchestration script parameters according to the execution command script, obtains the target interface orchestration script, and executes the target interface orchestration script according to the preset remote configuration tool to obtain the interface monitoring result. Compared with the existing method of manually checking logs regularly for interface monitoring, the above method of this application can automatically monitor the interface, greatly shorten the fault response time, effectively improve the operation and maintenance efficiency and stability of large-scale clusters, and reduce resource waste and operation and maintenance costs.

[0048] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a monitoring agent device, etc. The following takes the monitoring agent device as an example to illustrate this embodiment and the following embodiments.

[0049] Based on this, the present application embodiment provides an interface monitoring method, referring to Figure 1 , Figure 1 A flowchart of the first embodiment of the interface monitoring method of the present application is provided.

[0050] In this embodiment, the interface monitoring method includes steps S10 to S30:

[0051] Step S10, receiving an interface monitoring task, and determining an interface orchestration script according to the interface monitoring task;

[0052] It should be noted that the interface monitoring task can be a task configured by the user to monitor each interface in the K8s cluster. The interface monitoring task may include information such as the interface orchestration script to be executed, the task execution frequency, the execution time, the execution script parameters, etc. In addition, when configuring the interface monitoring task, the functions of timed triggering, deletion, pause and resume of the task are also supported. The script types of the interface orchestration script are mainly: Playbook, which is a script form of the remote configuration tool Ansible, similar to a Shell script, and is a collection of a series of commands for controlling the remote host.

[0053] The interface orchestration script is used to call a series of K8s interfaces to perform operations such as creation, reading, querying or deletion. The interface orchestration script is usually written in a combination of Playbook and Shell or other programming languages ​​that support HTTP requests, because the K8s interface is a RES Tful API based on the HTTP / HTTPS protocol. When designing the script, the sequence of interfaces to be called will be planned in advance. Each interface call contains authentication information (such as using Bearer Token), request method (GET, POST, PATCH, etc.), request path (such as querying node information, Pod status, etc.) and necessary request body content, thereby realizing the full life cycle management of various resources in K8s (Pod, ConfigMap, Deployment, StatefulSet, Daemonset, etc.), including creation, reading, querying and deletion operations.

[0054] Step S20, generating an execution command script based on the interface monitoring task, and configuring parameters of the interface orchestration script according to the execution command script to obtain a target interface orchestration script;

[0055] It should be noted that the interface monitoring task includes information such as the script name and execution script parameters, and the generation of the execution command script based on the interface monitoring task may be to generate an execution command script (.sh) based on the script name and execution script parameters. The configuration of the interface orchestration script parameters according to the execution command script to obtain the target interface orchestration script may be to run the execution command script, log in to the K8s host using a preset remote configuration tool, configure the parameters of the interface orchestration script according to the execution parameters (such as "execution parameter 1 = a execution parameter 2 = b"), and obtain the configured target interface orchestration script.

[0056] It should be understood that users can easily modify the parameters of the interface arrangement script as needed, and the interface arrangement in the form of scripts provides extremely high flexibility and logic. At the same time, through parameterized design, the same script can adapt to monitoring needs in different environments or conditions, generate execution commands based on user input parameters, and realize flexible replacement of parameters. When the system environment changes, there is no need to modify the script content itself, which improves the reusability and maintainability of the script.

[0057] Step S30, executing the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result.

[0058] It should be noted that the preset remote configuration tool can be ansible, which is used to implement centralized management and dynamic update of configuration in a distributed system to ensure the consistency and flexibility of service configuration. The target interface orchestration script is executed according to the preset remote configuration tool to obtain the interface monitoring result. Ansible uses the hosts file SSH connection to log in to the K8s host, executes the target interface orchestration script, calls the K8s interface, completes the interaction with the K8s API Server, and then outputs the interface monitoring result in Prometheus format. K8s interface (API): allows users to interact with the K8s cluster. Through the K8s interface, resources (such as Pod) can be created, updated, queried and deleted. Pod is the smallest orchestration unit in the K8s project and plays the role of a "virtual machine" in a traditional deployment environment.

[0059] It should be noted that, please refer to Figure 2 , Figure 2 A schematic diagram of the system architecture provided in Example 1 of the interface monitoring method of this application, Figure 2 The monitoring agent in the example is the monitoring agent device in this embodiment. The monitoring system of this embodiment adopts an advanced distributed architecture as a whole, which is divided into two parts: the monitoring backend and the monitoring agent (i.e., the monitoring agent device). It communicates through the HTTPS protocol and realizes comprehensive, real-time, and automatic monitoring and management of the K8s cluster API interface. Specifically, in the monitoring backend, this embodiment designs multiple functional modules such as script management, task management, cluster management, task analysis, configuration management, and alarm management. Specifically:

[0060] 1. Script management: used to store and manage various interface orchestration scripts, among which the main script types are: Playbook. Playbook is a script form of the remote configuration tool Ansible, similar to a Shell script, and is a collection of a series of commands used to control the remote host.

[0061] 2. Task management: used to create and manage monitoring tasks and assign tasks to distributed scheduling tools (such as powerjob or xxl-job). When creating a monitoring task, the user can specify the script to be executed, the task execution frequency, the execution time, the script parameters, etc. In addition, task management also supports the scheduled triggering, deletion, suspension and resumption of tasks.

[0062] 3. Cluster management: It is used to manage the information of multiple K8s clusters, store and manage the hosts files required for remote configuration tools to connect to the cluster host through SSH. Each cluster has a corresponding hosts file (host account and password). In order to ensure the security of sensitive information transmission, the monitoring backend will use the AES symmetric encryption algorithm to save the host account and password of the hosts file to the database, and the monitoring agent will decrypt the encrypted information.

[0063] 4. Task analysis: It is used to collect and analyze the data and results of monitoring task execution, and provides the function of displaying and downloading detailed reports and charts. It can intuitively display the task execution status, task execution status (queued, executing, manually canceled), whether the task is successfully executed (successful or failed), execution time (accurate to milliseconds) and other information.

[0064] 5. Configuration management, used to store and manage the parameters for creating monitoring tasks as configuration templates for creating monitoring tasks. When creating multiple monitoring tasks, you can import them into Excel with one click to create multiple tasks at one time. Store the information needed to create tasks: task name, script name, cluster name, execution cycle (Cron expression), execution time, and execution script parameters (script parameters, which can change according to the actual service deployment configuration, including: interface domain name (api_domain), port number (port), etc.).

[0065] 6. Alarm management: Prometheus is a monitoring and alarm system. After the alarm management module sends alarm rules to Prometheus, Prometheus periodically pulls indicators from node-exporter (used to collect the operating indicators of the host that executes the interface orchestration script); for example, Prometheus pulls the indicator file generated by the host executing the interface orchestration script every 20 seconds by default. When the indicator reaches the set threshold, an alarm will be reported to the alarm management module, and then the alarm management will send an alarm SMS to the user.

[0066] Distributed Scheduling Tool: It is used to receive task requests from the monitoring backend. The "Task Management" module in the monitoring backend allows users to define interface monitoring tasks, including the name of the task, the interface orchestration script to be executed, the execution frequency, the execution time, etc. Once the task is defined, the task management module converts this configuration information into a format that the distributed scheduling tool can recognize. The task management module submits the configured task to the distributed scheduling tool, which receives the task and adds it to the task queue for scheduling. The distributed scheduling tool automatically schedules the execution of the task based on the configuration information of the task (such as the execution frequency and time). It triggers the execution of the task at the appropriate time and distributes the task to the monitoring agent on the nodes in the cluster.

[0067] In this embodiment, the distributed scheduling tool can be used to realize the automation and periodic execution of the interface monitoring task. Specifically, the interface monitoring task that has passed the test is added to the scheduled task scheduler of the distributed scheduling tool to realize the automation and periodic execution of the interface monitoring task. For example, the cluster resource status is checked once every morning, or the health status of the key interface is checked every 1 minute.

[0068] In this embodiment, three functional modules are designed on the monitoring agent side: script parsing, script execution, and result return. Among them, script parsing is used to parse and save the interface orchestration script received from the distributed scheduling tool, and decrypt the hosts file information using the AES algorithm according to the key and save it to the monitoring agent side. The monitoring agent side generates an execution command script (.sh) according to the script name and execution script parameters sent by the monitoring backend.

[0069] Script execution: used to call the operating system command execution command (.sh) script to call the remote configuration tool (Ansible). The remote configuration tool will actually execute the interface orchestration script (.yaml) to implement actual monitoring operations on the K8s interface. The task management module has a script testing function. In order to avoid script errors or script parameter input errors but continuous execution, the test task is only executed once. If the test is successful, the task is created. The monitoring agent parses the test script and saves the temporary script and hosts files. After the test, it will automatically clear them to avoid accumulated files occupying container resources.

[0070] Result return: used to encapsulate the execution results of the interface orchestration script and then return them to the monitoring backend through the HT TPS protocol. In addition, in order to better interact with the K8s cluster, a remote configuration tool is introduced on the monitoring agent side, through which it interacts with the K8s interface to obtain cluster status information or add, delete, modify and query cluster resources.

[0071] In the entire system, the database plays an important role. It stores all interface orchestration scripts, task information, cluster configuration, alarm management, monitoring results and other data, which are crucial for subsequent query and analysis.

[0072] This embodiment is a distributed K8s interface monitoring solution, which realizes all-round monitoring and timely alarm of K8s interface through reasonable division of labor and efficient communication mechanism. In this embodiment, Cangjie programming language is used. The advantages of using Cangjie programming language are its high performance, ease of use and rich network programming library, which enables the system to run efficiently and stably, while simplifying development and maintenance work. Not only can the health status of K8s interface be checked regularly, but also data can be automatically analyzed, potential problems can be predicted, and alarms can be issued in advance, thereby helping the operation and maintenance team to quickly locate and solve problems and ensure the stable operation of K8s cluster. At the same time, this embodiment also provides flexible configuration options, which can be personalized according to different needs to meet the monitoring needs in different scenarios.

[0073] Furthermore, in order to avoid the resource remaining in the system and occupying resources when the interface fails to be called midway, and to avoid the problem of failure to create resources due to resource conflicts when the interface orchestration script is executed again, the interface orchestration script for creating resources in this embodiment has a rollback mechanism. Specifically, the step S30 includes: executing the target interface orchestration script according to the preset remote configuration tool and monitoring the execution process; judging whether an execution exception occurs according to the execution process; when an execution exception occurs, calling the preset rollback mechanism to perform rollback and generate an interface monitoring result.

[0074] The interface arrangement script for creating resources in this embodiment has a rollback mechanism. When a resource is successfully created, if an error occurs when executing the query, update, or other interfaces (before executing the deletion), the deletion interface will be directly called to ensure that the resource will not remain in the system and occupy resources when the interface call fails. This also avoids the problem of failure to create resources due to resource conflicts caused by executing the interface arrangement script again. If there is a problem with the deletion interface, manual intervention can be made to manually delete the resource.

[0075] When it does not involve creating interface orchestration scripts that change the system status of resources, such as querying interface orchestration scripts: querying a specified nood, querying a node list, querying a specified pod, querying a pod list, querying a de ployment list, querying a statefulset list, querying a daemonset list, querying an application service status, querying an application service list, and querying an image list. These 10 interface calls are orchestrated into one script. These 10 interfaces do not involve changes to system resources, but are only queries. Even if one of the interfaces sends an error, the order of the 10 interfaces is not related and will not affect the system status and the next script execution, so there will be no rollback operation. Reading interface orchestration scripts is similar to querying interface orchestration scripts, so I will not go into details.

[0076] It should be noted that, please refer to Figure 3 , Figure 3This is a schematic diagram of a script example provided for the second embodiment of the interface monitoring method of this application. The interface orchestration script is used to call the K8s interface of the pod to perform operations on the pod. Specifically, 301: Get the Token first. In K8s, the API Server is the core of cluster control, which exposes a series of interfaces for cluster users to use. For security, users need to use Token for authentication. If the acquisition fails, the process ends.

[0077] 302: After the token verification is passed, execute step 302 to try to create a new Pod. Pod is the basic unit for running applications in K8s. If the creation fails, resource conflicts may occur. Execute 305 to delete the Pod to resolve the resource conflict.

[0078] It should be noted that the various resources in K8s include: Pod, ConfigMap, Deployment, StatefulSet, Daemonset, and the same is true for other types of resources. Pod is just an example here.

[0079] 303: If the Pod is created successfully, execute step 303 to query the list of all Pods in the current cluster. If a failure occurs, execute 305 to delete the Pod to prevent resources from remaining in the cluster.

[0080] 304: If the previous step is successfully verified, execute step 304 to query the status of the Pod created in 302. If a failure occurs, execute 305 to delete the Pod to prevent resources from remaining in the cluster.

[0081] 305: If all the above steps are executed, the deletion operation is performed.

[0082] 306: If 305 fails to delete the Pod interface, manual intervention is required to delete it.

[0083] Further, in order to ensure the security of data transmission, the step S10 includes: receiving an interface monitoring task sent by a distributed scheduling tool based on a preset encryption protocol, and determining an interface orchestration script according to the interface monitoring task;

[0084] The interface monitoring task is generated by the distributed scheduling tool according to the task configuration information sent by the monitoring backend.

[0085] It should be noted that the preset encryption protocol can be an SSL / TLS protocol. After the user configures the monitoring task through the monitoring backend, the monitoring backend converts the configuration information of the monitoring task into a format that can be recognized by the distributed scheduling tool. The distributed scheduling tool receives the monitoring task and adds it to the task queue for scheduling. The distributed scheduling tool automatically schedules the execution of the task according to the configuration information of the task (such as execution frequency and time). The task execution is triggered at the appropriate time, and the interface monitoring task is generated according to the configuration information of the monitoring task and the monitoring task, and then sent to the monitoring agent through the preset encryption protocol.

[0086] Furthermore, in order to enable the user to intuitively view the interface monitoring result, after the step S30, it further includes: encapsulating the interface monitoring result to obtain a response body;

[0087] The response body is sent to the monitoring backend through a preset encryption protocol, and the response body includes at least one of the following: execution status, execution log, execution start time, execution end time and error cause.

[0088] It should be noted that the monitoring agent obtains the result of the remote configuration tool executing the interface orchestration script, encapsulates the response body and then returns it to the monitoring backend through https, so that the monitoring backend can analyze and display the interface monitoring results. The response body mainly includes: execution status (ok / failed), execution results (including: execution log, start time, end time, error cause (if status = failed)).

[0089] This embodiment receives an interface monitoring task, determines an interface orchestration script according to the interface monitoring task; generates an execution command script based on the interface monitoring task, and configures the interface orchestration script according to the execution command script to obtain a target interface orchestration script; executes the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result. Since this embodiment determines an interface orchestration script according to an interface monitoring task, and then generates an execution command script, configures the interface orchestration script according to the execution command script to obtain a target interface orchestration script, and executes the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result. Compared with the existing method of manually checking logs regularly for interface monitoring, the above method of this embodiment can automatically monitor the interface, greatly shorten the fault response time, effectively improve the operation and maintenance efficiency and stability of large-scale clusters, and reduce resource waste and operation and maintenance costs.

[0090] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 4 , Figure 4The flowchart provided in the second embodiment of the interface monitoring method of the present application, step S30, further includes the following steps:

[0091] Step S31: determining the operating system file according to the interface monitoring task;

[0092] It should be noted that the operating system file may be a file containing the host account and password of each cluster, that is, a hosts file.

[0093] Furthermore, in order to ensure the security of data during transmission and prevent man-in-the-middle attacks or data eavesdropping, the step of determining the operating system file according to the interface monitoring task includes:

[0094] Determining the encrypted operating system file according to the interface monitoring task;

[0095] The encrypted operating system file is decrypted by a preset symmetric decryption algorithm to obtain the operating system file, and the operating system file is saved.

[0096] It should be noted that when the monitoring backend sends the operating system file, it will encrypt the operating system file through a preset symmetric encryption algorithm, and when the data is transmitted, HTTP communication will also be encrypted through the SSL / TLS protocol to protect the security and integrity of the data during transmission. Therefore, the encrypted operating system file included in the interface monitoring task needs to be decrypted using a preset symmetric decryption algorithm. The preset symmetric decryption algorithm can be an AES symmetric decryption algorithm.

[0097] Step S32: connecting to the target host using the operating system file through a preset remote configuration tool;

[0098] It should be noted that the preset remote configuration tool can be Ansible, that is, Figure 2 A remote configuration tool that connects to the monitoring agent in .

[0099] Step S33: When the connection is successful, the target interface orchestration script is executed on the target host to obtain an interface monitoring result.

[0100] In the specific implementation, the monitoring agent calls the operating system command to run the execution command script (sh. / exec s / script name_task id.sh). The command actually executed by the operating system is the execution command script content, that is: ansible-playbook-i. / hosts / hosts_task id. / script / script name_task id.yaml-e "execution parameter 1 = a execution parameter 2 = b". Here, the execution command script is used to log in to the K8s host using the remote configuration tool, configure the parameters of the interface orchestration script according to the execution parameters (such as "execution parameter 1 = a, execution parameter 2 = b"), and use the configured interface orchestration script to call the K8s interface, complete the interaction with the Kubernetes API Server, and output the interface monitoring results in Prometheus format.

[0101] In the specific implementation, please refer to Figure 5 , Figure 5 The monitoring process diagram provided for the second embodiment of the interface monitoring method of this application specifically includes: 201. Triggering the monitoring task: The task management module of the monitoring backend uses a distributed scheduling tool to schedule and periodically execute the monitoring task. When the execution time and execution frequency set when creating the monitoring task are reached, the task scheduling will be triggered.

[0102] 201. Acquisition of interface orchestration script: The script management module of the monitoring backend acquires the interface orchestration script corresponding to the task from the database; for example, this embodiment adopts the Ansible Playbook script.

[0103] 203. Cluster hosts file acquisition: The cluster management module of the monitoring backend obtains the cluster host hosts file from the database according to the cluster name of the task, which is used for monitoring the agent SSH remote login to the cluster host.

[0104] 204. Send https request to monitoring agent: The task management module of the monitoring backend encapsulates the task request body and sends https request to the monitoring agent. The request body carries the task id and name, the interface orchestration script name and content, the execution script parameters, and the cluster hosts file information. https requests the SSL / TLS protocol to encrypt HTTP communication, thereby protecting the security and integrity of data during transmission.

[0105] 205. Parse and save the interface orchestration script: The script parsing module of the monitoring agent obtains the request body, parses the request content, and parses and saves the interface orchestration script to the container specified folder (. / script / script name_task id.yaml).

[0106] 206. Decrypt and save hosts file: The script parsing module of the monitoring agent obtains the request body, parses the request content, uses the AES symmetric decryption algorithm (the key is the key used to encrypt the hosts file saved by the monitoring backend) to decrypt the hosts file and save it to the specified folder (. / hosts / hosts_task id), and performs a test to verify the accuracy of the settings. If the test fails, you need to check whether the configuration file account and password are correct or whether the parameter settings are correct according to the test log; otherwise, proceed to the next stage.

[0107] 207. Generate and save the execution command script: The script parsing module of the monitoring agent obtains the request body, parses the request content, and generates the execution command script (. / execs / script name_task id.sh) according to the script name, hosts file name and script execution parameters. The execution command script content is, for example: ansible-playbook-i. / hosts / hosts_task id. / script / script name_task id.yaml-e "execution parameter 1 = a, execution parameter 2 = b". The three files saved in steps 205-207, namely the interface orchestration script, hosts file and execution command script corresponding to each task, are unique to avoid thread safety issues caused by high concurrency. In particular, when monitoring the backend test script, the task has not been created yet, so no task id is generated. The monitoring agent determines whether it is a test task or a monitoring task based on whether there is a task id. When it is a test task, the agent will generate a UUID instead of the task id to ensure the uniqueness of the file and avoid thread safety issues. The temporary test file is cleared immediately after the test is completed.

[0108] 208. The system runs the execution command script: The script execution module of the monitoring agent calls the operating system command to run the execution command script (sh. / execs / script name_task id.sh). The command actually executed by the operating system in 208 is the execution command script content, that is: ansible-playbook-i. / hosts / hosts task id. / script / script name_task id.yaml-e "execution parameter 1 = a, execution parameter 2 = b". The execution command script is used to log in to the host using the remote configuration tool, configure the parameters of the interface orchestration script according to the execution parameters (such as "execution parameter 1 = a, execution parameter 2 = b"), and use the configured interface orchestration script to perform operations (i.e., implement step 209).

[0109] The remote configuration tool executes the interface orchestration script (209): The remote configuration tool (ansible) uses the hosts file (. / hosts / hosts_task id) to connect to the host through SSH and execute the interface orchestration script (. / script / script name_task id.yaml) to call the K8s interface and complete the interaction with the Kubernetes API Server.

[0110] 210. Output Prometheus format results: The remote configuration tool executes the interface orchestration script to call the K8s interface and obtains the return value, which is encapsulated into Prometheus format data. The data is output to the specified directory and ends with .prom.

[0111] As shown below, the output should be sent to the default directory, such as / var / lib / node_exporter. In addition to comments, each line of data in the .pr om file contains: indicator name, label, and value. Label:

[0112] url and model represent the called url and module;

[0113] code is the http status code;

[0114] errcode is the application status code;

[0115] message is the error content, which can be used in alarm SMS to display detailed problems.

[0116] A value of 1 indicates ok, and 0 indicates fail;

[0117] Each interface call returns and saves a record to the .prom file.

[0118] 211. The monitoring backend obtains the execution result and encapsulates the response body: The result return module of the monitoring agent obtains the result of the remote configuration tool executing the interface orchestration script, encapsulates the response body and returns it to the monitoring backend. The response body mainly includes: execution status (ok / failed), execution result (including: execution log, start time, end time, error reason (if status = failed)), and then returns it to the monitoring backend through https.

[0119] 212. Save the task execution results and analyze and display the task execution results: The task management module of the monitoring backend parses the response body returned by the agent, calculates the script execution time (milliseconds) based on the start time and end time, and saves the task execution results. The results of the saved monitoring tasks are displayed, and detailed information such as charts and Excel tables can be displayed and downloaded. At this point, a complete monitoring task process ends.

[0120] This embodiment also provides cloud native monitoring: mainly including Prometheus and node-exporter. For example, after the interface orchestration script A is executed, an indicator file (that is, the above-mentioned .prom file) is generated. By default, Prometheus pulls the node-exporter of the host once every 20 seconds to obtain the indicator file generated by the host executing the interface orchestration script A.

[0121] This embodiment also includes alarm management: the alarm management module of the monitoring backend configures alarm rules, sends the alarm rules to Prometheus and takes effect, Prometheus reports to the alarm management module according to the alarm rules, and the alarm management module sends an alarm SMS.

[0122] Furthermore, in order to avoid naming conflicts of environmental resources of the entire system, different applications or monitoring tasks cannot directly access each other's resources, reducing security risks caused by resource competition or malicious operations. In this embodiment, the Namespace mechanism of K8s is used to implement resource isolation, and each specific interface monitoring task or application runs in a specified Namespace to achieve fine division and management of resources. This isolation design ensures the efficiency and security of resource use, and provides a highly flexible and non-interfering execution environment for different monitoring needs. Users can adjust resource quotas according to overall monitoring requirements, and Namespace dynamically allocates resources according to specific tasks to achieve comprehensive resource management from macro to micro, improve resource utilization, and ensure efficient execution of monitoring tasks. For example, the resources in the specified Namespace do not involve the resources of the user system, avoiding misoperation of the user system resources. This isolation mechanism ensures that even if a task is abnormal, it will not affect the normal operation of other tasks, improving the stability and security of the overall system.

[0123] This embodiment determines the operating system file according to the interface monitoring task; uses the operating system file to connect to the target host through a preset remote configuration tool; when the connection is successful, executes the target interface orchestration script on the target host to obtain the interface monitoring result. This embodiment can periodically and automatically monitor the health status of the K8s interface, and can also instantly identify anomalies and trigger alarms according to preset alarm rules, greatly shortening the fault response time. At the same time, this embodiment fully considers scalability and compatibility, ensures support for various interfaces and complex scenarios, effectively improves the operation and maintenance efficiency and stability of large-scale clusters, reduces resource waste and operation and maintenance costs, and thus provides a strong guarantee for business continuity and security in cloud environments.

[0124] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the interface monitoring method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0125] This application also provides an interface monitoring device, please refer to Figure 6 , the interface monitoring device comprises:

[0126] A receiving module 10 is used to receive an interface monitoring task and determine an interface orchestration script according to the interface monitoring task;

[0127] A parameter configuration module 20, used to generate an execution command script based on the interface monitoring task, and perform parameter configuration on the interface orchestration script according to the execution command script to obtain a target interface orchestration script;

[0128] The execution module 30 is used to execute the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result.

[0129] This embodiment receives an interface monitoring task, determines an interface orchestration script according to the interface monitoring task; generates an execution command script based on the interface monitoring task, and configures the interface orchestration script according to the execution command script to obtain a target interface orchestration script; executes the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result. Since this embodiment determines an interface orchestration script according to an interface monitoring task, and then generates an execution command script, configures the interface orchestration script according to the execution command script to obtain a target interface orchestration script, and executes the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result. Compared with the existing method of manually checking logs regularly for interface monitoring, the above method of this embodiment can automatically monitor the interface, greatly shorten the fault response time, effectively improve the operation and maintenance efficiency and stability of large-scale clusters, and reduce resource waste and operation and maintenance costs.

[0130] The interface monitoring device provided by the present application adopts the interface monitoring method in the above embodiment, which can solve the technical problems that the existing interface monitoring method is inefficient and difficult to ensure the comprehensiveness and timeliness of monitoring. Compared with the prior art, the beneficial effects of the interface monitoring device provided by the present application are the same as the beneficial effects of the interface monitoring method provided by the above embodiment, and other technical features in the interface monitoring device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0131] The present application provides an interface monitoring device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the interface monitoring method in the above-mentioned embodiment one.

[0132] Reference below Figure 7 , which shows a schematic diagram of the structure of an interface monitoring device suitable for implementing the embodiment of the present application. The interface monitoring device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The interface monitoring device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0133] like Figure 7 As shown, the interface monitoring device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In the RAM 1004, various programs and data required for the operation of the interface monitoring device are also stored. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems may be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 may allow the interface monitoring device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows an interface monitoring device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.

[0134] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0135] The interface monitoring device provided by the present application adopts the interface monitoring method in the above embodiment, which can solve the technical problems that the existing interface monitoring method is inefficient and difficult to ensure the comprehensiveness and timeliness of monitoring. Compared with the prior art, the beneficial effects of the interface monitoring device provided by the present application are the same as the beneficial effects of the interface monitoring method provided by the above embodiment, and the other technical features in the interface monitoring device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0136] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0137] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0138] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the interface monitoring method in the above-mentioned embodiment.

[0139] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0140] The computer-readable storage medium may be included in the interface monitoring device; or may exist independently without being assembled into the interface monitoring device.

[0141] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the interface monitoring device, the interface monitoring device executes the interface monitoring method.

[0142] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0143] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0144] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0145] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned interface monitoring method, and can solve the technical problems that the existing interface monitoring method is inefficient and difficult to ensure the comprehensiveness and timeliness of monitoring. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the interface monitoring method provided by the above-mentioned embodiment, and will not be repeated here.

[0146] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned interface monitoring method when executed by a processor.

[0147] The computer program product provided by the present application can solve the technical problems that the existing interface monitoring methods are inefficient and difficult to ensure the comprehensiveness and timeliness of monitoring. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the interface monitoring method provided by the above embodiment, which will not be repeated here.

[0148] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. An interface monitoring method, characterized in that: The interface monitoring method comprises the following steps: Receiving an interface monitoring task, and determining an interface orchestration script according to the interface monitoring task; Generate an execution command script based on the interface monitoring task, and configure parameters of the interface orchestration script according to the execution command script to obtain a target interface orchestration script; The target interface orchestration script is executed according to a preset remote configuration tool to obtain an interface monitoring result.

2. The interface monitoring method according to claim 1, characterized in that: The step of executing the target interface orchestration script according to the preset remote configuration tool to obtain the interface monitoring result includes: Determining an operating system file according to the interface monitoring task; Connecting to the target host using the operating system file through a preset remote configuration tool; When the connection is successful, the target interface orchestration script is executed on the target host to obtain the interface monitoring result.

3. The interface monitoring method according to claim 2, characterized in that: The step of determining the operating system file according to the interface monitoring task includes: Determining the encrypted operating system file according to the interface monitoring task; The encrypted operating system file is decrypted by a preset symmetric decryption algorithm to obtain the operating system file, and the operating system file is saved.

4. The interface monitoring method according to any one of claims 1 to 3, characterized in that: The step of receiving an interface monitoring task and determining an interface orchestration script according to the interface monitoring task includes: Receiving an interface monitoring task sent by a distributed scheduling tool based on a preset encryption protocol, and determining an interface orchestration script according to the interface monitoring task; The interface monitoring task is generated by the distributed scheduling tool according to the task configuration information sent by the monitoring backend.

5. The interface monitoring method according to any one of claims 1 to 3, characterized in that: After the step of executing the target interface orchestration script according to the preset remote configuration tool to obtain the interface monitoring result, the method further includes: Encapsulate the interface monitoring result to obtain a response body; The response body is sent to the monitoring backend through a preset encryption protocol, and the response body includes at least one of the following: execution status, execution log, execution start time, execution end time and error cause.

6. The interface monitoring method according to any one of claims 1 to 3, characterized in that: The step of executing the target interface orchestration script according to the preset remote configuration tool to obtain the interface monitoring result includes: Execute the target interface orchestration script according to a preset remote configuration tool and monitor the execution process; Determining whether an execution exception occurs according to the execution process; When an execution exception occurs, the preset rollback mechanism is called to perform rollback and generate interface monitoring results.

7. An interface monitoring device, characterized in that: The interface monitoring device comprises: A receiving module, used for receiving an interface monitoring task and determining an interface orchestration script according to the interface monitoring task; A parameter configuration module, used to generate an execution command script based on the interface monitoring task, and perform parameter configuration on the interface orchestration script according to the execution command script to obtain a target interface orchestration script; The execution module is used to execute the target interface orchestration script according to a preset remote configuration tool to obtain an interface monitoring result.

8. An interface monitoring device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the interface monitoring method according to any one of claims 1 to 6.

9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the interface monitoring method according to any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the interface monitoring method according to any one of claims 1 to 6 are implemented.