Log-based monitoring item processing method and device, equipment and storage medium
By receiving the business code uploaded by users and using the log printing function to automatically determine monitoring items, it solves the problem of low efficiency and accuracy in monitoring item management, realizes efficient adding of monitoring items and log monitoring, and improves monitoring efficiency and accuracy.
Patent Information
- Application Number
- CN202410650514.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-23
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-05-23
AI Technical Summary
In the existing technology, the management efficiency and accuracy of monitoring items are low, resulting in low monitoring efficiency and accuracy of logs, and it is easy to miss monitoring items, which affects the rapid discovery of online problems.
By receiving the business code uploaded by the user, using the preset log printing function to determine the monitoring items to be added, and adding them to the monitoring system through the preset interface, automatic monitoring item management and monitoring system data transmission are realized.
It improves the processing efficiency and accuracy of monitoring items, reduces manual operations, avoids missing monitoring items, significantly improves the efficiency and accuracy of log monitoring, and reduces the process of adding monitoring items from the hour level to the second level.
Smart Images

Figure CN118567960A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of log monitoring in the field of computer technology, and in particular to a method, device, equipment and storage medium for processing log-based monitoring items. Background Art
[0002] In the process of processing business, business logs can be generated in real time, and logs can be used to represent the business working process. Online problems can be quickly discovered by monitoring logs. Monitoring items play a very important role in monitoring. Different monitoring items can monitor different information in the logs.
[0003] Monitoring items are derived from logs printed by the business. Manual log sorting can easily lead to omission of monitoring items, resulting in low management efficiency and accuracy of monitoring items, which in turn affects the monitoring efficiency and accuracy of logs. Summary of the invention
[0004] The present invention provides a method, device, equipment and storage medium for processing monitoring items based on logs.
[0005] According to a first aspect of the present disclosure, a method for processing monitoring items based on logs is provided, wherein the monitoring items represent items in the logs that need to be monitored, and the method comprises:
[0006] Receive a business code uploaded by a user; wherein the business code is used to generate a business log and output the business log in a preset log format, and the business code includes a log printing function, and the log printing function represents the preset log format;
[0007] According to the log printing function, character information located at a preset position is determined from the business code as a monitoring item to be added;
[0008] By calling a preset interface, the monitoring item to be added is added to a preset monitoring system; wherein the preset interface is used for data transmission with the preset monitoring system, and the preset monitoring system is used for monitoring the content of the log according to the monitoring item.
[0009] According to a second aspect of the present disclosure, a device for processing monitoring items based on logs is provided, wherein the monitoring items represent items in the logs that need to be monitored, and the device includes:
[0010] A code receiving unit, used to receive a business code uploaded by a user; wherein the business code is used to generate a business log and output the business log in a preset log format, wherein the business code includes a log printing function, and the log printing function represents a preset log format;
[0011] A monitoring item determination unit, used to determine, according to the log printing function, character information located at a preset position from the business code as a monitoring item to be added;
[0012] The monitoring item adding unit is used to add the monitoring item to be added to the preset monitoring system by calling the preset interface; wherein the preset interface is used to transmit data with the preset monitoring system, and the preset monitoring system is used to monitor the content of the log according to the monitoring item.
[0013] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0014] at least one processor; and
[0015] a memory communicatively coupled to the at least one processor;
[0016] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.
[0017] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method described in the first aspect.
[0018] According to a fifth aspect of the present disclosure, a computer program product is provided, the computer program product comprising: a computer program, which implements the method described in the first aspect when executed by a processor.
[0019] According to the technology disclosed in the present invention, the processing efficiency and accuracy of monitoring items are improved.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0022] Figure 1 It is a flowchart of a method for processing a monitoring item based on a log provided in an embodiment of the present disclosure;
[0023] Figure 2 It is a flowchart of a method for processing a monitoring item based on a log provided in an embodiment of the present disclosure;
[0024] Figure 3It is a flowchart of a method for processing a monitoring item based on a log provided in an embodiment of the present disclosure;
[0025] Figure 4 is a schematic diagram of a visual interface of a monitoring system provided according to an embodiment of the present disclosure;
[0026] Figure 5 It is a structural block diagram of a log-based monitoring item processing device provided according to an embodiment of the present disclosure;
[0027] Figure 6 It is a structural block diagram of a log-based monitoring item processing device provided according to an embodiment of the present disclosure;
[0028] Figure 7 is a block diagram of an electronic device for implementing the log-based monitoring item processing method of the embodiment of the present disclosure;
[0029] Figure 8 The block diagram is a block diagram of an electronic device used to implement the log-based monitoring item processing method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0031] Monitoring is to quickly discover online problems. In the monitoring process, monitoring items play a very important role. Monitoring items represent items that need to be monitored in the log, for example, the traffic size needs to be monitored, the CPU usage needs to be monitored, etc.
[0032] Monitoring items are derived from business logs, and there are many logs. Currently, people manually comb through the logs, obtain the keywords of monitoring items from the logs, and then manually add the keywords of monitoring items to the monitoring system to manage the monitoring items. This method has a low processing efficiency for monitoring items and is prone to missing monitoring items, which affects the efficiency and accuracy of subsequent log monitoring.
[0033] The present invention discloses a method, device, equipment and storage medium for processing monitoring items based on logs, which are applied to the field of log monitoring in the field of computer technology to improve the processing efficiency and accuracy of monitoring items.
[0034] It should be noted that the data in this embodiment is not targeted at a specific user and cannot reflect the personal information of a specific user. It should be noted that the data in this embodiment comes from a public data set.
[0035] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0036] In order to enable readers to more deeply understand the implementation principle of the present disclosure, the following Figure 1-Figure 8 The embodiment is further refined.
[0037] Figure 1 The present invention is a flowchart of a method for processing monitoring items based on logs according to an embodiment of the present disclosure. The monitoring items represent items in the logs that need to be monitored. The method can be executed by a device for processing monitoring items based on logs. Figure 1 As shown, the method comprises the following steps:
[0038] S101, receiving a business code uploaded by a user; wherein the business code is used to generate a business log and output the business log in a preset log format, and the business code includes a log printing function, and the log printing function represents the preset log format.
[0039] Exemplarily, a user may refer to a developer of a business, and a business code is a code submitted by the developer when developing a business function. The business code may include a code portion for executing the business function and a code portion for printing a log. Every time a user updates a business function or updates the log generation requirements, a new business code may be uploaded. For example, if a user adds a business function, the code portion for executing the business function is updated. After uploading a new business code, the new business function can be executed.
[0040] The business code includes a code portion for printing a log, so the business code can be used to generate a log of the business. The user can set a preset log format in the business code, and the business log can be output in the preset log format through the business code. The preset log format can be determined by a preset log printing function, that is, the business code can include a log printing function, and different log printing functions can represent different log formats. According to the preset log printing function, a standardized log format is provided, and the R&D personnel add the log printing function to the business code to facilitate the subsequent generation of a log in a standard format. In this embodiment, the preset log printing function is not specifically limited.
[0041] Users can upload business codes at any time. Every time a user uploads a business code, the business code can be received in real time, so as to achieve timely processing of monitoring items and improve the efficiency of log monitoring.
[0042] S102. According to the log printing function, character information located at a preset position is determined from the business code as a monitoring item to be added.
[0043] For example, after obtaining the business code, the business code can be statically checked to determine the monitoring items to be added from the business code. For example, when a user submits a business code, a callback hook of the pipeline is triggered to automatically perform a static code check on the business code, and the monitoring items are extracted from the code portion of the print log of the business code.
[0044] The business code contains a log printing function. Different positions in the log printing function may correspond to different parameters. Parameters refer to the business-related information represented in the log, and monitoring items may be parameters in the code. That is, different positions in the business code may correspond to different parameters. By setting the log printing function, you can determine the location of each parameter in the code. After setting the log printing function, you can determine the location of the parameters to be monitored in the business code, that is, determine the location of the monitoring item in the business code.
[0045] That is, the preset position in the business code can be predetermined according to the log printing function, and after receiving the business code, the character information located at the preset position is determined from the business code, and the obtained character information is determined as the monitoring item to be added. For example, the relevant parameters in the log printing function can be obtained, and the first parameter can be determined as the monitoring item to be added. In this embodiment, one or more monitoring items to be added can be determined.
[0046] In this embodiment, the method also includes: if the log printing function does not exist in the business code, the monitoring item to be added is not extracted from the business code, and a second prompt message is sent to the user; wherein the second prompt message is used to remind the user to check the log printing function of the business code.
[0047] Specifically, the business code is written by the user. When writing the business code, the user may not add the log printing function to the business code, that is, the log printing function may not exist in the business code.
[0048] When statically testing the business code, it can be determined whether the business code contains a log printing function. If so, the character information at the preset position in the business code can be determined as the monitoring item to be added; if not, the monitoring item to be added cannot be extracted from the business code, and a second prompt message can be sent to the user. The second prompt message can be used to remind the user to check the business code to confirm whether the log printing function is missing, so as to resubmit the business code and test the business code again.
[0049] The beneficial effect of this setting is that if the business code does not contain the preset log printing function, the user is reminded that the monitoring item cannot be extracted, avoiding subsequent unnecessary detection operations, improving the extraction efficiency and accuracy of the monitoring item, and improving the accuracy of the business code.
[0050] S103. Add the monitoring item to be added to the preset monitoring system by calling the preset interface; wherein the preset interface is used to transmit data with the preset monitoring system, and the preset monitoring system is used to monitor the content of the log according to the monitoring item.
[0051] Exemplarily, the monitoring items to be added refer to monitoring items that need to be added to the preset monitoring system, and the monitoring system can be used to monitor the content of the log according to the monitoring items to determine the abnormal situation written in the log. In this embodiment, the preset monitoring system is not specifically limited.
[0052] After obtaining the monitoring items to be added, the monitoring items to be added can be automatically added to the preset monitoring system. For example, the API (Application Programming Interface) of the monitoring system can be called, that is, the preset interface can be called, and the preset interface can be used for data transmission with the preset monitoring system to automatically add monitoring items to the monitoring system.
[0053] The monitoring system stores multiple monitoring items. When the business is actually running, the monitoring system obtains the log in the preset log format. According to the preset monitoring items, the corresponding content of the monitoring items is obtained from the log, that is, the content to be monitored is obtained. According to the preset log format, the corresponding position of each monitoring item in the log can be determined, so as to extract the log content corresponding to the monitoring item and improve the monitoring efficiency.
[0054] In the disclosed embodiment, a business code uploaded by a user is received, and the business code includes a log printing function, through which the log can be printed in a preset log format. The detection of the business code is automatically triggered, and according to the log printing function, the character information located at a preset position is determined from the business code as the monitoring item to be added. By calling the preset interface, the monitoring item to be added is automatically added to the preset monitoring system, so that the preset monitoring system can monitor the content of the log according to the monitoring item. There is no need to manually sort out the monitoring items and add them to the monitoring system. By automatically determining the monitoring items and automatically adding them to the monitoring system, the efficiency of adding monitoring items can be improved, and the process of adding monitoring items can be reduced from the hour level to the second level, thereby improving the processing efficiency and accuracy of the monitoring items. It also avoids the problem of abnormalities occurring online due to manual omission of monitoring items, which cannot be discovered, thereby improving the efficiency and accuracy of monitoring.
[0055] Figure 2 A flowchart of a log-based monitoring item processing method provided in an embodiment of the present disclosure.
[0056] In this embodiment, according to the log printing function, the character information located at the preset position is determined from the business code as the monitoring item to be added, including: obtaining the log level in the business code; wherein the log level represents the abnormal level of the log; if the log level in the business code is the preset log level, then according to the log printing function and the log level in the business code, the character information located at the preset position is determined from the business code as the monitoring item to be added.
[0057] like Figure 2 As shown, the method comprises the following steps:
[0058] S201, receiving a business code uploaded by a user; wherein the business code is used to generate a business log and output the business log in a preset log format, and the business code includes a log printing function, and the log printing function represents the preset log format.
[0059] Exemplarily, this step may refer to the above-mentioned step S101 and will not be described in detail.
[0060] S202: Obtain the log level in the business code; wherein the log level represents the abnormal level of the log.
[0061] Exemplarily, the business code is detected to determine whether the business code contains a preset log printing function. If so, the log level contained in the business code is determined; if not, the monitoring item is not extracted. The log level can represent the abnormal level of the log. For example, the log level can include debug, info, warning, error, etc. The business code can include one or more log levels. When generating a business log, a log of the log level contained in the business code can be generated.
[0062] When writing business code, users can place the log level in a preset code line. When obtaining the log level in the business code, you can locate the code line and directly extract the log level from the code line.
[0063] S203: If the log level in the business code is a preset log level, then according to the log printing function and the log level in the business code, character information at a preset position is determined from the business code as a monitoring item to be added.
[0064] Exemplarily, one or more log levels are pre-set as standard log levels. After obtaining the log level in the business code, it is determined whether the log level in the business code is a preset log level, that is, whether it is a standard log level. If so, the monitoring items to be added can be determined from the business code; if not, the monitoring items to be added cannot be extracted.
[0065] There can be multiple log levels in the business code, and each log level is judged in turn to see if it is a standard log level. If there is a log level in the business code that is a standard log level, the preset position corresponding to the log level in the business code can be determined according to the log printing function, and the character information located at the preset position can be determined from the business code as the monitoring item to be added. For example, the code line where the log level is located in the business code can be determined, and according to the log format represented by the log printing function, the preset position set in the log format can be found from the code line, and then the monitoring item to be added can be extracted from the position.
[0066] In this embodiment, the business code is statically detected to determine the preset log level contained in the business code, thereby avoiding confusion in monitoring items of all log levels, accurately determining monitoring items based on log levels, and improving the accuracy of determining monitoring items.
[0067] In this embodiment, the method also includes: if the log levels in the business code are not preset log levels, the monitoring items to be added are not extracted from the business code, and a first prompt message is sent to the user; wherein the first prompt message is used to remind the user to check the log level in the business code.
[0068] Specifically, each log level in the business code is compared with the preset log level. If each log level in the business code is not the preset log level, that is, it is not the standard log level, the monitoring item to be added cannot be extracted from the business code, and a first prompt message can be issued to the user. The first prompt message can be used to remind the user to check the log level in the business code. If the user determines that there is an error in the log level in the business code, the business code can be resubmitted to perform the business code detection and monitoring item extraction again. If the user determines that there is no problem with the business code, the monitoring item will not be extracted, and the business functions will be executed directly according to the business code and the business log will be generated.
[0069] The beneficial effect of this setting is that if the business code does not contain the preset log level, the monitoring item cannot be extracted, avoiding subsequent unnecessary operations, improving the efficiency of code detection, and thus improving the processing efficiency of monitoring items.
[0070] In this embodiment, according to the log printing function and the log level in the business code, the character information located at the preset position is determined from the business code as the monitoring item to be added, including: from the business code, determining the code line corresponding to the log level in the business code as the target code line; according to the log printing function, determining the character information located at the preset position from the target code line as the monitoring item to be added.
[0071] Specifically, the log level corresponds to different code lines in the business code, for example, info is on the first line, warning is on the second line, and error is on the third line. Determine the standard log level in the business code, and then determine the code line of the standard log level in the business code. That is, after determining that the log level in the business code is the standard log level, determine the code line corresponding to the log level from the business code as the target code line.
[0072] The log printing function can indicate the location of the parameter represented by the monitoring item in the code. Different log printing functions can correspond to different locations. For example, the parameter represented by the monitoring item in function one is the first parameter, and the parameter represented by the monitoring item in function two is the second parameter. After determining the target code line, determine the location of the parameter represented by the monitoring item in the code according to the target printing function as the preset location. Determine the character information at the preset location from the target code line as the monitoring item to be added. For example, get the first parameter from the error code line as the monitoring item to be added.
[0073] The beneficial effect of such a setting is that relevant parameters are obtained according to the log printing function, for example, the first parameter is obtained as the monitoring item to be added, so as to automatically determine the monitoring item, reduce manual operations, and improve the management efficiency and accuracy of the monitoring item.
[0074] In this embodiment, the method further includes: storing the monitoring item to be added in association with the log level in the business code.
[0075] Specifically, for different log levels, different monitoring items to be added can be extracted. The monitoring items to be added are determined to be extracted, and the log level corresponding to the monitoring items to be added is determined. The monitoring items to be added are associated with the corresponding log levels and stored.
[0076] The beneficial effect of such a setting is that different log levels can correspond to different monitoring items, which facilitates the subsequent monitoring of logs of different log levels and improves the accuracy of log monitoring.
[0077] In this embodiment, the method further includes: generating a log in a preset log format according to the log printing function as the log to be monitored; and extracting information corresponding to the monitoring item to be added from the log to be monitored according to the preset log format.
[0078] Specifically, when the business code is actually running to generate logs, a standardized log can be generated according to the preset structured log printing function, that is, a log in a preset log format is generated as a log to be monitored. In the log in the preset log format, information content of preset categories is written at different locations. For example, the first line in the log contains information about the flow size, and the second line of the log contains information about whether the service is overloaded, etc.
[0079] According to the preset log format, the corresponding position of the monitoring item to be added in the monitored log is determined, and the information corresponding to the monitoring item to be added is extracted at the corresponding position in the monitored log, that is, the content to be monitored is obtained. For example, the first to fourth characters of the first line in the monitored log can be extracted as the information content corresponding to the monitoring item to be added.
[0080] The beneficial effect of such a setting is that during actual monitoring, a log in a preset format can be generated, which facilitates quick acquisition of required information from the log, thereby improving the efficiency and accuracy of log monitoring.
[0081] In this embodiment, according to the preset log format, information corresponding to the monitoring item to be added is extracted from the log to be monitored, including: determining the log level of the log to be monitored; determining the monitoring item to be added that is associated with the log level of the log to be monitored as the target monitoring item; according to the preset log format, extracting information corresponding to the target monitoring item from the log to be monitored.
[0082] Specifically, after the log to be monitored is generated, the log level of the log to be monitored is determined. For example, the log to be monitored may be marked with a log level identifier, and the identifier is obtained to determine the log level of the log to be monitored. Different log levels are associated with different monitoring items. From the predetermined monitoring items to be added, the monitoring items associated with the log level of the log to be monitored are determined as the target monitoring items. One or more target monitoring items can be determined.
[0083] According to the preset log format, determine the location corresponding to the target monitoring item in the log to be monitored. Obtain the information corresponding to the target monitoring item recorded in the log from this location, that is, obtain the information to be monitored. You can also obtain the information corresponding to all monitoring items from the log to be monitored according to the preset log format, and then filter the information corresponding to the target monitoring item from the information corresponding to all monitoring items.
[0084] The log may contain the name or keyword of the monitoring item. According to the identifier of the target monitoring item, the string of preset length after the identifier can be searched from the log to be monitored as the information corresponding to the target monitoring item. For example, if the target monitoring item is the flow size, and the log to be monitored contains "flow size: more than 30% of the preset size", the four words "flow size" can be searched from the log to be monitored, and the ten characters after "flow size" can be determined as the information corresponding to the flow size.
[0085] The beneficial effect of such a setting is that, according to the log level of the log, the monitoring items that need to be monitored are determined, the targeted monitoring of the log is achieved, and the accuracy of log monitoring is improved.
[0086] In this embodiment, according to the preset log format, information corresponding to the target monitoring item is extracted from the log to be monitored, including: according to the preset log format, determining the position corresponding to the target monitoring item in the log to be monitored, which is the target position; extracting the information at the target position from the log to be monitored, which is the information corresponding to the target monitoring item.
[0087] Specifically, the log format is provided with the location of each monitoring item in the log. After the target monitoring item is determined, the location corresponding to the target monitoring item in the log to be monitored is found according to the preset log format as the target location.
[0088] Different target monitoring items correspond to different target locations. For each target monitoring item, the information at the target location is extracted from the log to be monitored as the information corresponding to the target monitoring item. Each target monitoring item and the corresponding information are displayed in association, for example, they can be displayed on the visual interface of the monitoring system for users to view. That is to say, after the monitoring items of the monitoring system are managed, when the log is actually generated, the log level of the log to be monitored is determined, and the monitoring items corresponding to the log level in the monitoring system are determined. According to the monitoring items in the monitoring system, the information in the log to be monitored is extracted and displayed.
[0089] The beneficial effect of such a setting is that the required information is obtained from the corresponding position in the log, redundancy of the obtained information is avoided, and the accuracy and efficiency of log monitoring are improved.
[0090] S204. Add the monitoring item to be added to the preset monitoring system by calling the preset interface; wherein the preset interface is used to transmit data with the preset monitoring system, and the preset monitoring system is used to monitor the content of the log according to the monitoring item.
[0091] Exemplarily, this step may refer to the above-mentioned step S103 and will not be described in detail.
[0092] In the disclosed embodiment, a business code uploaded by a user is received, and the business code includes a log printing function, through which the log can be printed in a preset log format. The detection of the business code is automatically triggered, and according to the log printing function, the character information located at a preset position is determined from the business code as the monitoring item to be added. By calling the preset interface, the monitoring item to be added is automatically added to the preset monitoring system, so that the preset monitoring system can monitor the content of the log according to the monitoring item. There is no need to manually sort out the monitoring items and add them to the monitoring system. By automatically determining the monitoring items and automatically adding them to the monitoring system, the efficiency of adding monitoring items can be improved, and the process of adding monitoring items can be reduced from the hour level to the second level, thereby improving the processing efficiency and accuracy of the monitoring items. It also avoids the problem of abnormalities occurring online due to manual omission of monitoring items, which cannot be discovered, thereby improving the efficiency and accuracy of monitoring.
[0093] Figure 3 A flowchart of a log-based monitoring item processing method provided in an embodiment of the present disclosure.
[0094] In this embodiment, the monitoring items to be added are added to the preset monitoring system by calling the preset interface, including: transmitting the monitoring items to be added to the preset monitoring system by calling the preset interface; wherein the preset monitoring system is configured with a visualization interface; storing the monitoring items to be added in the preset monitoring system and displaying them on the visualization interface.
[0095] like Figure 3 As shown, the method comprises the following steps:
[0096] S301, receiving a business code uploaded by a user; wherein the business code is used to generate a business log and output the business log in a preset log format, and the business code includes a log printing function, and the log printing function represents the preset log format.
[0097] Exemplarily, this step may refer to the above-mentioned step S101 and will not be described in detail.
[0098] S302. According to the log printing function, character information located at a preset position is determined from the business code as a monitoring item to be added.
[0099] Exemplarily, this step may refer to the above-mentioned step S102 and will not be described in detail.
[0100] S303. The monitoring item to be added is transmitted to the preset monitoring system by calling the preset interface; wherein the preset monitoring system is configured with a visual interface.
[0101] Exemplarily, an API interface of the monitoring system is pre-set, and the monitoring items to be added are transmitted to the preset monitoring system by calling the preset API interface. The monitoring system is configured with a visual interface, which can be used to display the monitoring items and the information in the log corresponding to the monitoring items subsequently extracted. In this embodiment, the transmission process of the monitoring items to be added is not specifically limited.
[0102] S304: Store the monitoring item to be added in a preset monitoring system and display it on a visual interface.
[0103] Exemplarily, the monitoring system receives the monitoring items to be added, stores the monitoring items to be added in the monitoring system, and can display the monitoring items to be added on a visual interface of the monitoring system. When storing the monitoring items to be added in the monitoring system, the monitoring system to be added can be associated with the log level for storage.
[0104] A table of monitoring items can be set up on the visual interface, and a row in the table can represent a monitoring item. After the user sees the extracted monitoring items through the visual interface, he can also modify or delete the extracted monitoring items according to actual business needs. For example, he can change the name and description of the monitoring items. If the user confirms that the monitoring items on the interface are correct, the logs will be monitored according to the monitoring items on the interface.
[0105] In this embodiment, the API of the monitoring system is called to automatically add monitoring items to the monitoring system, thereby reducing the user's adding operations, improving the management efficiency of monitoring items, and avoiding problems such as poor monitoring effects caused by manual omission of monitoring items.
[0106] Figure 4 Schematic diagram of the visual interface of the monitoring system. Figure 4 The "Error log monitoring items" in the table represent the monitoring items at the error log level, and the "Warning log monitoring items" represent the monitoring items at the warning log level. Figure 4 The displayed items are the monitoring items added for the error log level. The monitoring items to be added are "db error" and "actionrecover". Different monitoring items have their own descriptions, which are simple explanations of the meaning of the monitoring items. Users can click the "Edit" or "Delete" controls on the interface to operate the monitoring items. Users can also click the "Add" control to manually add monitoring items.
[0107] In the disclosed embodiment, a business code uploaded by a user is received, and the business code includes a log printing function, through which the log can be printed in a preset log format. The detection of the business code is automatically triggered, and according to the log printing function, the character information located at a preset position is determined from the business code as the monitoring item to be added. By calling the preset interface, the monitoring item to be added is automatically added to the preset monitoring system, so that the preset monitoring system can monitor the content of the log according to the monitoring item. There is no need to manually sort out the monitoring items and add them to the monitoring system. By automatically determining the monitoring items and automatically adding them to the monitoring system, the efficiency of adding monitoring items can be improved, and the process of adding monitoring items can be reduced from the hour level to the second level, thereby improving the processing efficiency and accuracy of the monitoring items. It also avoids the problem of abnormalities occurring online due to manual omission of monitoring items, which cannot be discovered, thereby improving the efficiency and accuracy of monitoring.
[0108] Figure 5 This is a structural block diagram of a log-based monitoring item processing device provided in an embodiment of the present disclosure. The monitoring item represents an item in the log that needs to be monitored. For ease of explanation, only the part related to the embodiment of the present disclosure is shown. Figure 5 The log-based monitoring item processing device 500 includes: a code receiving unit 501, a monitoring item determining unit 502 and a monitoring item adding unit 503.
[0109] The code receiving unit 501 is used to receive the service code uploaded by the user; wherein the service code is used to generate a service log and output the service log in a preset log format, and the service code includes a log printing function, and the log printing function represents the preset log format;
[0110] A monitoring item determination unit 502, configured to determine, according to the log printing function, character information located at a preset position from the business code as a monitoring item to be added;
[0111] The monitoring item adding unit 503 is used to add the monitoring item to be added to the preset monitoring system by calling the preset interface; wherein the preset interface is used to transmit data with the preset monitoring system, and the preset monitoring system is used to monitor the content of the log according to the monitoring item.
[0112] Figure 6 A structural block diagram of a log-based monitoring item processing device provided in an embodiment of the present disclosure, such as Figure 6 As shown, the log-based monitoring item processing device 600 includes a code receiving unit 601 , a monitoring item determining unit 602 and a monitoring item adding unit 603 , wherein the monitoring item determining unit 602 includes a level obtaining module 6021 and a monitoring item determining module 6022 .
[0113] The level acquisition module 6021 is used to acquire the log level in the business code; wherein the log level represents the abnormal level of the log;
[0114] The monitoring item determination module 6022 is used to determine the character information located at a preset position in the business code as the monitoring item to be added according to the log printing function and the log level in the business code if the log level in the business code is a preset log level.
[0115] In one example, the monitoring item determination module 6022 includes:
[0116] A code line determination submodule, used to determine, from the business code, a code line corresponding to a log level in the business code as a target code line;
[0117] The monitoring item determination submodule is used to determine the character information located at a preset position from the target code line according to the log printing function, which is the monitoring item to be added.
[0118] In one example, it also includes:
[0119] A storage unit is used to associate and store the monitoring item to be added with the log level in the business code.
[0120] In one example, it also includes:
[0121] A log generating unit, used for generating a log in the preset log format according to the log printing function, which is a log to be monitored;
[0122] The information extraction unit is used to extract the information corresponding to the monitoring item to be added from the log to be monitored according to the preset log format.
[0123] In one example, the information extraction unit includes:
[0124] A level determination module, used to determine the log level of the log to be monitored;
[0125] A target determination module, used to determine the monitoring item to be added that is associated with the log level of the log to be monitored as the target monitoring item;
[0126] The information determination module is used to extract information corresponding to the target monitoring item from the to-be-monitored log according to the preset log format.
[0127] In one example, the information determination module includes:
[0128] A position determination submodule, used to determine the position corresponding to the target monitoring item in the to-be-monitored log according to the preset log format, as the target position;
[0129] The information extraction submodule is used to extract the information at the target location from the log to be monitored, which is the information corresponding to the target monitoring item.
[0130] In one example, it also includes:
[0131] The first prompt unit is used for not extracting the monitoring items to be added from the business code if the log levels in the business code are not preset log levels, and sending a first prompt message to the user; wherein the first prompt message is used to remind the user to check the log level in the business code.
[0132] In one example, the monitoring item adding unit 603 includes:
[0133] A monitoring item transmission module, used to transmit the monitoring item to be added to the preset monitoring system by calling a preset interface; wherein the preset monitoring system is configured with a visual interface;
[0134] The monitoring item display module is used to store the monitoring items to be added in the preset monitoring system and display them on the visual interface.
[0135] In one example, it also includes:
[0136] The second prompt unit is used for not extracting the monitoring item to be added from the business code if the log printing function does not exist in the business code, and sending a second prompt message to the user; wherein, the second prompt message is used to remind the user to check the log printing function of the business code.
[0137] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device.
[0138] Figure 7 This is a structural block diagram of an electronic device provided in an embodiment of the present disclosure. The electronic device may be a terminal device, a processor or a server. Figure 7 As shown, the electronic device 70 includes: at least one processor 702; and a memory 701 communicatively connected to the at least one processor 702; wherein the memory stores instructions executable by the at least one processor 702, and the instructions are executed by the at least one processor 702 so that the at least one processor 702 can execute the log-based monitoring item processing method disclosed in the present invention.
[0139] The electronic device 70 further includes a receiver 703 and a transmitter 704. The receiver 703 is used to receive instructions and data sent by other devices, and the transmitter 704 is used to send instructions and data to external devices.
[0140] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0141] According to an embodiment of the present disclosure, the present disclosure also provides a computer program product, which includes: a computer program, the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the solution provided by any of the above embodiments.
[0142] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0143] like Figure 8As shown, the device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0144] A number of components in the device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0145] The computing unit 801 can be various general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as the processing method of the monitoring items based on the log. For example, in some embodiments, the processing method of the monitoring items based on the log can be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the processing method of the monitoring items based on the log described above can be executed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the log-based monitoring item processing method in any other appropriate manner (for example, by means of firmware).
[0146] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0147] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0148] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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 foregoing.
[0149] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0150] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0151] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0152] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0153] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for processing monitoring items based on logs, wherein the monitoring items represent items in the logs that need to be monitored. include: Receive a business code uploaded by a user; wherein the business code is used to generate a business log and output the business log in a preset log format, and the business code includes a log printing function, and the log printing function represents the preset log format; According to the log printing function, character information located at a preset position is determined from the business code as a monitoring item to be added; By calling a preset interface, the monitoring item to be added is added to a preset monitoring system; wherein the preset interface is used for data transmission with the preset monitoring system, and the preset monitoring system is used for monitoring the content of the log according to the monitoring item.
2. The method according to claim 1, in, The step of determining, according to the log printing function, character information at a preset position from the business code as a monitoring item to be added includes: Obtaining the log level in the business code; wherein the log level represents the abnormal level of the log; If the log level in the business code is a preset log level, character information located at a preset position is determined from the business code according to the log printing function and the log level in the business code as the monitoring item to be added.
3. The method according to claim 2, in, The step of determining, according to the log printing function and the log level in the business code, character information at a preset position from the business code as a monitoring item to be added includes: From the business code, determine the code line corresponding to the log level in the business code as the target code line; According to the log printing function, character information located at a preset position is determined from the target code line as a monitoring item to be added.
4. The method according to claim 3, further comprising: include: The monitoring item to be added is associated with the log level in the business code and stored.
5. The method according to claim 4, further comprising: include: According to the log printing function, a log in the preset log format is generated as the log to be monitored; According to the preset log format, information corresponding to the monitoring item to be added is extracted from the log to be monitored.
6. The method according to claim 5, in, The extracting information corresponding to the monitoring item to be added from the to-be-monitored log according to the preset log format includes: Determine the log level of the log to be monitored; Determine a monitoring item to be added that is associated with the log level of the log to be monitored as a target monitoring item; According to the preset log format, information corresponding to the target monitoring item is extracted from the log to be monitored.
7. The method according to claim 6, in, The extracting information corresponding to the target monitoring item from the to-be-monitored log according to the preset log format includes: According to the preset log format, determine the position corresponding to the target monitoring item in the log to be monitored as the target position; The information at the target location is extracted from the log to be monitored, which is the information corresponding to the target monitoring item.
8. The method according to any one of claims 2 to 7, further comprising: include: If the log levels in the business code are not the preset log levels, the monitoring items to be added will not be extracted from the business code, and a first prompt message will be sent to the user; wherein the first prompt message is used to remind the user to check the log level in the business code.
9. The method according to any one of claims 1 to 8, in, The step of adding the monitoring item to be added to the preset monitoring system by calling the preset interface includes: By calling a preset interface, the monitoring item to be added is transmitted to the preset monitoring system; wherein the preset monitoring system is configured with a visual interface; The monitoring items to be added are stored in the preset monitoring system and displayed on the visualization interface.
10. The method according to any one of claims 1 to 9, further comprising: include: If the log printing function does not exist in the business code, the monitoring item to be added will not be extracted from the business code, and a second prompt message will be sent to the user; wherein the second prompt message is used to remind the user to check the log printing function of the business code.
11. A device for processing monitoring items based on logs, wherein the monitoring items represent items in the logs that need to be monitored. include: A code receiving unit, used to receive a business code uploaded by a user; wherein the business code is used to generate a business log and output the business log in a preset log format, wherein the business code includes a log printing function, and the log printing function represents a preset log format; A monitoring item determination unit, used to determine, according to the log printing function, character information located at a preset position from the business code as a monitoring item to be added; The monitoring item adding unit is used to add the monitoring item to be added to the preset monitoring system by calling the preset interface; wherein the preset interface is used to transmit data with the preset monitoring system, and the preset monitoring system is used to monitor the content of the log according to the monitoring item.
12. The device according to claim 11, in, The monitoring item determination unit includes: A level acquisition module, used to acquire the log level in the business code; wherein the log level represents the abnormal level of the log; A monitoring item determination module is used to determine, if the log level in the business code is a preset log level, character information located at a preset position in the business code according to the log printing function and the log level in the business code, as a monitoring item to be added.
13. The device according to claim 12, in, The monitoring item determination module includes: A code line determination submodule, used to determine, from the business code, a code line corresponding to a log level in the business code as a target code line; The monitoring item determination submodule is used to determine the character information located at a preset position from the target code line according to the log printing function, which is the monitoring item to be added.
14. The device according to claim 13, further comprising: include: A storage unit is used to associate and store the monitoring item to be added with the log level in the business code.
15. The device according to claim 14, further comprising: include: A log generating unit, used for generating a log in the preset log format according to the log printing function, which is a log to be monitored; The information extraction unit is used to extract the information corresponding to the monitoring item to be added from the log to be monitored according to the preset log format.
16. The device according to claim 15, in, The information extraction unit comprises: A level determination module, used to determine the log level of the log to be monitored; A target determination module, used to determine the monitoring item to be added that is associated with the log level of the log to be monitored as the target monitoring item; The information determination module is used to extract information corresponding to the target monitoring item from the to-be-monitored log according to the preset log format.
17. The device according to claim 16, in, The information determination module comprises: A position determination submodule, used to determine the position corresponding to the target monitoring item in the to-be-monitored log according to the preset log format, as the target position; The information extraction submodule is used to extract the information at the target location from the log to be monitored, which is the information corresponding to the target monitoring item.
18. The device according to any one of claims 12 to 17, further comprising: include: The first prompt unit is used for not extracting the monitoring items to be added from the business code if the log levels in the business code are not preset log levels, and sending a first prompt message to the user; wherein the first prompt message is used to remind the user to check the log level in the business code.
19. The device according to any one of claims 11 to 18, in, The monitoring item adding unit includes: A monitoring item transmission module, used to transmit the monitoring item to be added to the preset monitoring system by calling a preset interface; wherein the preset monitoring system is configured with a visual interface; The monitoring item display module is used to store the monitoring items to be added in the preset monitoring system and display them on the visual interface.
20. The device according to any one of claims 11 to 19, further comprising: include: The second prompt unit is used for not extracting the monitoring items to be added from the business code if the log printing function does not exist in the business code, and sending a second prompt message to the user; wherein the second prompt message is used to remind the user to check the log printing function of the business code.
21. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.
22. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-10.
23. A computer program product, in, The invention comprises a computer program, which implements the steps of the method according to any one of claims 1 to 10 when being executed by a processor.
Citation Information
Patent Citations
Log generation method and device
CN107193721A
Log information analysis method and device, computer equipment and storage medium
CN111475324A
Log monitoring adding method and device, computer equipment and storage medium
CN111475369A
Automatic log classification method and device and computer readable storage medium
CN113312485A
Log printing response method and device, electronic equipment and storage medium
CN113553578A
