Traffic recording method and device, electronic equipment and storage medium

By dynamically analyzing and adjusting the sampling rate of the traffic interface, the problem of fixed sampling rate in the prior art resulting in low traffic recording coverage is solved, and a more comprehensive traffic recording effect is achieved.

CN119728468APending Publication Date: 2025-03-28BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411829810.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the prior art, a fixed universal sampling rate is used for traffic recording, resulting in low traffic recording coverage and the inability to effectively capture interface traffic with small requests.

Method used

By receiving traffic information and obtaining corresponding recording configuration information, determining the target interface identification and interface status information, combining these information for sampling rate analysis, dynamically determining the interface sampling rate of each traffic interface, and thus recording.

Benefits of technology

Improve the coverage of traffic recording, ensure full recording of all interface traffic, and avoid the problem of incomplete traffic recording coverage due to fixed sampling rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728468A_ABST
    Figure CN119728468A_ABST
Patent Text Reader

Abstract

The invention relates to a traffic recording method and device, electronic equipment and a storage medium, and the traffic recording method comprises the steps: receiving traffic information according to a traffic recording starting instruction, obtaining recording configuration information according to a traffic interface corresponding to the traffic information, so as to determine a target interface identifier and interface state information corresponding to the traffic interface, according to the target interface identification and the interface state information, sampling rate analysis is carried out in combination with the recording configuration information, an interface sampling rate corresponding to the flow interface is determined, then the interface sampling rate is adopted to record the flow information, and a flow recording result is obtained; therefore, the purpose of configuring different interface sampling rates for each flow interface is achieved, the problem that the flow recording coverage rate is low when a fixed general sampling rate is adopted for flow recording in the prior art is solved, and the flow recording coverage rate can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a traffic recording method, device, electronic device and storage medium. Background Art

[0002] With the development of the Internet, the number and functions of applications are gradually increasing. In order to ensure that applications can run accurately and effectively, traffic recording is usually required. Traffic recording is a means of capturing network communication data, specifically collecting client-to-server traffic. It can be used for a variety of purposes, such as performance analysis, troubleshooting, and regression testing.

[0003] In the process of traffic recording in the existing related technologies, in order to reduce the impact on application services, a fixed general sampling rate is usually set to reduce the sampling frequency. However, in real business scenarios, traffic is usually unevenly distributed. Some interfaces may have a large number of requests, while some interfaces may have a small number of requests. A single sampling rate will cause a large amount of interface traffic with a large number of requests to be recorded, but the interface traffic with a small number of requests cannot be recorded or only a small amount of traffic can be recorded; that is, using a fixed general sampling rate for traffic recording will result in a low traffic recording coverage problem. Summary of the invention

[0004] In order to solve the problem of low traffic recording coverage when using a fixed universal sampling rate for traffic recording in the existing related technologies, the present application provides a traffic recording method, device, electronic device and storage medium.

[0005] In a first aspect, the present application provides a traffic recording method, comprising:

[0006] Receive traffic information according to the traffic recording start command;

[0007] Acquire recording configuration information according to the flow interface corresponding to the flow information;

[0008] Determine the target interface identifier and interface status information corresponding to the traffic interface;

[0009] Based on the target interface identifier and the interface status information, a sampling rate analysis is performed in combination with the recording configuration information to determine an interface sampling rate corresponding to the traffic interface;

[0010] The flow information is recorded using the interface sampling rate to obtain a flow recording result.

[0011] Optionally, the performing sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine the interface sampling rate corresponding to the traffic interface includes:

[0012] Acquire recording history information according to the interface status information;

[0013] Determine whether there is historical traffic information corresponding to the target interface identifier in the recorded historical information;

[0014] If the historical traffic information exists in the recorded history information, a sampling rate analysis is performed based on the number of interface recordings corresponding to the traffic interface in combination with the recording configuration information and the interface status information to determine the interface sampling rate corresponding to the traffic interface.

[0015] Optionally, after determining whether the recorded history information contains the history traffic information corresponding to the target interface identifier, the method further includes:

[0016] If the historical traffic information does not exist in the recorded historical information, directly record the traffic information to obtain a traffic recording result;

[0017] Generate historical traffic information corresponding to the target interface identifier according to the traffic recording result;

[0018] And add the historical traffic information to the recorded historical information.

[0019] Optionally, the performing sampling rate analysis based on the number of interface recordings corresponding to the traffic interface in combination with the recording configuration information and the interface status information to determine the interface sampling rate corresponding to the traffic interface includes:

[0020] Determine the number of interface recordings corresponding to the target interface identifier according to the recording history information;

[0021] Based on the recording configuration information, determining an interface recording threshold corresponding to the target interface identifier;

[0022] When the number of interface recordings does not reach the interface recording threshold, extracting a preset sampling rate corresponding to the target interface identifier from the recording configuration information;

[0023] The preset sampling rate is determined as the interface sampling rate.

[0024] Optionally, extracting the preset sampling rate corresponding to the target interface identifier from the recording configuration information includes:

[0025] Extracting a common sampling rate, at least one preset sampling rate, and a preset interface identifier corresponding to each preset sampling rate from the recording configuration information;

[0026] When the target interface identifier matches the preset interface identifier, extracting the preset sampling rate corresponding to the preset interface identifier;

[0027] In a case where the target interface identifier does not match the preset interface identifier, the universal sampling rate is determined as the interface sampling rate.

[0028] Optionally, acquiring recording configuration information according to a traffic interface corresponding to the traffic information includes:

[0029] According to the traffic interface, sending a configuration request to the server;

[0030] Receive the recording configuration information sent by the server, and save the recording configuration information to a local service cache.

[0031] Optionally, after saving the recording configuration information to the local service cache, the method further includes:

[0032] Receive recording configuration modification information;

[0033] The recording configuration information in the local service cache is modified and updated according to the recording configuration modification information to obtain the modified and updated recording configuration information.

[0034] In a second aspect, a flow recording device is provided, comprising:

[0035] A module, used for receiving flow information according to a flow recording start instruction;

[0036] An acquisition module, used to acquire recording configuration information according to a flow interface corresponding to the flow information;

[0037] A determination module, used to determine the target interface identifier and interface status information corresponding to the traffic interface;

[0038] A sampling rate analysis module, configured to perform sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine an interface sampling rate corresponding to the traffic interface;

[0039] The recording module is used to record the flow information using the interface sampling rate to obtain a flow recording result.

[0040] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0041] Memory, used to store computer programs;

[0042] The processor is used to implement the traffic recording method described in any one of the first aspects when executing the program stored in the memory.

[0043] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the traffic recording method as described in any one of the first aspects is implemented.

[0044] The embodiment of the present application receives traffic information according to a traffic recording start instruction, obtains recording configuration information according to the traffic interface corresponding to the traffic information, so as to determine the target interface identifier and interface status information corresponding to the traffic interface, and performs sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine the interface sampling rate corresponding to the traffic interface, and then records the traffic information using the interface sampling rate to obtain the traffic recording result; thereby achieving the purpose of configuring different interface sampling rates for each traffic interface, solving the problem of low traffic recording coverage rate in the existing related technology when using a fixed universal sampling rate for traffic recording, and being able to effectively improve the coverage rate of traffic recording. BRIEF DESCRIPTION OF THE DRAWINGS

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

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

[0047] Figure 1 A flow chart of a traffic recording method provided in an embodiment of the present application;

[0048] Figure 2 A schematic diagram of the structure of a flow recording device provided in an embodiment of the present application;

[0049] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0051] After the application is put into use, in order to perform performance analysis, troubleshooting, regression testing and other test analyses on the application, it is necessary to collect the client-server traffic during the operation of the application, that is, traffic recording. Through the traffic recording data, various tests and inspections of the application can be performed; that is, whether the traffic recording data is comprehensive will directly affect the accuracy of subsequent performance analysis, troubleshooting, regression testing and other test analyses; and in the existing related technology, a fixed universal sampling rate is set to uniformly record and collect all traffic on the server. At this time, the traffic of some interfaces will be recorded more, and the traffic of some interfaces will be recorded less or cannot be recorded, that is, the final traffic recording data will be incomplete, resulting in low accuracy of test analyses such as performance analysis, troubleshooting and regression testing, that is, using a fixed universal sampling rate for traffic recording will result in a low traffic recording coverage rate.

[0052] In order to solve the problem of low traffic recording coverage when using a fixed universal sampling rate for traffic recording in the existing related technology, the present application provides a traffic recording method, device, electronic device and storage medium, which receives traffic information according to a traffic recording start instruction, obtains recording configuration information according to the traffic interface corresponding to the traffic information, determines the target interface identifier and interface status information corresponding to the traffic interface, and performs sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine the interface sampling rate corresponding to the traffic interface, and then records the traffic information using the interface sampling rate to obtain the traffic recording result; thereby achieving the purpose of configuring different interface sampling rates for each traffic interface, solving the problem of low traffic recording coverage when using a fixed universal sampling rate for traffic recording in the existing related technology, and can effectively improve the coverage of traffic recording.

[0053] Figure 1 A flow chart of a method for determining a verification method provided in an embodiment of the present application. The method can be applied to one or more electronic devices such as a client and a server. In addition, the execution subject of the method can be hardware or software. When the above-mentioned execution subject is hardware, the execution subject can be one or more of the above-mentioned electronic devices. For example, a single electronic device can execute the method, or a plurality of electronic devices can cooperate with each other to execute the method. When the above-mentioned execution subject is software, the method can be implemented as a plurality of software or software modules, or as a single software or software module. No specific limitation is made herein.

[0054] like Figure 1 As shown, the present application discloses an embodiment, providing a traffic recording method, which may specifically include the following steps:

[0055] Step S110: Receive traffic information according to the traffic recording start instruction.

[0056] Specifically, the traffic recording start instruction in this embodiment can represent an instruction for starting traffic recording, which can be input by the tester according to the needs, so that traffic information can be received according to the traffic recording start instruction. The traffic information can represent various types of information received through preset reception, such as access information, query information, etc. This embodiment does not make specific limitations on this.

[0057] Step S120: Acquire recording configuration information according to the traffic interface corresponding to the traffic information.

[0058] Specifically, after receiving the traffic information, the traffic interface corresponding to the traffic information can be determined, where the traffic interface can be an interface for receiving the traffic information, such as an application programming interface (Application Programming Interface, API); thereby, the recording configuration information can be obtained, and the recording configuration information represents the configuration information pre-configured for recording the traffic information. The specific acquisition method can be obtained from the back-end database or from the cache, and this embodiment does not make any specific limitations on this.

[0059] Step S130: Determine the target interface identifier and interface status information corresponding to the traffic interface.

[0060] Specifically, after determining the traffic interface, the target interface identifier and interface status information corresponding to the traffic interface can be determined, wherein the target interface identifier can represent an identifier used to mark the traffic interface, and the interface status information can represent whether the traffic interface is in a state that requires recording, that is, the interface status information can be a state that requires recording or a state that does not require recording, wherein the state that requires recording can represent that the traffic interface is in a state that requires traffic recording.

[0061] Step S140: Based on the target interface identifier and the interface status information, a sampling rate analysis is performed in combination with the recording configuration information to determine the interface sampling rate corresponding to the traffic interface.

[0062] Specifically, after obtaining the interface status information, it can be determined whether the interface status information is in a state where recording is required. When the interface status information is in a state where recording is not required, it indicates that the traffic interface does not require traffic recording, and there is no need to execute subsequent steps at this time; and when the interface status information is in a state where recording is required, it indicates that the traffic interface requires traffic recording. At this time, the sampling rate analysis can be performed in combination with the target interface identifier and the recording configuration information to determine the interface sampling rate corresponding to the traffic interface, wherein the interface sampling rate can represent the probability of sampling the traffic of the traffic interface, for example, the interface sampling rate A of traffic interface A is 10%, and the interface sampling rate B of traffic interface B is 15%. At this time, there is a 10% probability of recording and collecting the traffic of traffic interface A, and a 15% probability of recording and collecting the traffic of traffic interface B. It should be noted that the present embodiment may include multiple traffic interfaces, and the interface sampling rates corresponding to different traffic interfaces may be the same or different, and the present embodiment does not make specific limitations on this.

[0063] Specifically, the sampling rate analysis method in this embodiment can be determined by directly extracting the interface sampling rate corresponding to the target interface identifier from the recording configuration information, or by combining the recording history information to determine the interface sampling rate corresponding to the target interface identifier. Of course, other methods can also be used to determine it, and this embodiment does not make specific limitations on this.

[0064] It can be seen that in this embodiment, the interface sampling rate corresponding to each traffic interface can be determined through the target interface identifier, interface status information and recording configuration information, so that each traffic interface is recorded with an appropriate interface sampling rate, thereby avoiding the problem of incomplete coverage of traffic recording and effectively improving the coverage of traffic recording.

[0065] Step S130: Record the traffic information using the interface sampling rate to obtain a traffic recording result.

[0066] Specifically, after determining the interface sampling rate, the interface sampling rate can be used to record the traffic information to obtain a traffic recording result. The traffic recording result is used to represent the result obtained by recording the traffic information, that is, the traffic recording result can be a stored recording result of a successful recording or a discarded result of not recording. This embodiment does not make any specific limitations on this.

[0067] It can be seen that the traffic recording method in this embodiment can be applied to a server to perform traffic recording in the server; specifically, according to the traffic recording start instruction, traffic information can be received, and according to the traffic interface corresponding to the traffic information, recording configuration information can be obtained to determine the target interface identifier and interface status information corresponding to the traffic interface, and based on the target interface identifier and the interface status information, combined with the recording configuration information, a sampling rate analysis is performed to determine the interface sampling rate corresponding to the traffic interface, and then the traffic information is recorded using the interface sampling rate to obtain a traffic recording result; thereby achieving the purpose of configuring different interface sampling rates for each traffic interface, solving the problem of low traffic recording coverage in the existing related technology using a fixed universal sampling rate for traffic recording, and effectively improving the coverage of traffic recording; that is, the interface sampling rate of the traffic interface is configured through the recording configuration information, so as to achieve flexible control of traffic recording. For example, for a traffic interface with high traffic, the interface sampling rate of the traffic interface can be reduced to reduce the system load, and for an important traffic interface, the sampling rate of the traffic interface can be increased to ensure complete traffic records, which can greatly improve the diversity of recorded traffic and avoid the problem of incomplete coverage of traffic recording.

[0068] In an optional embodiment of the present application, step S140 performs a sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine the interface sampling rate corresponding to the traffic interface, and may specifically include the following sub-steps: obtaining recording history information based on the interface status information; determining whether there is historical traffic information corresponding to the target interface identifier in the recording history information; if there is historical traffic information in the recording history information, performing a sampling rate analysis based on the number of interface recordings corresponding to the traffic interface in combination with the recording configuration information and the interface status information to determine the interface sampling rate corresponding to the traffic interface.

[0069] In this embodiment, after determining the target interface identifier and interface status information corresponding to the flow information, the recording history information can be obtained, and the recording history information can represent the record information of the historically recorded flow information; then it can be determined whether there is historical flow information corresponding to the target interface identifier in the recording history information, and the historical flow information represents the flow information collected by the historical recording corresponding to the target interface identifier, that is, the flow information collected by the historical recording of the flow interface. It can be seen that in this embodiment, by judging whether there is historical flow information corresponding to the flow interface in the recording history information, it can be used to judge whether the flow information corresponding to the target interface identifier has been recorded and collected, that is, if there is historical flow information in the recording history information, it can be determined that the flow information corresponding to the target interface identifier has been recorded and collected. At this time, based on the number of interface recordings corresponding to the flow interface, the sampling rate analysis is performed in combination with the recording configuration information and the interface status information to determine the interface sampling rate corresponding to the flow interface.

[0070] In an optional embodiment of the present application, after determining whether there is historical traffic information corresponding to the target interface identifier in the recorded history information, it may also include: if there is no historical traffic information in the recorded history information, directly recording the traffic information to obtain the traffic recording result; based on the traffic recording result, generating historical traffic information corresponding to the target interface identifier; and adding the historical traffic information to the recorded history information.

[0071] In this embodiment, when there is no historical traffic information in the recorded history information, it can be determined that the traffic information corresponding to the target interface identifier has not been recorded and collected. At this time, the traffic information can be directly recorded to obtain the traffic recording result, thereby achieving the purpose of recording and collecting the first traffic information received by the traffic interface that has not recorded and collected traffic information. Therefore, based on the traffic recording result, the historical traffic information corresponding to the target interface identifier can be generated, and the historical traffic information can be added to the recorded history information. Then, when the traffic information corresponding to the traffic interface is received next time, it can be determined whether the historical traffic information corresponding to the target interface identifier exists in the recorded history information, thereby achieving accurate recording only when the traffic information of the traffic interface is received for the first time, and sampling can be performed according to the subsequent steps when the traffic information of the traffic interface is received again.

[0072] It can be seen that in this embodiment, when there is no historical traffic information in the recorded historical information, the traffic information is directly recorded to obtain the traffic recording result. Therefore, when an interface has never been recorded and collected, the first traffic information received by the interface can be directly recorded and collected. This can ensure that no interface is missed for traffic information recording and collection, and prevent the problem of incomplete traffic recording coverage due to failure to record traffic information of some interfaces, which can effectively improve the coverage rate of traffic recording.

[0073] In an optional embodiment of the present application, based on the number of interface recordings corresponding to the traffic interface, a sampling rate analysis is performed in combination with the recording configuration information and the interface status information to determine the step of determining the interface sampling rate corresponding to the traffic interface. The step may specifically include the following sub-steps: determining the number of interface recordings corresponding to the target interface identifier based on the recording history information; determining the interface recording threshold corresponding to the target interface identifier based on the recording configuration information; when the number of interface recordings does not reach the interface recording threshold, extracting the preset sampling rate corresponding to the target interface identifier from the recording configuration information; and determining the preset sampling rate as the interface sampling rate.

[0074] In this embodiment, there is historical traffic information in the recording history information, and it can be determined that the traffic information corresponding to the target interface identifier has been recorded and collected. At this time, the interface recording times corresponding to the target interface identifier can be determined based on the recording history information. The interface recording times can indicate the number of times the traffic received marked by the target interface identifier is recorded. The specific determination method can be to count the number of traffic information in the historical traffic information to obtain the interface recording times; then, the interface recording threshold corresponding to the target interface identifier can be determined based on the recording configuration information. In addition to the interface sampling rate, the recording configuration information can also include the interface recording threshold corresponding to the target interface identifier. The interface recording threshold can indicate the maximum recording amount corresponding to a single traffic interface. The specific acquisition method can be to extract the interface recording threshold corresponding to the target interface identifier from the recording configuration information; thereby, it can be determined whether the interface recording times reaches the interface recording threshold. When the interface recording times does not reach the interface recording threshold, it means that the traffic recording of the traffic interface can continue at this time. At this time, the preset sampling rate corresponding to the target interface identifier can be extracted from the recording configuration information. The preset sampling rate can indicate the sampling rate pre-configured for each traffic interface, and then the preset sampling rate can be determined as the interface sampling rate. Subsequently, the traffic information can be recorded according to the sampling rate of the interface; when the number of interface recordings reaches the interface recording threshold, it means that the number of interface recordings has reached the maximum recording amount of the traffic interface. At this time, there is no need to record the traffic information, that is, the traffic information can be discarded, thereby limiting the number of recordings for each traffic interface, avoiding a large number of recordings on a single traffic interface and the problem of uneven traffic recording coverage, which can effectively improve the coverage balance of traffic recording.

[0075] In an optional embodiment of the present application, the interface sampling rate corresponding to the traffic interface is extracted from the recording configuration information, which may specifically include the following sub-steps: extracting the general sampling rate, at least one preset sampling rate, and the preset interface identifier corresponding to each preset sampling rate from the recording configuration information; determining the target interface identifier corresponding to the traffic information; when the target interface identifier matches the preset interface identifier, extracting the preset sampling rate corresponding to the preset interface identifier; when the target interface identifier does not match the preset interface identifier, determining the general sampling rate as the interface sampling rate.

[0076] In this embodiment, when the number of interface recordings does not reach the interface recording threshold, the general sampling rate, at least one preset sampling rate, and the preset interface identifier corresponding to each preset sampling rate can be extracted from the recording configuration information, wherein the general sampling rate represents the sampling rate common to conventional interfaces, and the preset interface identifier represents the traffic interface identifier pre-configured to correspond to the preset sampling rate; then the target interface identifier corresponding to the traffic information can be determined, wherein the target interface identifier represents the identifier corresponding to the traffic interface that receives the traffic information; thereby, the target interface identifier can be compared with each preset interface identifier to determine whether they match. When the target interface identifier matches the preset interface identifier, the preset sampling rate corresponding to the preset interface identifier can be extracted; and when the target interface identifier does not match the preset interface identifier, the general sampling rate can be directly determined as the interface sampling rate.

[0077] Since there are multiple businesses in the server, and each business may have a large number of interfaces, if all interfaces are configured with their corresponding preset sampling rates, the workload will be too large and is not suitable for specific implementation. In this embodiment, the corresponding preset sampling rates are configured for some traffic interfaces, and a universal sampling rate is uniformly used for other conventional interfaces. This can solve the problem of needing to configure the corresponding preset sampling rates for all interfaces, which is too much of a workload, and also avoids the unreasonable strategy of recording all or not recording any interfaces that are not configured with the corresponding preset sampling rates, which can effectively improve the efficiency of interface recording.

[0078] In an optional embodiment of the present application, recording configuration information is obtained according to the traffic interface corresponding to the traffic information, which may specifically include the following sub-steps: sending a configuration request to the server based on the traffic interface; receiving the recording configuration information sent by the server, and saving the recording configuration information to the local service cache.

[0079] In this embodiment, after receiving the flow information, the flow interface corresponding to the flow information can be determined, and based on the flow interface, a configuration request can be sent to the server, so that the server responds to the configuration request and feeds back recording configuration information. The recording configuration information can be configured and generated in advance according to the needs and stored in the server, or it can be configured and generated according to the implementation scenario and stored in the server. This embodiment does not make specific limitations on this; when receiving the recording configuration information sent by the server, the recording configuration information can be saved in the local service cache, so that when the flow information is received, the flow information can be recorded based on the recording configuration information.

[0080] In an optional embodiment of the present application, after the recording configuration information is saved to the local service cache, the following sub-steps may be specifically included: receiving recording configuration modification information; modifying and updating the recording configuration information in the local service cache based on the recording configuration modification information to obtain the modified and updated recording configuration information.

[0081] In this embodiment, after the recording configuration information is saved to the local service cache, it can also be determined whether recording configuration modification information is received. The recording configuration modification information represents information used to modify and adjust the recording configuration information. The specific input method of the recording configuration modification information can be input by the user according to specific scene changes or demand changes, or it can be adaptively generated according to scene changes or acquisition conditions. This embodiment does not specifically limit this. Then, the recording configuration information in the local service cache can be modified and updated according to the recording configuration modification information to obtain the modified and updated recording configuration information. The specific recording configuration modification information can include one or more of the interface recording threshold modification information, the general sampling rate modification information, and the preset sampling rate modification information. The method comprises the following steps: wherein the interface recording threshold modification information represents information for modifying the interface recording threshold, the general sampling rate modification information represents information for modifying the general sampling rate, and the preset sampling rate modification information represents information for modifying the preset sampling rate, thereby playing the role of dynamically adjusting and modifying the recording configuration information in real time during the flow recording process through the recording configuration modification information, and then the modified and updated recording configuration information can be used to continue to execute the subsequent steps based on the recording configuration information to determine the interface sampling rate corresponding to the flow interface, the flow interface being an interface for receiving flow information, and the interface sampling rate being used to record the flow information to obtain the flow recording result step, thereby achieving the effect of dynamically adjusting the flow recording sampling method.

[0082] like Figure 2 As shown, the present application also discloses an embodiment, providing a traffic recording device, including:

[0083] A receiving module 210 is used to receive flow information according to a flow recording start instruction;

[0084] An acquisition module 220, configured to acquire recording configuration information according to a flow interface corresponding to the flow information;

[0085] A determination module 230, configured to determine a target interface identifier and interface status information corresponding to the traffic interface;

[0086] A sampling rate analysis module 240, configured to perform sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine an interface sampling rate corresponding to the traffic interface;

[0087] The recording module 250 is used to record the flow information using the interface sampling rate to obtain a flow recording result.

[0088] In an optional embodiment of the present application, the sampling rate analysis module 240 may include:

[0089] A first acquisition unit, used to acquire recording history information according to the interface status information;

[0090] A first determining unit, configured to determine whether there is historical traffic information corresponding to the target interface identifier in the recorded historical information;

[0091] The second determination unit is used to determine the interface sampling rate corresponding to the traffic interface by performing sampling rate analysis based on the number of interface recordings corresponding to the traffic interface, in combination with the recording configuration information and the interface status information, if the historical traffic information exists in the recording history information.

[0092] In an optional embodiment of the present application, the sampling rate analysis module 240 may further include:

[0093] A recording unit, configured to directly record the traffic information if the historical traffic information does not exist in the recorded historical information, to obtain a traffic recording result;

[0094] A generating unit, configured to generate historical traffic information corresponding to the target interface identifier according to the traffic recording result;

[0095] The adding unit is used to add the historical traffic information to the recorded historical information.

[0096] In an optional embodiment of the present application, the second determining unit may include:

[0097] A first determining subunit, configured to determine the number of interface recordings corresponding to the target interface identifier according to the recording history information;

[0098] A second determining subunit, configured to determine an interface recording threshold corresponding to the target interface identifier based on the recording configuration information;

[0099] A first extraction subunit is used to extract the preset sampling rate corresponding to the target interface identifier from the recording configuration information when the number of interface recordings does not reach the interface recording threshold;

[0100] The third determining subunit is configured to determine the preset sampling rate as the interface sampling rate.

[0101] In an optional embodiment of the present application, the first extraction subunit may include:

[0102] A second extraction subunit is used to extract a common sampling rate, at least one preset sampling rate, and a preset interface identifier corresponding to each preset sampling rate from the recording configuration information;

[0103] A third extraction subunit is used to extract the preset sampling rate corresponding to the preset interface identifier when the target interface identifier matches the preset interface identifier;

[0104] The fourth determining subunit is configured to determine the universal sampling rate as the interface sampling rate when the target interface identifier does not match the preset interface identifier.

[0105] In an optional embodiment of the present application, the acquisition module 220 may include:

[0106] A sending unit, used for sending a configuration request to a server according to the traffic interface;

[0107] The storage unit is used to receive the recording configuration information sent by the server and save the recording configuration information to a local service cache.

[0108] In an optional embodiment of the present application, the acquisition module 220 may further include:

[0109] A receiving unit, used for receiving recording configuration modification information;

[0110] The modification and updating unit is used to modify and update the recording configuration information in the local service cache according to the recording configuration modification information to obtain the modified and updated recording configuration information.

[0111] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0112] like Figure 3 As shown, an embodiment of the present application provides an electronic device, including a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340;

[0113] Memory 330, for storing computer programs;

[0114] In one embodiment of the present application, the processor 310 is used to execute the program stored in the memory 330 to implement the traffic recording method provided by any of the aforementioned method embodiments, receive traffic information according to the traffic recording start instruction, obtain recording configuration information according to the traffic interface corresponding to the traffic information to determine the target interface identifier and interface status information corresponding to the traffic interface, and perform sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine the interface sampling rate corresponding to the traffic interface, and then use the interface sampling rate to record the traffic information to obtain the traffic recording result; thereby The purpose of configuring different interface sampling rates for each traffic interface is achieved, and the problem of low traffic recording coverage rate in the existing related technology using a fixed general sampling rate for traffic recording is solved, and the coverage rate of traffic recording can be effectively improved; that is, the interface sampling rate of the traffic interface is configured through the recording configuration information, and flexible control of traffic recording is achieved. For example, for a traffic interface with high traffic, the interface sampling rate of the traffic interface can be reduced to reduce the system load, and for an important traffic interface, the sampling rate of the traffic interface can be increased to ensure complete traffic records, which can greatly improve the diversity of recorded traffic and avoid the problem of incomplete coverage of traffic recording.

[0115] The embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the flow recording method provided in any of the aforementioned method embodiments is implemented, and flow information is received according to a flow recording start instruction. According to the flow interface corresponding to the flow information, recording configuration information is obtained to determine the target interface identifier and interface status information corresponding to the flow interface, and based on the target interface identifier and the interface status information, a sampling rate analysis is performed in combination with the recording configuration information to determine the interface sampling rate corresponding to the flow interface, and then the flow information is recorded using the interface sampling rate to obtain a flow recording. Result; thereby achieving the purpose of configuring different interface sampling rates for each traffic interface, solving the problem of low traffic recording coverage rate in the existing related technology that adopts a fixed general sampling rate for traffic recording, and being able to effectively improve the coverage rate of traffic recording; that is, the interface sampling rate of the traffic interface is configured through the recording configuration information, thereby realizing flexible control of traffic recording. For example, for a traffic interface with high traffic, the interface sampling rate of the traffic interface can be reduced to reduce the system load, and for an important traffic interface, the sampling rate of the traffic interface can be increased to ensure complete traffic records, which can greatly improve the diversity of recorded traffic and avoid the problem of incomplete coverage of traffic recording.

[0116] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0117] The above describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0118] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A traffic recording method, characterized in that: include: Receive traffic information according to the traffic recording start command; Acquire recording configuration information according to the flow interface corresponding to the flow information; Determine the target interface identifier and interface status information corresponding to the traffic interface; Based on the target interface identifier and the interface status information, a sampling rate analysis is performed in combination with the recording configuration information to determine an interface sampling rate corresponding to the traffic interface; The flow information is recorded using the interface sampling rate to obtain a flow recording result.

2. The traffic recording method according to claim 1, characterized in that: The performing sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine the interface sampling rate corresponding to the traffic interface includes: Acquire recording history information according to the interface status information; Determine whether there is historical traffic information corresponding to the target interface identifier in the recorded historical information; If the historical traffic information exists in the recorded history information, a sampling rate analysis is performed based on the number of interface recordings corresponding to the traffic interface in combination with the recording configuration information and the interface status information to determine the interface sampling rate corresponding to the traffic interface.

3. The traffic recording method according to claim 2, characterized in that: After determining whether the recorded history information contains the history traffic information corresponding to the target interface identifier, the method further includes: If the historical traffic information does not exist in the recorded historical information, directly record the traffic information to obtain a traffic recording result; Generate historical traffic information corresponding to the target interface identifier according to the traffic recording result; And add the historical traffic information to the recorded historical information.

4. The traffic recording method according to claim 2, characterized in that: The performing sampling rate analysis based on the number of interface recordings corresponding to the traffic interface in combination with the recording configuration information and the interface status information to determine the interface sampling rate corresponding to the traffic interface includes: Determine the number of interface recordings corresponding to the target interface identifier according to the recording history information; Based on the recording configuration information, determining an interface recording threshold corresponding to the target interface identifier; When the number of interface recordings does not reach the interface recording threshold, extracting a preset sampling rate corresponding to the target interface identifier from the recording configuration information; The preset sampling rate is determined as the interface sampling rate.

5. The traffic recording method according to claim 4, characterized in that: The step of extracting the preset sampling rate corresponding to the target interface identifier from the recording configuration information includes: Extracting a common sampling rate, at least one preset sampling rate, and a preset interface identifier corresponding to each preset sampling rate from the recording configuration information; When the target interface identifier matches the preset interface identifier, extracting the preset sampling rate corresponding to the preset interface identifier; In a case where the target interface identifier does not match the preset interface identifier, the universal sampling rate is determined as the interface sampling rate.

6. The traffic recording method according to claim 1, characterized in that: The acquiring recording configuration information according to the flow interface corresponding to the flow information includes: According to the traffic interface, sending a configuration request to the server; Receive the recording configuration information sent by the server, and save the recording configuration information to a local service cache.

7. The traffic recording method according to claim 6, characterized in that: After the recording configuration information is saved in the local service cache, the method further includes: Receive recording configuration modification information; The recording configuration information in the local service cache is modified and updated according to the recording configuration modification information to obtain the modified and updated recording configuration information.

8. A flow recording device, characterized in that: include: A module, used for receiving flow information according to a flow recording start instruction; An acquisition module, used to acquire recording configuration information according to a flow interface corresponding to the flow information; A determination module, used to determine the target interface identifier and interface status information corresponding to the traffic interface; A sampling rate analysis module, configured to perform sampling rate analysis based on the target interface identifier and the interface status information in combination with the recording configuration information to determine an interface sampling rate corresponding to the traffic interface; The recording module is used to record the flow information using the interface sampling rate to obtain a flow recording result.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor is used to implement the traffic recording method described in any one of claims 1-7 when executing the program stored in the memory.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the traffic recording method as described in any one of claims 1 to 7 is implemented.