Application monitoring log generation method and device, equipment and medium
By introducing interceptors into microservices, the requirements log format of the application monitoring system are obtained and parsed, and application monitoring logs that meet the requirements are extracted and generated, the problem of log format mismatch is solved, and the efficiency and security of log generation are improved.
Patent Information
- Application Number
- CN202411123563.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-12-03
AI Technical Summary
In the existing solution to collect microservice application logs, the application monitoring log format generated by the acquisition agent is fixed, while the log format required by the application monitoring system does not match, resulting in the inability to provide normal monitoring services.
By introducing interceptors in microservices, we can obtain the requirements log format of the application monitoring system, intercept request and response information, extract target field information, and generate application monitoring logs based on the requirements log format, ensuring that the log format meets the requirements of the monitoring system, and setting permissions Control to protect data security.
It realizes the generation of application monitoring logs that meet the data format requirements of the application monitoring system, improves log generation efficiency, prevents the problem of incomplete log content, and ensures that only authorized users can modify the log format, protects the security and integrity of the application system. sex.
Smart Images

Figure CN119065944A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a method, device, equipment and medium for generating an application monitoring log. Background Art
[0002] With the development of Internet technology, the architecture of Internet application systems has become increasingly complex. Usually, an application system contains dozens of microservices. Therefore, it is necessary to monitor the operation of microservices from various dimensions to keep an eye on whether the various business indicators of the application system are normal.
[0003] Currently, a common solution is to collect application logs of microservices and process them into application monitoring logs in a fixed format. The application monitoring logs contain information such as the request interface name, service response time, and service response status. The application monitoring logs can be used to analyze whether the application logic is normal and whether the application operation is stable.
[0004] Existing solutions for collecting microservice application logs mostly integrate information collection agents on the application side, such as Figure 1 As shown in the figure, the application logs of microservices are collected through the collection agent, and then processed into application monitoring logs in a fixed format and output to the application monitoring system, which then aggregates and calculates the data and provides relevant monitoring services. Among them, the collection agent adopts the bytecode agent method and is combined with the application at runtime. However, when the collection agent is running, it is integrated into the application in the form of a black box. Therefore, it is impossible to perceive whether there is a problem with the collection agent during the application development and debugging stage, such as the collection agent is not suitable for the application environment. In addition, the application monitoring log format generated by the collection agent is fixed, while the application monitoring system has a required log format. When the formats of the two do not match, the application monitoring system cannot provide normal monitoring services. Summary of the invention
[0005] The embodiments of the present application provide an application monitoring log generation method, apparatus, device and medium, which are used to solve the problem that the application monitoring log format generated by the collection agent is fixed and does not match the log format required by the application monitoring system.
[0006] In a first aspect, the present application provides a method for generating an application monitoring log, the method comprising:
[0007] Obtaining a demand log format, parsing the demand log format, and obtaining demand field attributes;
[0008] According to the required field attributes, target field information is extracted from the intercepted request information and response information, wherein the request information is initiated by the client and the response information is initiated by the microservice;
[0009] Generate an application monitoring log according to the required log format and the target field information.
[0010] The present application obtains the required log format of the application monitoring system, parses it, obtains the required field attributes, and on this basis, uses an interceptor to intercept the request information initiated from the outside to the microservice and the response information made by the microservice, and extracts the required target field information from the intercepted request information and response information according to the required field attributes, and then generates an application monitoring log according to the target field information and the required log format. This method can generate an application monitoring log that meets the data format requirements of the application monitoring system, and can generate application monitoring logs in different formats according to the data format requirements of different application monitoring systems to meet the requirements of different application monitoring systems.
[0011] In a possible embodiment, the requirement field attributes include: service name, log file path, timestamp, request path, request scheme, processing time, response status, response code and response description.
[0012] According to these field attributes, the target field information in the request information and response information can be accurately extracted, thereby improving the efficiency of generating application monitoring logs.
[0013] In a possible embodiment, extracting the target field information from the intercepted request information and response information according to the requirement field attribute includes: intercepting the request information initiated by the client to the microservice by an interceptor, and extracting the first target field information from the request information according to the requirement field attribute; intercepting the response information initiated by the microservice and corresponding to the request information by the interceptor, and extracting the second target field information from the response information according to the requirement field attribute; and associating the first target field information with the second target field information to obtain the target field information.
[0014] By introducing interceptors into microservices, we can intercept the external request information and the response information from microservices, and extract the target field information from the request information and response information according to the required field attributes, so that we can generate application monitoring logs that meet the data format requirements of the application monitoring system directly according to the target field information and the required log format. The interceptor is introduced into the microservice in the form of a tool jar package, which is not sensitive to the application logic, but is integrated with the application, which helps to understand the business meaning and troubleshoot problems.
[0015] In a possible embodiment, generating an application monitoring log according to the required log format and the target field information includes: caching the target field information according to a preset data structure to obtain a cache log; extracting the target field information from the cache log, inputting the target field information into a preset log file according to the required log format to obtain an application monitoring log.
[0016] By caching the extracted target field information, it can be prevented that when a large number of requests come in, some target field information cannot be processed in time and is lost or deleted, which in turn causes the generated application monitoring log content to be incomplete.
[0017] In a possible embodiment, after generating the application monitoring log according to the required log format and the target field information, it also includes: when receiving a change request to change the required log format, determining whether the user information carried by the change request exists in the preset authority user table; if the user information carried by the change request exists in the preset authority user table, changing the required log format according to the log format carried by the change request; if the user information carried by the change request does not exist in the preset authority user table, outputting a prompt message that there is no change permission.
[0018] By setting permissions for configuring the required log format, it is ensured that only authorized users can modify the above configuration, thus protecting the security and integrity of the application system data.
[0019] In a possible embodiment, after extracting the target field information from the cache log, inputting the target field information into a preset log file according to the required log format, and obtaining the application monitoring log, it also includes: detecting whether there is field information in the cache log that does not belong to the current required field attribute; if there is field information in the cache log that does not belong to the current required field attribute, deleting the field information; if there is no field information in the cache log that does not belong to the current required field attribute, periodically detecting the cache log.
[0020] By periodically detecting unnecessary field information in the cache log and deleting the unnecessary field information, the storage pressure of the cache log can be reduced.
[0021] In a second aspect, the present application provides an application monitoring log generating device, the device comprising:
[0022] An acquisition module acquires a demand log format, parses the demand log format, and obtains demand field attributes;
[0023] An extraction module extracts target field information from intercepted request information and response information according to the required field attribute, wherein the request information is initiated by the client and the response information is initiated by the microservice;
[0024] A generation module generates an application monitoring log according to the required log format and the target field information.
[0025] In a possible embodiment, the requirement field attributes include: service name, log file path, timestamp, request path, request scheme, processing time, response status, response code and response description.
[0026] In a possible embodiment, the extraction module is specifically used to: intercept request information initiated by the client to the microservice through an interceptor, and extract first target field information from the request information according to the requirement field attribute; intercept response information initiated by the microservice and corresponding to the request information through an interceptor, and extract second target field information from the response information according to the requirement field attribute; associate the first target field information with the second target field information to obtain the target field information.
[0027] In a possible embodiment, the generation module is specifically used to: cache the target field information according to a preset data structure to obtain a cache log; extract the target field information from the cache log, input the target field information into a preset log file according to the required log format, and obtain an application monitoring log.
[0028] In a possible embodiment, the device is also used to: when receiving a change request for changing the required log format, determine whether the user information carried by the change request exists in the preset authority user table; if the user information carried by the change request exists in the preset authority user table, change the required log format according to the log format carried by the change request; if the user information carried by the change request does not exist in the preset authority user table, output a prompt message that there is no change permission.
[0029] In a possible embodiment, the device is also used to: detect whether there is field information in the cache log that does not belong to the current required field attributes; if there is field information in the cache log that does not belong to the current required field attributes, delete the field information; if there is no field information in the cache log that does not belong to the current required field attributes, periodically detect the cache log.
[0030] In a third aspect, the present application provides an electronic device, including:
[0031] A memory for storing program instructions;
[0032] The processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods in the first aspect according to the obtained program instructions.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the methods described in the first aspect.
[0034] In a fifth aspect, the present application provides a computer program product, comprising: a computer program code, when the computer program code is run on a computer, the computer executes any one of the methods described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of an application scenario for collecting microservice application logs provided in an embodiment of the present application;
[0036] Figure 2 A schematic diagram of an application scenario for generating an application monitoring log provided in an embodiment of the present application;
[0037] Figure 3 A flowchart of a method for generating an application monitoring log provided in an embodiment of the present application;
[0038] Figure 4 A schematic diagram of a microservice framework structure provided for an embodiment of the present application;
[0039] Figure 5 A structural diagram of an application monitoring log generating device provided in an embodiment of the present application;
[0040] Figure 6 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0042] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0043] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0044] In the technical solution of this application, the acquisition, transmission, storage, and use of data are in compliance with the requirements of relevant national laws and regulations.
[0045] Before introducing an application monitoring log generation method provided by an embodiment of the present application, in order to facilitate understanding, the technical background of the embodiment of the present application is first introduced in detail below.
[0046] The existing Internet application system architecture is becoming increasingly complex. Usually, an application system contains dozens of microservices. It is necessary to monitor the operation of microservices from various dimensions to keep an eye on whether the various business indicators of the application system are normal. Currently, a common solution is to integrate information collection agents on the application side, such as Figure 1 As shown in the figure, the application logs of microservices are collected through the collection agent, and then processed into application monitoring logs in a fixed format and output to the application monitoring system, which aggregates and calculates the data and provides relevant monitoring services. However, when the collection agent is running, it is integrated into the application in a black box form. Therefore, it is impossible to perceive whether there is a problem with the collection agent during the application development and debugging stage. For example, the collection agent is not suitable for the application environment. In addition, the application monitoring log format generated by the collection agent is fixed, while the application monitoring system has a required log format. When the two formats do not match, the application monitoring system cannot provide normal monitoring services.
[0047] In order to solve the above problems, the embodiment of the present application provides a method for generating application monitoring logs, by introducing interceptors in each microservice, such as Figure 2 As shown, the interceptor will analyze the required log format of the acquired application monitoring system, and generate an application monitoring log according to the required log format for the content of the intercepted request information initiated by the client to the microservice and the content of the response information made by the microservice, thereby generating an application monitoring log that meets the data format requirements of the application monitoring system. This method can also realize a customized application monitoring log format to meet the data format requirements of different monitoring systems.
[0048] The technical solution in the embodiment of the present application is described in detail below in conjunction with the accompanying drawings. Figure 3 FIG. 1 is a flow chart of a method for generating an application monitoring log provided by an embodiment of the present application. The specific implementation process of the method is as follows:
[0049] Step 301: Obtain the demand log format, parse the demand log format, and obtain the demand field attributes;
[0050] In the embodiment of the present application, the demand log format is the data requirement format of the application monitoring system.
[0051] The methods for obtaining the required log format include but are not limited to the following:
[0052] Method 1: initiate a request to the application monitoring system to obtain the required log format, and extract the required log format from the response information fed back by the application monitoring system.
[0053] Method 2: Get the pre-configured required log format from the microservice.
[0054] Specifically, after introducing the interceptor in each microservice, configure each microservice as follows:
[0055] 1. Configure the microservice name, for example, serviceName = "ServiceA";
[0056] 2. Configure the application monitoring log file path, that is, the writing path of the application monitoring log. You need to ensure that the file directory exists and has write permission, for example, monLogPath = " / home / ap / mon / logs";
[0057] 3. Configure the required log format, that is, the format of the application monitoring log, for example, monLogPattern = " <timesteamp> <uri> <method> <cost> <status> <reponsecode><res ponseDescription>”.
[0058] Among them, the above configurations of each microservice can be configured by the user according to actual needs.
[0059] Furthermore, the configuration permissions of the microservices are set, and a preset permission user table is added to each microservice. Only users in the preset permission user table can perform the above configuration on the microservice.
[0060] By setting configuration permissions, it is ensured that only authorized users can modify the above configurations, thus protecting the security and integrity of application system data.
[0061] After obtaining the requirement log format, the requirement log format is parsed to obtain the requirement field attributes.
[0062] Specifically, the required field attributes include but are not limited to the field attributes in Table 1.
[0063] Field properties meaning serviceName Service Name monLogPath Log file path timestamp Timestamp method Request Plan cost Processing time status Response Status responseCode Response Code responseDescription Response Description
[0064] Table 1
[0065] Step 302: extracting target field information from intercepted request information and response information according to the required field attributes;
[0066] In the embodiment of the present application, an interceptor is introduced into the microservice to intercept the request information for accessing the microservice and the response information fed back by the microservice. The interceptor can be a tool jar package or a probe program, both of which are inserted into the microservice application in the form of a jar package. In the entire microservice framework, the entry point of the interceptor is as follows: Figure 4 As shown, after the request access processor and before the application logic processing module, it is possible to intercept the request information after the request access processor receives the external request information, and intercept the feedback response information after the application logic processing module processes the request information.
[0067] Specifically, the interceptor intercepts the request information initiated by the client to the microservice, the request information can be any request information, and the first target field information is extracted from the request information according to the required field attributes parsed above. It is worth noting that the extracted first target field information includes fields that meet the required field attributes, but is not limited to these fields.
[0068] For example, if the required field attributes include: serviceName-service name, monLogPahth-log file path, timestamp-timestamp, uri-request path, method-request scheme, status-response status, and the first target field information extracted from the request information includes: serviceName: "ServiceA", timestamp: "20240613175018", uri: " / aaa / bbb / ccc", method: "POST", cost: "44ms".
[0069] The interceptor intercepts the response information corresponding to the request information initiated by the microservice, and extracts the second target field information from the response information according to the parsed required field attributes. Similarly, the extracted second target field information includes fields that meet the required field attributes, but is not limited to these fields.
[0070] For example, if the required field attributes include: serviceName-service name, monLogPahth-log file path, timestamp-timestamp, uri-request path, method-request scheme, status-response status, and the second target field information extracted from the response information includes: serviceName: "ServiceA", timestamp: "20240613175044", uri: " / aaa / bbb / ccc", method: "POST", cost: "38ms", status: "200".
[0071] The first target field information and the second target field information are associated to obtain the target field information.
[0072] Step 303: Generate an application monitoring log according to the required log format and target field information.
[0073] After obtaining the target field information, the target field information is first cached according to a preset data format to obtain a cache log. For example, the target field information can be cached as the following data structure:
[0074] {
[0075] "timestamp": "20240613175712",
[0076] "uri": " / aaa / bbb / ccc",
[0077] "method": "POST",
[0078] "cost": "38ms",
[0079] "status": "200",
[0080] …
[0081] }
[0082] Then, the target field information is extracted from the cache log, and the target field information is input into the preset log file according to the required log format to obtain the application monitoring log. In an embodiment of the present application, after parsing the required log format, a preset log file is created under the path according to the application monitoring log file path configured on the microservice, and the preset log file is used to store the log content of the application monitoring log.
[0083] In a possible implementation, each time a request message and a response message corresponding to the request message are intercepted, the target field information of the request message and the corresponding response message can be cached to generate a cache log. Then, according to all cache logs generated within a preset time period, the log content is input line by line into a preset log file according to the required log format to obtain an application monitoring log.
[0084] In a possible implementation, all request information and all response information within a preset time period can also be intercepted, and the target field information extracted from each request information and each response information is associated (that is, the request information and the target field information of its corresponding response information are associated), and then all the associated target field information is cached to generate a cache log. Finally, according to the cache log, the log content is input into the preset log file line by line in the required Japanese format to obtain the application monitoring log.
[0085] This application obtains the demand log format of the application monitoring system, parses it, obtains the demand field attributes, and on this basis, uses an interceptor to intercept the request information initiated by the outside to the microservice and the response information made by the microservice. According to the demand field attributes, the required target field information is extracted from the intercepted request information and response information, and then the application monitoring log is generated according to the target field information and the demand log format. This method can generate an application monitoring log that meets the data format requirements of the application monitoring system, and the interceptor is introduced into the microservice in the form of a tool jar package. The application logic is not sensed, but it is integrated with the application, which helps to understand the business meaning and troubleshoot problems.
[0086] Furthermore, the demand log format can also be changed by the user according to actual needs. The specific implementation process is as follows:
[0087] When a change request to change the demand log format is received, it is determined whether the user information carried in the change request exists in the preset permission user table. In the embodiment of the present application, each microservice will pre-configure a preset permission user table, and the users on the preset permission user table have the permission to configure and change the demand log format.
[0088] If the user information carried in the change request exists in the preset permission user table, the required log format is changed according to the log format carried in the change request to obtain an updated required log format.
[0089] If the user information carried in the change request does not exist in the preset permission user table, a prompt message indicating that there is no permission to change is output.
[0090] By setting configuration permissions for each microservice, it is ensured that only authorized users can modify the above configurations, thus protecting the security and integrity of the application system data.
[0091] Furthermore, since the target field information contained in the cache log is not limited to the field information belonging to the required field attributes, and the required log format will also be changed according to the needs of the authorized user, it is necessary to detect the target field information in the cache log. The detection can be periodic or trigger the detection of the cache log in response to changes in the required log format.
[0092] Specifically, it is detected whether there is field information in the cache log that does not belong to the current required field attribute, and the current required field attribute is the field attribute parsed according to the current required log format.
[0093] If there is field information in the cache log that does not belong to the currently required field attributes, delete the field information.
[0094] If the cache log does not contain field information that does not belong to the currently required field attributes, the cache log is periodically checked.
[0095] By periodically detecting unnecessary field information in the cache log and deleting the unnecessary field information, the storage pressure of the cache log can be reduced.
[0096] The above method can be used to generate application monitoring logs that meet the data format requirements of the application monitoring system. The interceptor is introduced into the microservice in the form of a tool jar package, which is unaware of the application logic but integrated with the application, which helps to understand the business meaning and troubleshoot problems.
[0097] Based on the same inventive concept, the present application embodiment provides an application monitoring log generation device, please refer to Figure 5 , the device comprises:
[0098] The acquisition module 501 acquires the demand log format, parses the demand log format, and obtains the demand field attributes;
[0099] An extraction module 502 extracts target field information from intercepted request information and response information according to the required field attribute, wherein the request information is initiated by the client and the response information is initiated by the microservice;
[0100] The generating module 503 generates an application monitoring log according to the required log format and the target field information.
[0101] In a possible embodiment, the requirement field attributes include: service name, log file path, timestamp, request path, request scheme, processing time, response status, response code and response description.
[0102] In a possible embodiment, the extraction module 502 is specifically used to: intercept the request information initiated by the client to the microservice through an interceptor, and extract the first target field information from the request information according to the requirement field attribute; intercept the response information initiated by the microservice and corresponding to the request information through the interceptor, and extract the second target field information from the response information according to the requirement field attribute; associate the first target field information with the second target field information to obtain the target field information.
[0103] In a possible embodiment, the generation module 503 is specifically used to: cache the target field information according to a preset data structure to obtain a cache log; extract the target field information from the cache log, input the target field information into a preset log file according to the required log format, and obtain an application monitoring log.
[0104] In a possible embodiment, the device is also used to: when receiving a change request for changing the required log format, determine whether the user information carried by the change request exists in the preset authority user table; if the user information carried by the change request exists in the preset authority user table, change the required log format according to the log format carried by the change request; if the user information carried by the change request does not exist in the preset authority user table, output a prompt message that there is no change permission.
[0105] In a possible embodiment, the device is also used to: detect whether there is field information in the cache log that does not belong to the current required field attributes; if there is field information in the cache log that does not belong to the current required field attributes, delete the field information; if there is no field information in the cache log that does not belong to the current required field attributes, periodically detect the cache log.
[0106] Based on the same inventive concept, an electronic device is also provided in an embodiment of the present application, and the electronic device can realize the function of the aforementioned application monitoring log generating device, referring to Figure 6 , the electronic device comprises:
[0107] At least one processor 601, and a memory 602 connected to the at least one processor 601. The specific connection medium between the processor 601 and the memory 602 is not limited in the embodiment of the present application. Figure 6 In the example, the processor 601 and the memory 602 are connected via a bus 600. Figure 6 The connection between other components is shown by bold lines, and is not intended to be limiting. The bus 600 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 601 can also be called a controller, and there is no limitation on the name.
[0108] In the embodiment of the present application, the memory 602 stores instructions that can be executed by at least one processor 601. The at least one processor 601 can execute the application monitoring log generation method discussed above by executing the instructions stored in the memory 602. The processor 601 can implement Figure 5 The functions of each module in the device shown.
[0109] Among them, the processor 601 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 602 and calling the data stored in the memory 602, the various functions of the device and processing data, the device can be monitored as a whole.
[0110] In one possible design, the processor 601 may include one or more processing units, and the processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 601. In some embodiments, the processor 601 and the memory 602 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.
[0111] Processor 601 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the application monitoring log generation method disclosed in the embodiments of the present application can be directly embodied as a hardware processor execution, or a combination of hardware and software modules in the processor.
[0112] The memory 602 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 602 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 602 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 602 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0113] By programming the processor 601, the code corresponding to the application monitoring log generation method described in the above embodiment can be fixed into the chip, so that the chip can execute the code when running. Figure 3 The steps of the application monitoring log generation method of the embodiment shown are as follows: How to design and program the processor 601 is a technology well known to those skilled in the art and will not be described in detail here.
[0114] Based on the same inventive concept, the embodiment of the present application provides a computer-readable storage medium, and the computer program product includes: computer program code, when the computer program code is executed on a computer, the computer executes any of the application monitoring log generation methods discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the application monitoring log generation method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0115] Based on the same inventive concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the application monitoring log generation methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of the application monitoring log generation method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0116] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0117] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0118] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0119] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of user-operated steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0120] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.< / reponsecode> < / status> < / cost> < / method> < / uri> < / timesteamp>
Claims
1. A method for generating an application monitoring log, characterized in that: The method comprises: Obtaining a demand log format, parsing the demand log format, and obtaining demand field attributes; According to the required field attributes, target field information is extracted from the intercepted request information and response information, wherein the request information is initiated by the client and the response information is initiated by the microservice; Generate an application monitoring log according to the required log format and the target field information.
2. The method according to claim 1, characterized in that The required field attributes include: service name, log file path, timestamp, request path, request scheme, processing time, response status, response code and response description.
3. The method according to claim 1, characterized in that The step of extracting target field information from intercepted request information and response information according to the required field attribute includes: Intercepting the request information initiated by the client to the microservice through the interceptor, and extracting the first target field information from the request information according to the required field attribute; Intercepting the response information initiated by the microservice and corresponding to the request information through an interceptor, and extracting the second target field information from the response information according to the required field attribute; The first target field information and the second target field information are associated to obtain the target field information.
4. The method according to claim 1, characterized in that The generating the application monitoring log according to the required log format and the target field information includes: Cache the target field information according to a preset data structure to obtain a cache log; The target field information is extracted from the cache log, and the target field information is input into a preset log file according to the required log format to obtain an application monitoring log.
5. The method according to claim 1, characterized in that After generating the application monitoring log according to the required log format and the target field information, the method further includes: When receiving a change request for changing the demand log format, determining whether the user information carried in the change request exists in a preset authority user table; If the user information carried in the change request exists in the preset authority user table, the required log format is changed according to the log format carried in the change request; If the user information carried in the change request does not exist in the preset authority user table, a prompt message indicating that there is no change authority is output.
6. The method according to claim 4, characterized in that After extracting the target field information from the cache log, inputting the target field information into a preset log file according to the required log format, and obtaining the application monitoring log, the method further includes: Detect whether there is field information in the cache log that does not belong to the currently required field attribute; If there is field information in the cache log that does not belong to the currently required field attribute, then the field information is deleted; If the cache log does not contain field information that does not belong to the currently required field attribute, the cache log is periodically checked.
7. An application monitoring log generating device, characterized in that: The device comprises: An acquisition module acquires a demand log format, parses the demand log format, and obtains demand field attributes; An extraction module extracts target field information from intercepted request information and response information according to the required field attribute, wherein the request information is initiated by the client and the response information is initiated by the microservice; A generation module generates an application monitoring log according to the required log format and the target field information.
8. The device according to claim 7, characterized in that The required field attributes include: service name, log file path, timestamp, request path, request scheme, processing time, response status, response code and response description.
9. The device according to claim 7, characterized in that The extraction module is specifically used for: Intercepting the request information initiated by the client to the microservice through the interceptor, and extracting the first target field information from the request information according to the required field attribute; Intercepting the response information initiated by the microservice and corresponding to the request information through an interceptor, and extracting the second target field information from the response information according to the required field attribute; The first target field information and the second target field information are associated to obtain the target field information.
10. The device according to claim 7, characterized in that The generating module is specifically used for: Cache the target field information according to a preset data structure to obtain a cache log; The target field information is extracted from the cache log, and the target field information is input into a preset log file according to the required log format to obtain an application monitoring log.
11. The device according to claim 7, characterized in that The device is also used for: When receiving a change request for changing the demand log format, determining whether the user information carried in the change request exists in a preset authority user table; If the user information carried in the change request exists in the preset authority user table, the required log format is changed according to the log format carried in the change request; If the user information carried in the change request does not exist in the preset authority user table, a prompt message indicating that there is no change authority is output.
12. The device according to claim 7, characterized in that The device is also used for: Detect whether there is field information in the cache log that does not belong to the currently required field attribute; If there is field information in the cache log that does not belong to the currently required field attribute, then the field information is deleted; If the cache log does not contain field information that does not belong to the currently required field attribute, the cache log is periodically checked.
13. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of claims 1-6 according to the obtained program instructions.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 6.
15. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 6.
