Log information transmission method and device and storage medium
By generating log information subscription identifiers and establishing SSE long connections, dynamically adjusting the log information content, the problem that the syslog protocol is difficult to change the reported content in a timely manner according to the needs of the log information application equipment, and the flexibility and real-time nature of the log information application equipment is realized.
Patent Information
- Application Number
- CN202411103874.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-12
AI Technical Summary
The syslog protocol is a unilateral protocol, and it is difficult to change the reported log information content in a timely manner according to the log information needs of the log information application device.
By receiving a POST request from the log information application device, a log information subscription identifier is generated, a server push event (SSE) long connection is established, log information is sent to the application device, and the log information type is updated or deleted when the requirements change.
It realizes dynamic adjustment of reported log information content according to the needs of log information application equipment, and solves the problem that the syslog protocol is difficult to change the log information content in a timely manner.
Smart Images

Figure CN119071281A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of communication technology, and in particular to a log information transmission method, device and storage medium. Background Art
[0002] Currently, in the scenario of reporting log information, a common method of reporting log information is to report the log information to a log information application device through the syslog protocol.
[0003] However, since the syslog protocol is a unilateral protocol, when the log information requirements of the log information application device change, it is difficult to timely change the content of the reported log information according to the log information requirements of the log application device when reporting log information through the syslog protocol. Summary of the invention
[0004] The present invention provides a log information transmission method, device and storage medium, which solves the technical problem in the related art that the syslog protocol is a unilateral protocol and it is difficult to change the content of the reported log information in time according to the log information requirements of the log application device when reporting log messages.
[0005] In order to achieve the above objectives, the present invention adopts the following technical solutions:
[0006] In a first aspect, a log information transmission method is provided, the method comprising: receiving a first POST request; the first POST request comprising: an identifier of a log information application device and a type of log information requested by the log information application device; generating a log information subscription identifier based on the identifier of the log information application device and the type of log information requested; the log information subscription identifier is used to characterize a binding relationship between the log information application device and the type of log information; sending a response message to the log information application device; the response message is used to instruct the log information application device to establish a server push event SSE long connection based on the log information subscription identifier; the SSE long connection is used to send log information to the log information application device.
[0007] In combination with the first aspect above, in a possible implementation, after sending a response message to the log information application device, the method further includes: receiving a GET request from the log information application device; the GET request includes: a log information subscription identifier. Based on the log information subscription identifier, determining to establish an SSE long connection with the log information application device.
[0008] In combination with the above-mentioned first aspect, in a possible implementation method, the method specifically includes: determining the legitimacy of the type of log information requested by the log information application device based on the identification of the log information application device and the type of log information requested to be obtained; and generating a log information subscription identification when it is determined that the type of log information requested by the log information application device is legal.
[0009] In combination with the above-mentioned first aspect, in a possible implementation method, the method specifically includes: determining the log information access rights of the log information application device based on the identification of the log information application device; when it is determined that the log information application device has the authority to access the type of log information requested to be obtained, determining that the type of log information requested to be obtained by the log information application device is legal.
[0010] In combination with the above-mentioned first aspect, in a possible implementation method, before sending a response message to the log information application device, the method also includes: constructing a system table based on the log information subscription identifier, the log information type, and the identifier of the log information application device; the system table is used to characterize the binding relationship between the log information application device, the log information type requested to be obtained, and the log information subscription identifier.
[0011] In combination with the above-mentioned first aspect, in a possible implementation, the method also includes: receiving a second POST request; the second POST request is used to request to stop obtaining log information; based on the log information subscription identifier in the second POST request, determining to disconnect the SSE long connection with the log information application device.
[0012] In combination with the above-mentioned first aspect, in a possible implementation method, the method also includes: determining whether the time interval for sending log messages to the log information application device is greater than a preset threshold; if it is determined that the time interval is greater than the preset threshold, sending a link detection message to the log information application device; the link detection message is used to confirm whether the SSE long connection is disconnected.
[0013] In a second aspect, a log information transmission device is provided, which includes: a communication unit and a processing unit; the communication unit is used to receive a first POST request; the first POST request includes: an identifier of a log information application device and a type of log information requested by the log information application device; the processing unit is used to generate a log information subscription identifier based on the identifier of the log information application device and the type of log information requested; the log information subscription identifier is used to characterize the binding relationship between the log information application device and the type of log information; the communication unit is used to send a response message to the log information application device; the response message is used to instruct the log information application device to establish a server push event SSE long connection based on the log information subscription identifier; the SSE long connection is used to send log information to the log information application device.
[0014] In combination with the above second aspect, in a possible implementation, after sending a response message to the log information application device, the processing unit is further used to instruct the communication unit to receive a GET request from the log information application device; the GET request includes: a log information subscription identifier. Based on the log information subscription identifier, it is determined to establish an SSE long connection with the log information application device.
[0015] In combination with the above-mentioned second aspect, in a possible implementation method, the processing unit is specifically used to: determine the legitimacy of the type of log information requested by the log information application device based on the identification of the log information application device and the type of log information requested to be obtained; and generate a log information subscription identification when it is determined that the type of log information requested by the log information application device is legal.
[0016] In combination with the above-mentioned second aspect, in a possible implementation method, the processing unit is specifically used to determine the log information access rights of the log information application device based on the identification of the log information application device; when it is determined that the log information application device has the authority to access the type of log information requested to be obtained, it is determined that the type of log information requested to be obtained by the log information application device is legal.
[0017] In combination with the above-mentioned second aspect, in a possible implementation method, before sending a response message to the log information application device, the processing unit is also used to: build a system table based on the log information subscription identifier, the log information type, and the identifier of the log information application device; the system table is used to characterize the binding relationship between the log information application device, the log information type requested to be obtained, and the log information subscription identifier.
[0018] In combination with the above-mentioned second aspect, in a possible implementation method, the processing unit is also used to instruct the communication unit to receive a second POST request; the second POST request is used to request to stop obtaining log information; based on the log information subscription identifier in the second POST request, it is determined to disconnect the SSE long connection with the log information application device.
[0019] In combination with the above-mentioned second aspect, in a possible implementation method, the processing unit is also used to determine whether the time interval for sending log messages to the log information application device is greater than a preset threshold; when it is determined that the time interval is greater than the preset threshold, the communication unit is instructed to send a link detection message to the log information application device; the link detection message is used to confirm whether the SSE long connection is disconnected.
[0020] In a third aspect, a log information transmission device is provided, comprising: a processor and a memory; wherein the memory is used to store computer execution instructions, and when the log information transmission device is running, the processor executes the computer execution instructions stored in the memory, so that the log information transmission device performs the log information transmission method recorded in the above-mentioned first aspect and any possible implementation method thereof.
[0021] In a fourth aspect, a computer-readable storage medium is provided, in which instructions are stored. When the instructions in the computer-readable storage medium are executed by a processor of a log information transmission device, the log information transmission device executes the log information transmission method as described in the first aspect and any possible implementation method thereof.
[0022] In a fifth aspect, a chip is provided, the chip including a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run a computer program or instruction to implement the log information transmission method recorded in the above-mentioned first aspect and any possible implementation method thereof.
[0023] In the present disclosure, the name of the above-mentioned log information transmission device does not limit the device or functional module itself. In actual implementation, these devices or functional modules may appear with other names. As long as the functions of each device or functional module are similar to those of the present disclosure, they belong to the scope of the present disclosure and its equivalent technologies.
[0024] The technical solution provided by the present disclosure brings at least the following beneficial effects: the log information transmission device in the present disclosure first receives the first POST request from the log information application device; and based on the identification of the log information application device in the first POST request and the type of log information requested by the log information application device, generates a log information subscription identification for characterizing the type binding relationship between the log information application device and the log information; then sends a response message to the log information application device, instructing the log information application device to establish a server push event (Server-SentEvents, SSE) long connection based on the log information subscription identification; sends the log information requested to the log information application device through the SSE long connection. When the log information demand of the log information application device changes, the type of log information requested to be obtained can be added or deleted through the POST request, thereby solving the technical problem that when the log information demand of the log information application device changes, it is difficult to change the content of the reported log information in time according to the log information demand of the log application device when reporting log messages through the syslog protocol. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0026] Figure 1 A structural diagram of a log information transmission system provided by an embodiment of the present disclosure;
[0027] Figure 2 A schematic diagram of the hardware structure of a log information transmission device provided in an embodiment of the present disclosure;
[0028] Figure 3 A flow chart of a log information transmission method provided by an embodiment of the present disclosure;
[0029] Figure 4 A flowchart of another log information transmission method provided by an embodiment of the present disclosure;
[0030] Figure 5 A flowchart of another log information transmission method provided by an embodiment of the present disclosure;
[0031] Figure 6 A flowchart of another log information transmission method provided by an embodiment of the present disclosure;
[0032] Figure 7 A flowchart of another log information transmission method provided by an embodiment of the present disclosure;
[0033] Figure 8 A flowchart of another log information transmission method provided by an embodiment of the present disclosure;
[0034] Fig. 9 A flowchart of another log information transmission method provided by an embodiment of the present disclosure;
[0035] Fig.10 A flowchart of another log information transmission method provided by an embodiment of the present disclosure;
[0036] Fig.11 A schematic diagram of the structure of a log information transmission device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0037] A log information transmission method, device, and storage medium provided by an embodiment of the present disclosure are described in detail below with reference to the accompanying drawings.
[0038] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0039] The terms “first”, “second” and the like in the specification and drawings of the present disclosure are used to distinguish different objects, or to distinguish different processing of the same object, rather than to describe a specific order of objects.
[0040] In addition, the terms "including" and "having" and any variations thereof mentioned in the description of the present disclosure are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes other steps or units that are not listed, or optionally includes other steps or units that are inherent to these processes, methods, products or devices. It should be noted that in the embodiments of the present disclosure, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present disclosure should not be interpreted as being more preferred or more advantageous than other embodiments or design solutions. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0041] In the description of the present disclosure, unless otherwise specified, “plurality” means two or more.
[0042] The following explains the terms involved in the embodiments of the present disclosure to facilitate readers' understanding.
[0043] 1. Server-Sent Events (SSE)
[0044] SSE technology is a technology used to enable the server to actively push data to the client, also known as "event stream". It is based on the HTTP protocol and uses its long connection feature to establish a persistent connection between the client and the server, and through this connection, the server can push real-time data to the client.
[0045] 2.syslog system log protocol
[0046] The syslog protocol is a master-slave protocol, which is divided into a client and a server. The client is the party that generates log messages, while the server is responsible for receiving log messages sent by the client, saving them in a specific log file or processing them in other ways. On Unix-like operating systems, syslog log messages can be recorded in local files or sent to a server that receives syslog over the network. The server that receives syslog can uniformly manage and store log records from many different types of systems, or parse the content and perform corresponding processing. Common application scenarios include network management tools, security management systems, log audit systems, etc.
[0047] The data format specification RFC5424 specifies the header bytes of the syslog message body. The header bytes are defined in the following structure: <pri> > <version>sp <timestamp>sp <hostname>sp <app-name>sp <procid>sp <msg-id>sp<STRUCTURE DATA> . Among them, "pri is used to represent the entity that creates the log message and the level of the log message"; "sp" identifies a confirmed information separator, such as the "space bar". "version" is the version, which is basically 1; "timestamp" is the time when the log is reported; "hostname" is the source host name that sends the syslog message; "app-name" is the specific location where the syslog message is generated, such as from a certain device; "procid" is the specific process id that generates the syslog message; "msg-id" is the message type, which can be used to identify specific message attributes and used for data filtering; "structure-data" is structured data; the body of the syslog message is encoded in utf-8, the type is a string, and the content is custom.
[0048] At present, in the scenario of reporting log information, the common method of reporting log information is to report log information to the log information application device through the syslog protocol. However, since the syslog protocol is a unilateral protocol, when the log information demand of the log information application device changes, it is difficult to change the content of the reported log information in time according to the log information demand of the log application device by reporting log information through the syslog protocol.
[0049] In order to solve the above technical problems, the present disclosure provides a log information transmission method, device and storage medium, which are used to solve the technical problem that it is difficult to change the content of the reported log information in time according to the log information demand of the log application device based on the log information reported through the syslog protocol. The method includes: the log information transmission device first receives a first POST request from the log information application device; and based on the identification of the log information application device in the first POST request and the type of log information requested by the log information application device, generates a log information subscription identifier for characterizing the type binding relationship between the log information application device and the log information; then sends a response message to the log information application device, instructing the log information application device to establish a server push event (Server-Sent Events, SSE) long connection based on the log information subscription identifier; and sends the log information requested to the log information application device through the SSE long connection. When the log information demand of the log information application device changes, the log information type requested to be obtained can be added or deleted through the POST request, thereby solving the technical problem that it is difficult to change the content of the reported log information in time according to the log information demand of the log application device when the log information demand of the log information application device changes.
[0050] In a possible implementation, the above log information transmission method can be applied to the log information transmission system 100. Figure 1 A log information transmission system 100 provided in an embodiment of the present application is described in detail. Figure 1 As shown, Figure 1 A log information transmission system 100 provided in an embodiment of the present disclosure includes: a log information application device 101 and a log information transmission apparatus 102 .
[0051] Among them, the log information application device 101 is used to send a first POST request to the log information transmission device 102, and the first POST request includes: the identification of the log information application device and the type of log information requested by the log information application device; receive response information from the log information transmission device 102, and the response information includes a log information subscription identification; send a GET request to the log information transmission device 102 based on the log information subscription identification, and determine to establish an SSE long connection with the log information transmission device 102.
[0052] The log information transmission device 102 is used to receive a first POST request; the first POST request includes: an identifier of the log information application device 101, and the type of log information requested by the log information application device 101; a log information subscription identifier is generated based on the identifier of the log information application device 101 and the type of log information requested; the log information subscription identifier is used to characterize the binding relationship between the log information application device 101 and the type of log information; a response message is sent to the log information application device 101; the response message is used to instruct the log information application device 101 to establish a server push event SSE long connection based on the log information subscription identifier; the SSE long connection is used to send log information to the log information application device 101.
[0053] In a possible implementation, the hardware structure of the log information transmission device includes: Figure 2 The log information transmission device 200 shown in FIG. Figure 2 The log information transmission device 200 shown in the figure is used as an example to introduce the hardware structure of the log information transmission device. Figure 2 As shown, the log information transmission device 200 includes at least one processor 201, a communication line 202, and at least one communication interface 204, and may also include a memory 203. The processor 201, the memory 203 and the communication interface 204 may be connected via the communication line 202.
[0054] The processor 201 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present disclosure, such as one or more digital signal processors (DSP), or one or more field programmable gate arrays (FPGA).
[0055] The communication link 202 may include a pathway for transmitting information between the above-mentioned components.
[0056] The communication interface 204 is used to communicate with other devices or communication networks, and can use any transceiver-like device, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.
[0057] The memory 203 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to include or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0058] In one possible design, the memory 203 can exist independently of the processor 201, that is, the memory 203 can be a memory outside the processor 201. In this case, the memory 203 can be connected to the processor 201 through the communication line 202, and is used to store execution instructions or application code, and the execution is controlled by the processor 201 to implement the log information transmission method provided in the following embodiment of the present disclosure. In another possible design, the memory 203 can also be integrated with the processor 201, that is, the memory 203 can be the internal memory of the processor 201, for example, the memory 203 is a cache, which can be used to temporarily store some data and instruction information, etc.
[0059] As an implementation method, the processor 201 may include one or more CPUs, for example Figure 2 As another possible implementation, the log information transmission device 200 may include multiple processors, such as Figure 2 As another possible implementation, the log information transmission device 200 may further include an output device 205 and an input device 206.
[0060] In the following, a log information transmission method provided by an embodiment of the present disclosure is described in detail.
[0061] like Figure 3 As shown, Figure 3 A log information transmission method provided in an embodiment of the present disclosure can be applied to Figure 2 In the log information transmission device shown, the method includes the following S301-S303, which are described in detail below.
[0062] S301: The log information transmission device receives a first POST request.
[0063] The first POST request includes: an identifier of the log information application device and a type of log information requested to be obtained by the log information application device.
[0064] In a possible implementation manner, the first POST request also includes a URL address of the first POST request.
[0065] For example, the request URL is:
[0066] / restconf / operations / ietf-subscribed-notifications:establish-subscription
[0067] Exemplarily, the input message of the first POST request is:
[0068]
[0069] Among them, encoding is the format requirement of the data in this interface; topic is the subscription topic; object-type-info is the subscription object type.
[0070] S302: The log information transmission device generates a log information subscription identifier based on the identifier of the log information application device and the type of log information requested to be obtained.
[0071] In a possible implementation, the log information subscription identifier is used to represent the binding relationship between the log information application device and the type of log information.
[0072] S303: The log information transmission device sends a response message to the log information application device.
[0073] In a possible implementation, the response message is used to instruct the log information application device to establish a server push event SSE long connection based on the log information subscription identifier; the SSE long connection is used to send log information to the log information application device.
[0074] Exemplarily, the input message of the response message is:
[0075] {
[0076] "ietf-subscribed-notifications:output":{
[0077] "id":{id}
[0078] }
[0079] }
[0080] Wherein, id is a log information subscription identifier used to characterize the binding relationship between the log information application device and the type of log information.
[0081] The technical solution provided by the above embodiment can at least bring the following beneficial effects: the log information transmission device first receives the first POST request from the log information application device; and based on the identification of the log information application device in the first POST request and the type of log information requested by the log information application device, generates a log information subscription identification for characterizing the type binding relationship between the log information application device and the log information; then sends a response message to the log information application device, instructing the log information application device to establish a server push event (Server-SentEvents, SSE) long connection based on the log information subscription identification; sends the log information requested to the log information application device through the SSE long connection. When the log information demand of the log information application device changes, the type of log information requested to be obtained can be added or deleted through the POST request, thereby solving the technical problem that when the log information demand of the log information application device changes, it is difficult to change the content of the reported log information in time according to the log information demand of the log application device when reporting the log message through the syslog protocol.
[0082] In one possible implementation, combining Figure 3 ,like Figure 4 As shown, in the above S303, after the log information transmission device sends a response message to the log information application device, the process of the log information transmission device establishing an SSE long connection can be specifically implemented through the following S401-S402, which is described in detail below.
[0083] S401: The log information transmission device receives a GET request from a log information application device.
[0084] The GET request includes: a log information subscription identifier.
[0085] In a possible implementation, the GET request also includes a URL address of the GET request.
[0086] For example, the URL address of the GET request is:
[0087] / restconf / streams / yang-push-json / subscription-id={id}
[0088] S402: The log information transmission device determines to establish an SSE long connection with the log information application device based on the log information subscription identifier.
[0089] In a possible implementation, when the log information transmission device receives a GET request and determines that the log information subscription identifier in the GET request is successfully verified, it can be determined that the SSE long connection between the log information transmission device and the log information application device is established.
[0090] In one possible implementation, after the SSE long connection between the log information transmission device and the log information application device is established, when the log information application device generates new log information requirements or modifies the log information requirements, a POST request can be used to add new subscription log information content or modify the subscription log information content, and the log information subscription identifier does not change, that is, there is no need to establish a new SSE long connection.
[0091] Exemplarily, after the SSE long connection is established, the data structure of the real-time reporting information is:
[0092]
[0093] Among them, event-time is the time when the report information is sent; subscription-id is the log information subscription identifier assigned by the log information transmission device; patch-id is the identifier of a single notification message; edit-id is the key value of the array element, which is used to express multiple notification messages; operation is used to generate / delete / update subscription objects; target is the root path; value is the data of the changed data node of the YANG model. When a log object is involved, fill in the data structure of the corresponding log type.
[0094] The technical solution provided by the above embodiment can at least bring about the following beneficial effects: the log information transmission device receives a GET request from a log information application device, and based on the log information subscription identifier in the GET request, determines to establish an SSE long connection with the log information application device, so that the log information transmission device sends log information to the log information application device based on the long connection.
[0095] In one possible implementation, Figure 5 As shown, in the above S302, before the log information transmission device generates a log information subscription identifier based on the identifier of the log information application device and the type of log information requested to be obtained, the log information transmission device needs to determine the legitimacy of the type of log information requested to be obtained. This process can be specifically determined by the following S501-S502, which is described in detail below.
[0096] S501: The log information transmission device determines the legitimacy of the type of log information requested by the log information application device based on the identification of the log information application device and the type of log information requested to be obtained.
[0097] In a possible implementation, the log information transmission device determines the log information application device based on the identifier of the log information application device, and then determines the legitimacy of the log information type requested by the log information application device.
[0098] It is understandable that the log information application device may not have the authority to access the log information type requested, so it is necessary to determine the legitimacy of the log information type requested by the log information application device.
[0099] S502: When determining that the type of log information requested by the log information application device is legal, the log information transmission device generates a log information subscription identifier.
[0100] In a possible implementation, the log information types include: operation log, system log, and security log.
[0101] Exemplarily, the data structure of the operation log is:
[0102] {
[0103] "serial-num":{serial-num},
[0104] "log-type":{log-type},
[0105] "log-location":{log-location},
[0106] "severity-level":{severity-level},
[0107] "identity":{
[0108]
[0109] Exemplarily, the data structure of the system log is:
[0110]
[0111]
[0112] Exemplarily, the data structure of the security log is:
[0113]
[0114] Among them, serial-num is the log serial number, which is assigned by the log information transmission device; log-type is the log type, including: operation log, system log, security log; log-location is the source of the log, including: network management log, network element log; severity-level is used to characterize the importance of information; ems-ip is the network address of the log information transmission device; ems-name is the name of the log information transmission device; name is the user name; rank is the user authority level, including: administrator, configuration, maintenance, monitoring; operating-terminal-address is the remote operation terminal address; operating-module is the operation module; operating-command is the operation command; object-type is the object type; object-name is the object name; operating-method is the operation method and action; operating-result is the operation result; syslog-name is the system log name; resource-id is the name of the object in the resource system; syslog-detail is the system log information description details; securitylog-detail is the security log details information; start-time is the operation start time; end-time is the operation end time.
[0115] The technical solution provided by the above embodiment can at least bring about the following beneficial effects: the log information transmission device determines the log information application device based on the identification of the log information application device, and determines the legitimacy of the log information type requested by the log information application device; when it is determined that the log information type requested by the log information application device is legal, a log information subscription identification is generated, thereby improving the security of the log information.
[0116] In one possible implementation, combining Figure 5 ,like Figure 6 As shown, the above S501, the process in which the log information transmission device determines the legitimacy of the log information type requested by the log information application device based on the identification of the log information application device and the log information type requested to be obtained, can be specifically implemented through the following S601-S602, which is described in detail below.
[0117] S601: The log information transmission device determines the log information access permission of the log information application device based on the identification of the log information application device.
[0118] In a possible implementation, the storage module of the log information transmission device stores information access permissions of all log information application devices.
[0119] S602: When determining that the log information application device has the authority to access the requested log information type, the log information transmission apparatus determines that the log information type requested by the log information application device is legal.
[0120] In a possible implementation, the log information transmission device determines that the log information application device has the authority to access the requested log information type, and then determines that the log information type requested by the log information application device is legal.
[0121] Exemplarily, the log information transmission device determines that the access rights of the log information application device include: operation log and security log, and the log information type requested by the log information application device is operation log, then the log information transmission device determines that the log information type requested by the log information application device is legal.
[0122] The technical solution provided by the above embodiment can at least bring about the following beneficial effects: the log information transmission device determines the log information application device based on the identification of the log information application device, and then determines the log information access rights of the log information application device, and determines the legitimacy of the log information type requested by the log information application device based on the log information access rights of the log information application device, thereby determining the legitimacy of the log information type requested by the log information application device.
[0123] In one possible implementation, combining Figure 3 ,like Figure 7 As shown, in the above S303, before the log information transmission device sends a response message to the log information application device, it is necessary to build a system table, which can be specifically implemented by the following S701, which is described in detail below.
[0124] S701: The log information transmission device constructs a system table based on the log information subscription identifier, the log information type, and the identifier of the log information application device.
[0125] The system table is used to represent the binding relationship between the log information application device, the log information type requested to be obtained, and the log information subscription identifier.
[0126] In one possible implementation, each time the log information transmission device receives the first POST request and generates a log information subscription identifier based on the first POST request, it will build a system table based on the log information subscription identifier, the log information type, and the identifier of the log information application device, so that the log information transmission device determines the binding relationship between the log information application device, the requested log information type, and the log information subscription identifier based on the system table.
[0127] The technical solution provided by the above embodiment can at least bring about the following beneficial effects: after the log information transmission device generates a log information subscription identifier based on the first POST request, it constructs a system table based on the log information subscription identifier, the log information type, and the identifier of the log information application device, so that the log information transmission device determines the binding relationship between the log information application device, the requested log information type, and the log information subscription identifier based on the system table.
[0128] In one possible implementation, Figure 8 As shown, the log information transmission device needs to disconnect the SSE long connection when it is determined that the log information application device stops obtaining log information. This process can be specifically implemented through the following S801-S802, which is described in detail below.
[0129] S801. The log information transmission device receives a second POST request.
[0130] The second POST request is used to request to stop obtaining log information.
[0131] In a possible implementation, when the log information application device does not need to obtain the log information, the log information application device sends a second POST request to the log information transmission device to request to stop obtaining the log information.
[0132] S802: The log information transmission device determines to disconnect the SSE long connection with the log information application device based on the log information subscription identifier in the second POST request.
[0133] In a possible implementation, the log information transmission device determines the log information application device to disconnect the SSE long connection based on the log information subscription identifier in the second POST request.
[0134] The technical solution provided by the above embodiment can at least bring the following beneficial effects: when determining that the log information application device stops acquiring log information, the log information transmission device disconnects the SSE long connection with the log information application device and releases the related resource information.
[0135] In one possible implementation, Fig. 9 As shown, when the log information transmission device does not send log messages to the log information application device for a long time, it is necessary for the log information application device to determine the connection status of the current SSE long connection. This process can be specifically implemented through the following S901-S902, which is described in detail below.
[0136] S901: The log information transmission apparatus determines whether a time interval for sending log messages to a log information application device is greater than a preset threshold.
[0137] Exemplarily, the log information transmission device determines whether the time interval from the time when the log message was last sent to the current time is greater than 30 seconds.
[0138] S902: When determining that the time interval is greater than a preset threshold, the log information transmission device sends a link detection message to the log information application device.
[0139] The link detection message is used to confirm whether the SSE long connection is disconnected.
[0140] Exemplarily, the log information transmission device determines the time when the log message was last sent, and if the time interval to the current time is greater than 30 seconds, it sends a link detection message to the log information application device, so that the log information application device determines the connection status of the current SSE long connection based on the link detection message.
[0141] The technical solution provided by the above embodiment can at least bring the following beneficial effects: when the log information transmission device does not send log messages to the log information application device for a long time, it sends a link detection message to the log information application device, so that the log information application device determines the connection status of the current SSE long connection based on the link detection message.
[0142] In one possible implementation, Fig.10 As shown, Fig.10 This is a flow chart of another log information transmission method provided by an embodiment of the present disclosure. The process specifically includes the following S1001-S1008, which are described in detail below.
[0143] S1001. The log information application device sends a log subscription relationship establishment request to the log information transmission device. Correspondingly, the log information transmission device receives the log subscription relationship establishment request.
[0144] S1002: The log information transmission device processes a log subscription relationship establishment request.
[0145] S1003: The log information transmission device sends a subscription relationship establishment result to the log information application device, and correspondingly, the log information application device receives the subscription relationship establishment result.
[0146] S1004: The log information application device sends an SSE long connection establishment request to the log information transmission apparatus. Correspondingly, the log information transmission apparatus receives the SSE long connection establishment request from the log information application device.
[0147] S1005 . When a log message is generated and triggered, the log information transmission device sends the log message to the log information application device. Correspondingly, the log information application device receives the log message from the log information transmission device.
[0148] S1006: The log information application device sends a request to delete the subscription relationship to the log information transmission apparatus. Correspondingly, the log information transmission apparatus receives the request to delete the subscription relationship from the log information application device.
[0149] S1007: The log information transmission device processes the request to delete the subscription relationship.
[0150] S1008: The log information transmission device sends a subscription deletion result to the log information application device. Correspondingly, the log information application device receives the subscription deletion result from the log information transmission device.
[0151] It can be seen that the above mainly introduces the technical solution provided by the embodiment of the present disclosure from the perspective of the method. In order to achieve the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the modules and algorithm steps of each example described in the embodiment disclosed herein, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present disclosure.
[0152] The disclosed embodiment can divide the log information transmission device into functional modules according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. Optionally, the division of modules in the disclosed embodiment is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0153] In one possible implementation, Fig.11 , Fig.11 A structural schematic diagram of a log information transmission device 1100 provided in the present disclosure.
[0154] The log information transmission device 1100 includes: a communication unit 1101 and a processing unit 1102; the communication unit 1101 is used to receive a first POST request; the first POST request includes: an identifier of a log information application device and a type of log information requested by the log information application device; the processing unit 1102 is used to generate a log information subscription identifier based on the identifier of the log information application device and the type of log information requested; the log information subscription identifier is used to characterize the binding relationship between the log information application device and the type of log information; the communication unit 1101 is used to send a response message to the log information application device; the response message is used to instruct the log information application device to establish a server push event SSE long connection based on the log information subscription identifier; the SSE long connection is used to send log information to the log information application device.
[0155] In a possible implementation, after sending a response message to the log information application device, the processing unit 1102 is further used to instruct the communication unit 1101 to receive a GET request from the log information application device; the GET request includes: a log information subscription identifier. Based on the log information subscription identifier, it is determined to establish an SSE long connection with the log information application device.
[0156] In one possible implementation, the processing unit 1102 is specifically used to: determine the legitimacy of the type of log information requested by the log information application device based on the identifier of the log information application device and the type of log information requested to be obtained; and generate a log information subscription identifier when it is determined that the type of log information requested by the log information application device is legal.
[0157] In one possible implementation, the processing unit 1102 is specifically used to determine the log information access rights of the log information application device based on the identification of the log information application device; when it is determined that the log information application device has the authority to access the requested log information type, determine that the log information type requested by the log information application device is legal.
[0158] In one possible implementation, before sending a response message to the log information application device, the processing unit 1102 is also used to: build a system table based on the log information subscription identifier, the log information type, and the identifier of the log information application device; the system table is used to characterize the binding relationship between the log information application device, the log information type requested to be obtained, and the log information subscription identifier.
[0159] In a possible implementation, the processing unit 1102 is further used to instruct the communication unit 1101 to receive a second POST request; the second POST request is used to request to stop obtaining log information; based on the log information subscription identifier in the second POST request, it is determined to disconnect the SSE long connection with the log information application device.
[0160] In one possible implementation, the processing unit 1102 is also used to determine whether the time interval for sending log messages to the log information application device is greater than a preset threshold; when it is determined that the time interval is greater than the preset threshold, the communication unit 1101 is instructed to send a link detection message to the log information application device; the link detection message is used to confirm whether the SSE long connection is disconnected.
[0161] The embodiment of the present disclosure also provides a log information transmission device, which includes a processor and a memory; wherein the memory is used to store computer execution instructions, and when the log information transmission device is running, the processor executes the computer execution instructions stored in the memory, so that the log information transmission device executes the log information transmission method recorded in the embodiment of the present disclosure.
[0162] An embodiment of the present disclosure provides a computer program product including instructions. When the instructions are executed on a computer, the computer is enabled to execute the log information transmission method in the above method embodiment.
[0163] An embodiment of the present disclosure provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run a computer program or instruction to implement the log information transmission method in the above method embodiment.
[0164] Among them, the computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, and a hard disk. Random Access Memory (RAM), Read-Only Memory (ROM), Erasable Programmable Read Only Memory (EPROM), registers, hard disks, optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any other form of computer-readable storage medium in a suitable combination of the above, or numerical values in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an Application Specific Integrated Circuit (ASIC). In the embodiments of the present disclosure, computer-readable storage media may be any tangible media that contains or stores a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0165] Since the apparatus, device, computer-readable storage medium, and computer program product in the embodiments of the present disclosure can be applied to the above-mentioned method, the technical effects that can be obtained can also refer to the above-mentioned method embodiments, and the embodiments of the present disclosure will not be repeated here.
[0166] The above is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims. < / procid> < / hostname> < / timestamp> < / version> < / pri>
Claims
1. A log information transmission method, characterized in that: include: Receive the first POST request; The first POST request includes: an identifier of the log information application device and the type of log information requested by the log information application device; Generate a log information subscription identifier based on the identifier of the log information application device and the type of log information requested; the log information subscription identifier is used to represent the binding relationship between the log information application device and the type of log information; A response message is sent to the log information application device; the response message is used to instruct the log information application device to establish a server push event SSE long connection based on the log information subscription identifier; the SSE long connection is used to send log information to the log information application device.
2. The method according to claim 1, characterized in that After sending a response message to the log information application device, the method further includes: Receiving a GET request from the log information application device; the GET request includes: the log information subscription identifier; Based on the log information subscription identifier, determine to establish an SSE long connection with the log information application device.
3. The method according to claim 2, characterized in that The step of generating a log information subscription identifier based on the identifier of the log information application device and the type of log information requested to be obtained includes: Determining the legitimacy of the type of log information requested by the log information application device based on the identifier of the log information application device and the type of log information requested to be obtained; When it is determined that the type of log information requested by the log information application device is legal, the log information subscription identifier is generated.
4. The method according to claim 3, characterized in that The determining, based on the identifier of the log information application device and the type of log information requested to be obtained, the legitimacy of the type of log information requested to be obtained by the log information application device includes: Determining the log information access permission of the log information application device based on the identification of the log information application device; In the case where it is determined that the log information application device has the authority to access the requested log information type, it is determined that the log information type requested by the log information application device is legal.
5. The method according to claim 4, characterized in that Before sending a response message to the log information application device, the method further includes: A system table is constructed based on the log information subscription identifier, the log information type, and the identifier of the log information application device; the system table is used to characterize the binding relationship between the log information application device, the requested log information type, and the log information subscription identifier.
6. The method according to claim 5, characterized in that The method further comprises: receiving a second POST request; wherein the second POST request is used to request to stop obtaining log information; Based on the log information subscription identifier in the second POST request, determine to disconnect the SSE long connection with the log information application device.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Determine whether the time interval for sending log messages to the log information application device is greater than a preset threshold; When it is determined that the time interval is greater than the preset threshold, a link detection message is sent to the log information application device; the link detection message is used to confirm whether the SSE long connection is disconnected.
8. A log information transmission device, characterized in that: include: a communication unit and a processing unit; The communication unit is used to receive a first POST request; The first POST request includes: an identifier of the log information application device and the type of log information requested by the log information application device; The processing unit is used to generate a log information subscription identifier based on the identifier of the log information application device and the type of log information requested to be obtained; the log information subscription identifier is used to represent the binding relationship between the log information application device and the type of log information; The communication unit is used to send a response message to the log information application device; the response message is used to instruct the log information application device to establish a server push event SSE long connection based on the log information subscription identifier; the SSE long connection is used to send log information to the log information application device.
9. A log information transmission device, characterized in that: include: A processor and a memory; wherein the memory is used to store computer-executable instructions; when the log information transmission device is running, the processor executes the computer-executable instructions stored in the memory, so that the log information transmission device executes the log information transmission method described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions. When the instructions in the computer-readable storage medium are executed by a processor for log information transmission, the log information transmission device executes the log information transmission method according to any one of claims 1 to 7.
Citation Information
Patent Citations
HTTP (Hyper Text Transfer Protocol) based mobile application message forwarding method and system
CN104660708A
Audit log obtaining, generating and verifying method and system and device
CN106571951A
Big data real-time storage, processing and querying system
CN106815338A
Real-time response type API gateway and request processing method thereof
CN110300056A
Log information collection system, method and device and electronic equipment
CN112887351A
Cited By
Business processing method and device
CN121619117A
