Method, device and equipment for writing username into gateway log and storage medium
Patent Information
- Application Number
- CN202311208815.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-18
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-09-18
AI Technical Summary
但是,由于网关日志中记录的是用户临时标识,且多次登录对应的用户临时标识不同,导致无法将网关日志归属到用户,日志分析效率很低
[0052]本发明提供的向网关日志中写入用户名的方法,包括:获取目标应用的网关日志,网关日志包括登录日志和使用日志,使用日志为用户登录后使用目标应用产生的日志,从网关日志中确定用于存储用户临时标识的目标字段,从登录日志中确定用户名与用户临时标识的对照关系,基于对照关系,将目标字段存储的用户临时标识对应的用户名写入到使用日志中,实现将网关日志归属到对应的用户,提高了后续日志分析的分析效率。
Smart Images

Figure CN117240660B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to gateway log processing technology, and more particularly to a method, apparatus, device, and storage medium for writing usernames into gateway logs. Background Technology
[0002] When a user accesses an application that requires login, the server returns a temporary user identifier (Token ID) after login. Subsequent gateway logs generated by the user's actions within the application record this temporary user identifier, not the username. Furthermore, the server returns a new temporary user identifier to the user each time they log in.
[0003] During application development, developers often need to obtain and analyze the application's gateway logs. However, because the gateway logs record temporary user identifiers, and different temporary user identifiers correspond to multiple logins, it is impossible to attribute the gateway logs to specific users, resulting in very low log analysis efficiency. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and storage medium for writing usernames into gateway logs, thereby assigning gateway logs to corresponding users and improving the efficiency of subsequent log analysis.
[0005] In a first aspect, the present invention provides a method for writing usernames to a gateway log, comprising:
[0006] Obtain the gateway logs of the target application, which include login logs and usage logs, wherein the usage logs are the logs generated by the user after logging in and using the target application;
[0007] Determine the target field for storing the user's temporary identifier from the gateway log;
[0008] Determine the mapping relationship between the username and the temporary user identifier from the login log;
[0009] Based on the aforementioned comparison relationship, the username corresponding to the temporary user identifier stored in the target field is written into the usage log.
[0010] Optionally, the target field for storing the user's temporary identifier is determined from the gateway log, including:
[0011] The gateway logs are normalized to obtain a data stream containing multiple logs;
[0012] The logs are processed one by one in the order of the data stream to determine potential fields for storing temporary user identifiers from multiple logs;
[0013] Count the number of each potential field, where a potential field with the same value is counted as one, and a potential field with different values is counted separately.
[0014] The number of times the user successfully logged in is determined from the login logs;
[0015] Potential fields whose number of entries matches the number of times the user has successfully logged in are used as target fields for storing the user's temporary identifier.
[0016] Optionally, the logs are processed sequentially according to the data stream to determine potential fields for storing temporary user identifiers from multiple logs, including:
[0017] Multiple regular expression rules, including potential fields as keywords, are used to perform regular expression matching on the request headers in the logs to identify potential fields used to store temporary user identifiers.
[0018] Store the potential fields of multiple log entries and their corresponding values in a temporary list.
[0019] Optionally, count the number of records for each of the potential fields, including:
[0020] Iterate through each potential field in the temporary list, and use that potential field as an aggregation field to perform an aggregation query on the temporary list to obtain the total number of aggregate query results for each potential field.
[0021] Optionally, determining the number of times the user successfully logged in from the login log includes:
[0022] The logs are processed one by one according to the order of the data stream to filter out the login logs;
[0023] The success of the login is determined based on the login return value returned by the server in the login log.
[0024] The number of successful login log entries is counted as the number of times the user has successfully logged in.
[0025] Optionally, the logs are processed one by one according to the order of the data stream to filter out login logs, including:
[0026] Regular expression rules including login keywords are used to perform regular expression matching on the URL field in the logs to extract login logs.
[0027] Optionally, determining the mapping relationship between the username and the temporary user identifier from the login log includes:
[0028] The logs are processed one by one according to the order of the data stream to filter out the login logs;
[0029] The target login log for successful login is determined based on the login return value returned by the server in the login log.
[0030] Determine the username of the user who logged in from the request body of the target login log;
[0031] Identify potential temporary user identifiers from the response body of the target login log;
[0032] Establish a mapping relationship between the username and potential temporary user identifiers.
[0033] Optionally, a potential temporary user identifier can be determined from the response body of the target login log, including:
[0034] Iterate through the values of all fields in the response body of the target login log;
[0035] Values with a length greater than a preset number of bits are used as potential temporary user identifiers.
[0036] Optionally, based on the aforementioned mapping relationship, the username corresponding to the temporary user identifier stored in the target field is written into the usage log, including:
[0037] Determine whether the user temporary identifier corresponding to the target field exists in the mapping relationship between the username and potential user temporary identifiers;
[0038] If so, the username corresponding to the temporary user identifier is determined based on the comparison relationship, and the username is written into the usage log.
[0039] Optionally, based on the comparison relationship, writing the username corresponding to the user temporary identifier stored in the target field into the usage log further includes:
[0040] Write the username corresponding to the temporary user identifier stored in the target field into a fixed preset field;
[0041] Write the preset field and the corresponding username into the login log and the usage log.
[0042] Secondly, the present invention also provides an apparatus for writing usernames to a gateway log, comprising:
[0043] The gateway log acquisition module is used to acquire the gateway logs of the target application. The gateway logs include login logs and usage logs. The usage logs are the logs generated when a user logs in and uses the target application.
[0044] The target field determination module is used to determine the target field for storing the user's temporary identifier from the gateway log;
[0045] The mapping relationship determination module is used to determine the mapping relationship between the username and the user's temporary identifier from the login log;
[0046] The username writing module is used to write the username corresponding to the temporary user identifier stored in the target field into the usage log based on the comparison relationship.
[0047] Thirdly, the present invention also provides an electronic device, comprising:
[0048] One or more processors;
[0049] Storage device for storing one or more programs;
[0050] When the one or more programs are executed by the one or more processors, the one or more processors implement the method of writing usernames to a gateway log as provided in the first aspect of the present invention.
[0051] Fourthly, the present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that, when executed by a processor, the program implements the method of writing usernames to a gateway log as provided in the first aspect of the present invention.
[0052] The present invention provides a method for writing usernames to gateway logs, comprising: obtaining gateway logs of a target application, the gateway logs including login logs and usage logs, the usage logs being logs generated by a user using the target application after logging in; determining a target field for storing a user's temporary identifier from the gateway logs; determining a mapping relationship between the username and the user's temporary identifier from the login logs; and, based on the mapping relationship, writing the username corresponding to the user's temporary identifier stored in the target field into the usage logs, thereby assigning the gateway logs to the corresponding user and improving the efficiency of subsequent log analysis.
[0053] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0054] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0055] Figure 1 A flowchart illustrating a method for writing a username to a gateway log, as provided in an embodiment of the present invention;
[0056] Figure 2 A schematic diagram of a device for writing usernames to a gateway log, provided in an embodiment of the present invention;
[0057] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
[0058] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0059] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0060] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0061] The acquisition, storage, use, and processing of data in this application all comply with the relevant provisions of national laws and regulations.
[0062] Figure 1 This is a flowchart illustrating a method for writing usernames to a gateway log according to an embodiment of the present invention. This embodiment is applicable to situations where usernames are written to the gateway log to assign the log to the corresponding user. This method can be executed by the apparatus for writing usernames to the gateway log provided in this embodiment of the present invention. This apparatus can be implemented in software and / or hardware, and is typically configured in an electronic device, such as... Figure 1 As shown, the method for writing a username to the gateway log includes the following steps:
[0063] S101. Obtain the gateway logs of the target application. The gateway logs include login logs and usage logs. The usage logs are the logs generated when a user logs in and uses the target application.
[0064] A gateway acts as a communication bridge between an application and its corresponding server. For example, a gateway can serve multiple applications. User actions within an application are recorded in the gateway log. These actions can be categorized into login actions and post-login usage actions. A login action generates a login log entry, while each click during usage generates a usage log entry. In other words, the gateway log includes login logs and usage logs; the usage logs are those generated after a user logs in and uses the application.
[0065] In this embodiment of the invention, for a specific target application, the gateway log of the target application is obtained. The gateway log includes login logs and usage logs. The usage logs are the logs generated after a user logs in and uses the target application. The login logs record information such as the username and password used by the user to log in to the application. The usage logs do not record the username, but only the temporary identifier of the user for this login.
[0066] For example, in this embodiment of the invention, gateway logs of multiple applications can be processed asynchronously, thereby improving processing efficiency.
[0067] S102. Determine the target field used to store the user's temporary identifier from the gateway log.
[0068] In gateway logs, user temporary identifiers and the target field for storing them are recorded as key-value pairs; for example, the target field is the key, and the user temporary identifier is the value. Different applications may use different fields to store user temporary identifiers in their gateway logs. For instance, application A might use the "ID" field, while application B might use the "session" field. Therefore, it is necessary to determine the target field used to store user temporary identifiers from the gateway logs.
[0069] For example, in some embodiments of the present invention, step S102 may include the following sub-steps:
[0070] S1021. Normalize the gateway logs to obtain a data stream containing multiple logs.
[0071] For example, for each target application's gateway logs, the original gateway logs of the target application are normalized and converted into a JSON format data stream, which includes multiple log entries.
[0072] S1022. Process the logs one by one in the order of the data flow, and determine the potential fields for storing temporary user identifiers from multiple logs.
[0073] In this embodiment of the invention, a message queue is set up to store logs from the data stream. For example, the message queue can store 500 logs. Logs are retrieved from the message queue one by one according to the order of the data stream (i.e., the chronological order of the logs) for processing, thereby reducing the peak pressure of log processing. Since it is currently unknown which field the target application uses to store the user's temporary identifier, the potential fields for storing the user's temporary identifier can only be determined from multiple logs.
[0074] For example, in some embodiments of the present invention, multiple regular expression rules are established using potential fields as keywords (e.g., id, cookie, session, token, etc.) and stored in a target field regular expression library. These rules are then used to perform regular expression matching on the request header in the log. The matching iterates through the rules, identifying potential fields containing keywords such as *id*, cookie*, session*, and token*, which are used to store temporary user identifiers. The potential fields and their corresponding values are then stored in a temporary list. For example, in cases involving multiple applications, the application names can also be written into this temporary list, forming a mapping relationship between application name, potential field, and value.
[0075] S1023. Count the number of records for each potential field. Among them, the same potential field with the same value is counted as one record, and the same potential field with different values is counted separately.
[0076] In this embodiment of the invention, the number of entries for each potential field is counted. A potential field with the same value is counted as one entry, and a potential field with different values is counted separately. For example, if the value corresponding to the potential field "cookie" is the same in multiple log entries, the number of entries for the potential field "cookie" in those multiple entries is counted as 1; if the value corresponding to the potential field "id" appears three times in multiple log entries, the number of entries for the potential field "id" in those multiple entries is counted as 3.
[0077] For example, in an embodiment of the present invention, for each application, each potential field in the temporary list is traversed, and the potential field is used as an aggregation field to perform an aggregation query on the temporary list to obtain the total number of aggregate query results for each potential field.
[0078] S1024. Determine the number of times a user has successfully logged in from the login log.
[0079] For example, the login return value in the login log can be used to determine whether the user has successfully logged in, and the number of successful login log entries can be used as the number of times the user has successfully logged in.
[0080] For example, in some embodiments of the present invention, step S1024 above includes the following sub-steps:
[0081] 1. Process the logs one by one according to the data flow order and filter out the login logs.
[0082] For example, logs are retrieved one by one from the message queue in the order of the data flow in the aforementioned embodiment for processing, and it is determined whether the log is a login log.
[0083] For example, using the login field as a keyword (e.g., login), a regular expression rule is created and stored in a login regular expression library. The regular expression rules in this library are used to perform regular expression matching on the URL field in the log. If the keyword is matched in the URL field of the log, the log is determined to be a login log. Otherwise, the matching continues to the next log.
[0084] 2. Determine whether the login was successful based on the login return value returned by the server in the login log.
[0085] When a user successfully logs in, the server returns a login return value to the application and records it in the corresponding field of the login log. For example, the field used to store the login return value is "code". The server checks whether the value of the "code" field in the login log is 200. If it is, the login was successful; otherwise, the login failed.
[0086] 3. Count the number of successful login log entries as the number of times a user has successfully logged in.
[0087] In this embodiment of the invention, the number of login log entries for successful logins is taken as the number of times a user successfully logs in.
[0088] S1025. Use the potential field that matches the number of records with the number of times a user has successfully logged in as the target field for storing the user's temporary identifier.
[0089] In this embodiment of the invention, a potential field whose number of entries matches the number of successful logins by the user is used as the target field for storing the user's temporary identifier. For example, in this embodiment, "matching" means that the number of entries in the target field is equal to or very close to the number of successful logins.
[0090] Specifically, if the log contains a temporary user identifier used as the basis for user login, the temporary user identifier will not change until the user logs in again or the current login expires. Therefore, the total number of records for each potential field is aggregated through aggregate query, and the total number of records for the target field used to store the temporary user identifier is close to the number of times the user has successfully logged in.
[0091] S103. Determine the correspondence between usernames and temporary user identifiers from the login logs.
[0092] The login log records the username used by the user when logging in, as well as the temporary user identifier returned by the server. Therefore, the correspondence between the username and the temporary user identifier can be determined from the login log.
[0093] As mentioned earlier, since it is unclear which field to use to store the user's temporary identifier, it is necessary to filter from the login logs.
[0094] For example, step S103 above includes the following sub-steps:
[0095] S1031. Process the logs one by one according to the data flow order and filter out the login logs.
[0096] For example, logs are retrieved one by one from the message queue in the order of the data flow in the aforementioned embodiment for processing, and login logs are filtered out. For example, a regular expression rule is established using the login field as a keyword (e.g., login), and stored in a login regular expression library. The regular expression rules of the login regular expression library are used to perform regular expression matching on the URL field in the log. If the keyword is matched in the URL field of the log, the log is determined to be a login log. If not, the matching continues to the next log.
[0097] S1032. Determine the target login log for successful login based on the login return value returned by the server in the login log.
[0098] When a user successfully logs in, the server returns a login return value to the application and records it in the corresponding field of the login log. For example, the field used to store the login return value is "code". The server checks whether the value of the "code" field in the login log is 200. If it is, it means that the login was successful and the log entry is recorded as the target login log entry for successful login. If not, it means that the login failed.
[0099] S1033. Determine the username of the user login from the request body of the target login log.
[0100] The username of the user is determined from the request body of the successful login log. For example, a regular expression rule is created using the field storing the username as a keyword (e.g., user or name) and stored in a regular expression library. The request body is then matched using the regular expression rules in the library to identify fields containing the keyword, and the value of that field is used as the username when the user logs in.
[0101] S1034. Determine potential temporary user identifiers from the response body of the target login log.
[0102] Potential temporary user identifiers are determined from the response body of the successful login log. For example, in some embodiments of the invention, regular expression matching can be used to identify potential fields for storing temporary user identifiers from the response body of the successful login log, and the values corresponding to these fields can be used as potential temporary user identifiers. In another embodiment of the invention, an exclusion method can also be used to determine potential temporary user identifiers. Specifically, the values of all fields in the response body of the target login log are iterated, and values with a length greater than a preset number of characters are used as potential temporary user identifiers. For example, all return values greater than 20 characters in the response body of the target login log are used as potential temporary user identifiers.
[0103] S1035. Establish a mapping relationship between usernames and potential temporary user identifiers.
[0104] After obtaining the username and potential temporary user ID from the target login log of a successful login, a mapping relationship is established between the username and the potential temporary user ID. For example, the request body in the target login log is:
[0105] {"user_name":"admin","pass":"xxxxxxxxxxxxxxxx"};
[0106] The response body is:
[0107] {"ssid":"ssid_asfgk45dgv85vcx14","token":"as1f6481gb654186ytgbfb",
[0108] "path":" / home","type":"1"}.
[0109] The above two sets of data will first match the user_name in the request body to generate a key-value pair {"admin":[]}. Then, they will retrieve all values longer than 20 characters from the response body to generate an array. Since the values of path and type are less than 20 characters, they will not be retrieved. That is, the following array will be generated:
[0110] {"admin":["ssid_asfgk45dgv85vcx14","as1f6481gb654186ytgbfb"]};
[0111] If the log contains multiple logged-in users, this comparison will be automatically accumulated, such as:
[0112] {"admin":["ssid_asfgk45dgv85vcx14","as1f6481gb654186ytgbfb"],
[0113] "test_user":["ssid_a748153v4c8v4ccc","wfag643184164aas1d6as5"],
[0114] "dept_test":["ssid_agjp74861518sa8asf","hbcxv41631518541882sss"]}.
[0115] S104. Based on the comparison relationship, write the username corresponding to the user temporary identifier stored in the target field into the usage log.
[0116] In this embodiment of the invention, based on the comparison relationship, the username corresponding to the temporary user identifier stored in the target field is written into the usage log. For example, using the temporary user identifier corresponding to the target field as an index, the system searches the above comparison relationship to see if there is a matching temporary user identifier, and writes the username corresponding to the temporary user identifier in the comparison relationship into the usage log, thereby assigning the log entry to the corresponding user.
[0117] For example, when writing usernames, a key-value pair format is used. The username corresponding to the temporary user identifier stored in the target field is written to a fixed preset field, and the preset field and the username corresponding to the preset field are written to the usage log. By writing the username corresponding to the temporary user identifier stored in the target field to a fixed preset field, the username can be found based on the fixed preset field, avoiding the problem of inconsistency caused by different applications using different fields for storage.
[0118] For example, a log entry might look like this:
[0119] {"token":"as1f6481gb654186ytgbfb","path":" / api / home","mod":"gsa1354xv18"…………};
[0120] The target field corresponds to the value as1f6481gb654186ytgbfb. Using as1f6481gb654186ytgbfb, the system iterates through the mapping between usernames and potential temporary user identifiers. It finds that as1f6481gb654186ytgbfb exists and the corresponding username is admin. Therefore, "user_name" is used as the default field for storing usernames. This default field and the corresponding username are written to this log entry.
[0121] {"token":"as1f6481gb654186ytgbfb","user_name":"admin","path":" / api / home","mod":"gsa1354xv18"…………}.
[0122] Because different applications may use different fields to store usernames in the login log, in some embodiments of the present invention, in order to facilitate the retrieval of usernames in the login fields, a preset field and the username corresponding to the preset field are also written into the login log.
[0123] The method for writing a username to a gateway log provided in this embodiment of the invention includes: obtaining the gateway log of a target application, the gateway log including login log and usage log, the usage log being the log generated by a user using the target application after logging in; determining a target field for storing a user's temporary identifier from the gateway log; determining the mapping relationship between the username and the user's temporary identifier from the login log; and, based on the mapping relationship, writing the username corresponding to the user's temporary identifier stored in the target field into the usage log, thereby assigning the gateway log to the corresponding user and improving the analysis efficiency of subsequent log analysis.
[0124] Figure 2 This is a schematic diagram of a device for writing usernames to a gateway log according to an embodiment of the present invention, as shown below. Figure 2 As shown, the device for writing usernames to the gateway log includes:
[0125] Gateway log acquisition module 201 is used to acquire gateway logs of the target application. The gateway logs include login logs and usage logs. The usage logs are logs generated when a user logs in and uses the target application.
[0126] The target field determination module 202 is used to determine the target field for storing the user's temporary identifier from the gateway log;
[0127] The mapping relationship determination module 203 is used to determine the mapping relationship between the username and the temporary user identifier from the login log;
[0128] Username writing module 204 is used to write the username corresponding to the user temporary identifier stored in the target field into the usage log based on the comparison relationship.
[0129] In some embodiments of the present invention, the target field determination module 202 includes:
[0130] The normalization processing submodule is used to normalize the gateway logs to obtain a data stream including multiple logs;
[0131] The potential field determination submodule is used to process the logs one by one in the order of the data stream to determine potential fields for storing temporary user identifiers from multiple logs;
[0132] The record count submodule is used to count the number of records for each of the aforementioned potential fields. Among them, the same potential field with the same value is counted as one record, and the same potential field with different values is counted separately.
[0133] The successful login count determination submodule is used to determine the number of times the user has successfully logged in from the login log;
[0134] The target field determination submodule is used to select potential fields whose number of entries matches the number of times the user has successfully logged in as target fields for storing the user's temporary identifier.
[0135] In some embodiments of the present invention, the potential field determination submodule includes:
[0136] The matching unit is used to perform regular expression matching on the request headers in the log using multiple regular expression rules that include potential fields as keywords, and to match potential fields used to store temporary user identifiers from the logs.
[0137] The temporary list creation unit is used to store the potential fields of multiple log entries and their corresponding values into a temporary list.
[0138] In some embodiments of the present invention, the count module includes:
[0139] The aggregation query unit is used to traverse each potential field in the temporary list, use the potential field as the aggregation field to perform an aggregation query on the temporary list, and obtain the total number of aggregation query results for each potential field.
[0140] In some embodiments of the present invention, the successful login count determination submodule includes:
[0141] The login log filtering unit is used to process the logs one by one according to the order of the data stream and filter out the login logs.
[0142] The login success determination unit is used to determine whether the login was successful based on the login return value returned by the server in the login log;
[0143] The login count statistics unit is used to count the number of successful login log entries as the number of times the user has successfully logged in.
[0144] In some embodiments of the present invention, the login log filtering unit includes:
[0145] The matching subunit is used to perform regular expression matching on the URL field in the log, including the login keyword, to extract the login log.
[0146] In some embodiments of the present invention, the comparison relationship determination module 203 includes:
[0147] The login log filtering submodule is used to process the logs one by one according to the order of the data stream and filter out the login logs.
[0148] The target login log determination submodule is used to determine the target login log for successful login based on the login return value returned by the server in the login log;
[0149] The username determination submodule is used to determine the username of the user login from the request body of the target login log;
[0150] A potential user temporary identifier determination submodule is used to determine potential user temporary identifiers from the response body of the target login log;
[0151] The mapping relationship establishment submodule is used to establish the mapping relationship between the username and the potential temporary user identifier.
[0152] In some embodiments of the present invention, the potential user temporary identifier determination submodule includes:
[0153] The traversal unit is used to traverse the values of all fields in the response body of the target login log;
[0154] A potential user temporary identifier determination unit is used to determine a value with more than a preset number of bits as a potential user temporary identifier.
[0155] In some embodiments of the present invention, the username writing module 204 includes:
[0156] The judgment submodule is used to determine whether the user temporary identifier corresponding to the target field exists in the mapping relationship between the username and potential user temporary identifiers;
[0157] The username writing submodule is used to determine the username corresponding to the temporary user identifier based on the mapping relationship between the username and potential temporary user identifiers when the temporary user identifier corresponding to the target field exists in the mapping relationship between the username and potential temporary user identifiers, and write the username to the usage log.
[0158] In some embodiments of the present invention, based on the aforementioned comparison relationship, the username writing module 204 further includes:
[0159] The first writing submodule is used to write the username corresponding to the user temporary identifier stored in the target field into a fixed preset field;
[0160] The second writing submodule is used to write the preset field and the username corresponding to the preset field into the login log and the usage log.
[0161] The aforementioned apparatus for writing usernames to the gateway log can execute the method for writing usernames to the gateway log provided in the foregoing embodiments of the present invention, and has the corresponding functional modules and beneficial effects for executing the method of writing usernames to the gateway log.
[0162] Figure 3 This is a schematic diagram of an electronic device provided for an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0163] like Figure 3 As shown, the electronic device includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded into the RAM 13 from storage unit 18. The RAM 13 can also store various programs and data required for the operation of the electronic device. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0164] Multiple components in the electronic device are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, optical disk, etc.; and a communication unit 19, such as a network card, modem, wireless transceiver, etc. The communication unit 19 allows the electronic device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0165] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the method of writing a username to a gateway log.
[0166] In some embodiments, the method of writing a username to the gateway log can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on an electronic device via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the method of writing a username to the gateway log described above can be performed. Alternatively, in other embodiments, processor 11 can be configured by any other suitable means (e.g., by means of firmware) to perform the method of writing a username to the gateway log.
[0167] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0168] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0169] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0170] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0171] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0172] A computing system can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system. It addresses the shortcomings of traditional physical hosts and VPS (Virtual Private Server) services, such as high management difficulty and weak business scalability.
[0173] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method of writing usernames to a gateway log as provided in any embodiment of this application.
[0174] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0175] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0176] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for writing usernames to a gateway log, characterized in that, include: Obtain the gateway logs of the target application, which include login logs and usage logs, wherein the usage logs are the logs generated by the user after logging in and using the target application; Determine the target field for storing the user's temporary identifier from the gateway log; Determine the mapping relationship between the username and the user's temporary identifier from the login log; Based on the aforementioned comparison relationship, the username corresponding to the temporary user identifier stored in the target field is written into the usage log; The target field for storing the user's temporary identifier is determined from the gateway log, including: The gateway logs are normalized to obtain a data stream containing multiple logs; Logs are retrieved one by one from the message queue in the order of the data stream and processed. Potential fields for storing temporary user identifiers are determined from multiple logs. The message queue is used to store logs in the data stream. Count the number of records for each of the potential fields, where the same potential field with the same value is counted as one record, and the same potential field with different values is counted separately. The number of times the user successfully logged in is determined from the login logs; Potential fields whose number of entries matches the number of times the user has successfully logged in are used as target fields for storing temporary user identifiers.
2. The method for writing usernames to the gateway log according to claim 1, characterized in that, The logs are processed sequentially according to the data stream, and potential fields for storing temporary user identifiers are identified from multiple log entries, including: Multiple regular expression rules, including potential fields as keywords, are used to perform regular expression matching on the request headers in the logs to identify potential fields used to store temporary user identifiers. Store the potential fields of multiple log entries and their corresponding values in a temporary list.
3. The method for writing usernames to the gateway log according to claim 2, characterized in that, Count the number of records for each of the aforementioned potential fields, including: Iterate through each potential field in the temporary list, and use that potential field as an aggregation field to perform an aggregation query on the temporary list to obtain the total number of aggregate query results for each potential field.
4. The method for writing usernames to the gateway log according to claim 1, characterized in that, Determining the number of times the user successfully logged in from the login log includes: The logs are processed one by one according to the order of the data stream to filter out the login logs; The success of the login is determined based on the login return value returned by the server in the login log; The number of successful login log entries is counted as the number of times the user has successfully logged in.
5. The method for writing usernames to the gateway log according to claim 4, characterized in that, The logs are processed sequentially according to the data stream to filter out login logs, including: Regular expression rules including login keywords are used to perform regular expression matching on the URL field in the logs to extract login logs.
6. The method for writing usernames to the gateway log according to any one of claims 1-5, characterized in that, Determining the mapping relationship between usernames and temporary user identifiers from the login logs includes: The logs are processed one by one according to the data flow order to filter out the login logs; The target login log for successful login is determined based on the login return value returned by the server in the login log. Determine the username of the user who logged in from the request body of the target login log; Identify potential temporary user identifiers from the response body of the target login log; Establish a mapping relationship between the username and potential temporary user identifiers.
7. The method for writing usernames to the gateway log according to claim 6, characterized in that, Determine potential temporary user identifiers from the response body of the target login log, including: Iterate through the values of all fields in the response body of the target login log; Values with a length greater than a preset number of bits are used as potential temporary user identifiers.
8. The method for writing usernames to the gateway log according to claim 6, characterized in that, Based on the aforementioned correspondence, the username corresponding to the temporary user identifier stored in the target field is written into the usage log, including: Determine whether the user temporary identifier corresponding to the target field exists in the mapping relationship between the username and potential user temporary identifiers; If so, the username corresponding to the temporary user identifier is determined based on the comparison relationship, and the username is written into the usage log.
9. The method for writing usernames to the gateway log according to any one of claims 1-5, characterized in that, Based on the aforementioned comparison relationship, the user name corresponding to the temporary user identifier stored in the target field is written into the usage log, and the method further includes: Write the username corresponding to the temporary user identifier stored in the target field into a fixed preset field; Write the preset field and the corresponding username into the login log and the usage log.
10. An apparatus for writing usernames to a gateway log, characterized in that, include: The gateway log acquisition module is used to acquire the gateway logs of the target application. The gateway logs include login logs and usage logs. The usage logs are the logs generated when a user logs in and uses the target application. The target field determination module is used to determine the target field for storing the user's temporary identifier from the gateway log; The mapping relationship determination module is used to determine the mapping relationship between the username and the user's temporary identifier from the login log; The username writing module is used to write the username corresponding to the temporary user identifier stored in the target field into the usage log based on the comparison relationship; The target field determination module includes: The normalization processing submodule is used to normalize the gateway logs to obtain a data stream including multiple logs; The potential field determination submodule is used to process the logs one by one from the message queue in the order of the data stream, and determine potential fields for storing temporary user identifiers from multiple logs, wherein the message queue is used to store logs in the data stream; The record count submodule is used to count the number of records for each of the aforementioned potential fields. Among them, the same potential field with the same value is counted as one record, and the same potential field with different values is counted separately. The successful login count determination submodule is used to determine the number of times the user has successfully logged in from the login log; The target field determination submodule is used to select potential fields whose number of entries matches the number of times the user has successfully logged in as target fields for storing the user's temporary identifier.
11. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method of writing usernames to the gateway log as described in any one of claims 1-9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the method of writing usernames to the gateway log as described in any one of claims 1-9.
Citation Information
Patent Citations
Log management method and device, electronic equipment and readable storage medium
CN112069425A