Internet of Things equipment log information query method and device, storage medium and electronic device
By hashing and bucket allocation of IoT device logs according to their keywords, the query complexity problem caused by the dispersed storage of device logs in the prior art is solved, and efficient log query is achieved.
Patent Information
- Application Number
- CN202411773136.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-04-25
AI Technical Summary
In the prior art, the device log is stored scatterly according to the server IP address as an index, resulting in huge spatial and temporal complexity of querying the specified keyword log in the device log.
By obtaining the first device log of the IoT device and using its keywords to perform hash calculations, the bucket identity of the target bucket is determined, and the logs are stored in the target bucket among multiple buckets. After receiving the query request, the second device log is queried from the target bucket through the keyword.
It realizes the technical effect of fast, efficient and concise querying device logs, reducing the spatial complexity and time complexity during query.
Smart Images

Figure CN119884036A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home technology, and more specifically, to a method and device for querying log information of an Internet of Things device, a storage medium, and an electronic device. Background Art
[0002] In the field of smart home, massive devices upload a large amount of log data every day, and the data of all user devices are mixed together. When you need to retrieve log data of a certain keyword (for example, device ID), you often need to extract all records containing the device ID from the massive logs, then aggregate the logs, and finally retrieve some key data you need.
[0003] According to the query scenario for a specific ID (for example, device ID), logs are currently stored in a dispersed manner with the server IP address as the index, and there is a problem that the results are dispersed in multiple log streams. To query data for a specified keyword, it is necessary to pull all streamlined logs within the time period for query. Taking the amount of device status change data as an example, assume that there are 50 index log streams and an average log stream of 200MB / h. Therefore, a query of 1h requires filtering 10GB of logs, which is a huge amount of data.
[0004] In the related art, device logs are stored in a dispersed manner according to the server IP address as the index, which leads to huge space complexity and time complexity for querying the specified keyword logs in the device logs. No effective solution has been proposed yet.
[0005] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the invention
[0006] The embodiments of the present application provide a method and device, storage medium and electronic device for querying IoT device log information, so as to at least solve the problem in the related art that device logs are dispersedly stored according to the server IP address as the index, resulting in huge space complexity and time complexity for querying the specified keyword log in the device log.
[0007] According to one aspect of an embodiment of the present application, a method for querying IoT device log information is provided, including: obtaining a first device log of an IoT device, storing the first device log using a keyword in the first device log, wherein a query request for querying the device log stored using the keyword includes the keyword; receiving the query request, and querying a second device log from a target storage bucket using the keyword.
[0008] In an exemplary embodiment, storing the first device log using a keyword in the first device log includes: performing a hash calculation on the keyword to obtain a hash value of the keyword; determining a bucket identifier of the target storage bucket using the hash value; and storing the first device log in the target storage bucket among multiple storage buckets using the bucket identifier.
[0009] In an exemplary embodiment, storing the first device log in the target storage bucket among multiple storage buckets through the bucket identifier includes: performing a processing operation on the tag of the first device log to obtain a third device log; and storing the third device log in the target storage bucket.
[0010] In an exemplary embodiment, a processing operation is performed on the label of the first device log to obtain a third device log, including: adding a first field in the label of the first device log after a text line of the first device log; adding a second field to the label, wherein the second field is determined by the keyword; deleting the remaining fields except the third field in the label to which the second field is added to obtain the label after performing the processing operation, wherein the third field includes: the second field; and determining the third device log by the label after performing the processing operation.
[0011] In an exemplary embodiment, querying the second device log from the target storage bucket through the keyword includes: determining the bucket identifier of the target storage bucket through the hash value corresponding to the keyword; generating an index query statement through the bucket identifier, and obtaining the index record corresponding to the index query statement; generating an original log query statement through the index record to obtain the second device log.
[0012] In an exemplary embodiment, determining the bucket identifier of the target bucket by using the hash value corresponding to the keyword includes: determining whether the quantity of multiple buckets changes, wherein the multiple buckets include: the target bucket; in case the quantity changes, determining the bucket identifier by using the hash value and the quantity after the change; in case the quantity does not change, determining the bucket identifier by using the hash value and the quantity before the change.
[0013] In an exemplary embodiment, after querying the second device log from the target storage bucket through the keyword, the method also includes: determining a query speed for querying the second device log; when the query speed is less than a preset query speed, increasing the number of multiple storage buckets, wherein the multiple storage buckets include: the target storage bucket.
[0014] According to another aspect of an embodiment of the present application, a device for querying IoT device log information is also provided, including: a storage module, used to obtain a first device log of an IoT device, and store the first device log using a keyword in the first device log, wherein a query request for querying the device log stored using the keyword includes the keyword; a query module, used to receive the query request, and query a second device log from a target storage bucket using the keyword.
[0015] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned method for querying log information of an Internet of Things device when running.
[0016] According to another aspect of an embodiment of the present application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for querying log information of an IoT device through the computer program.
[0017] According to another aspect of the embodiments of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the method for querying log information of an Internet of Things device is implemented.
[0018] Through the present application, the first device log of the IoT device is obtained, and the first device log is stored by the keyword in the first device log, wherein the query request for querying the device log stored by the keyword includes the keyword; the query request is received, and the second device log is queried from the target storage bucket by the keyword. That is to say, by storing the first device log to be stored according to the keyword in the first device log, the second device log can be queried from the target storage bucket by the keyword when a query request for the second device log with the keyword is received. Therefore, the above technical solution is adopted to solve the problem in the related technology that the device logs are dispersedly stored according to the server IP address as the index, resulting in huge space complexity and time complexity for querying the specified keyword log in the device log; and the technical effect of fast, efficient and concise query of the device log is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0021] Figure 1 It is a hardware environment diagram of an optional method for querying log information of an Internet of Things device according to an embodiment of the present application;
[0022] Figure 2 It is a flowchart of an optional method for querying log information of an Internet of Things device according to an embodiment of the present application;
[0023] Figure 3 This is a schematic diagram of an index log of an optional method for querying log information of an Internet of Things device according to an embodiment of the present application;
[0024] Figure 4 1 is a log query schematic diagram (I) of an optional method for querying log information of an IoT device according to an embodiment of the present application;
[0025] Figure 5 This is a log query schematic diagram (II) of an optional method for querying log information of an IoT device according to an embodiment of the present application;
[0026] Figure 6 It is a structural block diagram of an optional device for querying log information of an Internet of Things device according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] According to one aspect of the embodiments of the present application, a method for querying log information of an Internet of Things device is provided. The method for querying log information of an Internet of Things device is widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (IntelligenceHouse) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above-mentioned method for querying log information of an Internet of Things device can be applied to Figure 1 In the hardware environment shown in FIG. 1 , a plurality of terminal devices 102 and a server 104 are formed. Figure 1 As shown, the server 104 is connected to multiple terminal devices 102 via a network, and can be used to provide services (such as application services, etc.) for the terminals or clients installed on the terminals. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0030] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0031] In this embodiment, a method for querying log information of an IoT device is provided, including but not limited to being applied to a terminal device. Figure 2 : is a flowchart of a method for querying log information of an IoT device according to an embodiment of the present application, and the process includes the following steps:
[0032] Step S202: obtaining a first device log of an IoT device, and storing the first device log by using a keyword in the first device log, wherein a query request for querying the device log stored by using the keyword includes the keyword;
[0033] Step S204: receiving the query request, and querying the second device log from the target storage bucket using the keyword.
[0034] Optionally, the execution order of step S202 and step S204 is not limited in the embodiment of the present application. The second device log may include the first device log, or may not include the first device log. When a query request is received but the device log does not exist in the target storage bucket, an error query is fed back to the initiator of the query request to determine whether the query request is sent incorrectly.
[0035] Through the above steps, the first device log of the IoT device is obtained, and the first device log is stored by the keyword in the first device log, wherein the query request for querying the device log stored by the keyword includes the keyword; the query request is received, and the second device log is queried from the target storage bucket by the keyword. That is to say, by storing the first device log to be stored according to the keyword in the first device log, the second device log can be queried from the target storage bucket by the keyword when a query request for the second device log with the keyword is received. Therefore, the above technical solution is adopted to solve the problem in the related technology that the device log is dispersedly stored according to the server IP address as the index, resulting in huge space complexity and time complexity for querying the specified keyword log in the device log; and the technical effect of fast, efficient and concise query of the device log is achieved.
[0036] In an exemplary embodiment, storing the first device log using a keyword in the first device log includes: performing a hash calculation on the keyword to obtain a hash value of the keyword; determining a bucket identifier of the target storage bucket using the hash value; and storing the first device log in the target storage bucket among multiple storage buckets using the bucket identifier.
[0037] Optionally, the keywords in the first device log may include: device ID (deviceId) of the smart home device, etc.
[0038] The hash value of the keyword can be obtained by performing hash calculation on the keyword, which can be at least three ways: xxhash, sha1, and md5. The hash value of the keyword uniquely corresponds to a target storage bucket in multiple storages, and the target storage bucket is dedicated to storing the first device log with the keyword obtained from the smart home device. The hash value of the keyword is bound to the bucket identifier of the target storage bucket.
[0039] It should be noted that xxHash, SHA-1 and MD5 are three different hash algorithms, each of which calculates hash values in a unique way. The following briefly introduces the principles of these three algorithms and how to calculate hash values:
[0040] 1) xxHash:
[0041] xxHash is a non-cryptographic hash algorithm known for its high speed and high hash quality. The basic steps to calculate the hash value include: the input data is divided into blocks of fixed size. Each block is processed through a pseudo-random function to produce an intermediate value. These intermediate values are combined with the initial hash value (usually a random seed) and the entire input data is processed iteratively. Finally, the remaining unfull block data and the overall data length are processed to obtain the final hash value.
[0042] 2) SHA-1:
[0043] SHA-1 (Secure Hash Algori thm 1) is a secure hash algorithm used to generate a 160-bit (20-byte) hash value. Its calculation steps include: preprocessing the input message, including padding and adding the message length. Dividing the preprocessed message into 512-bit blocks. Performing a hash function once for each block, the function includes four rounds of iterative processing, each of which includes a series of bit operations and mathematical operations. The final hash value is the result of processing all blocks.
[0044] 3) MD5
[0045] MD5 (Message-Digest Algorithm 5) is another widely used non-cryptographic hash algorithm that is used to generate a 128-bit (16-byte) hash value. Its calculation steps are similar to SHA-1, but different operations and rounds are used, including: the input message is pre-processed, including padding and adding the message length, just like SHA-1. The message is split into 512-bit blocks. Each block is processed through four rounds, each of which includes 16 sub-processes, and each sub-processing includes a series of bit operations and mathematical operations. The final hash value is the result of all block processing.
[0046] The specific implementation details of these hash algorithms, such as bit operations, constant usage, initial value setting, etc., are relatively complex, and usually refer to the corresponding algorithm standards and literature when implementing them. In practical applications, such as using these algorithms in programming, they usually call existing library functions or use language built-in hash functions, such as Python's `hashlib` library, Java's `MessageDigest` class, etc., to generate hash values.
[0047] It should be noted that although SHA-1 and MD5 were once widely used, they are now mainly used in non-security scenarios, such as data integrity verification, due to known security vulnerabilities. For applications with higher security requirements, more modern and more secure hash algorithms, such as SHA-256 or SHA-3, should be used.
[0048] In some optional embodiments, storing the first device log in the target storage bucket among multiple storage buckets through the bucket identifier includes: performing a processing operation on the tag of the first device log to obtain a third device log; and storing the third device log in the target storage bucket.
[0049] Furthermore, a processing operation is performed on the label of the first device log to obtain a third device log, including: adding the first field in the label of the first device log after the text line of the first device log; adding the second field to the label, wherein the second field is determined by the keyword; deleting the remaining fields except the third field in the label to which the second field is added to obtain the label after performing the processing operation, wherein the third field includes: the second field; and determining the third device log by the label after performing the processing operation.
[0050] Among them, the first field in the label of the first device log is added after the text line of the first device log, for example: the IP value in the label of the first device log (the IP of the smart home device or the home where the smart home device is located, or the gateway to which the smart home device belongs, equivalent to the first field) is added after the text line of the first device log.
[0051] A second field is added to the label, wherein the second field is determined by the keyword; for example, index_name = "deviceId" is added to the label. In addition, the remaining fields except the third field in the label to which the second field is added are deleted to obtain the label after the processing operation is performed, for example, only the following are retained in the label, and the rest are deleted: 1) app_name (the name of the application to which the first device log belongs); 2) format (the format of the first device log); 3) bucket_count (the number of the first device log); 4) bucket_id (the bucket ID to which the first device log belongs); 5) index_name (the index name to which the first device log belongs).
[0052] In an exemplary embodiment, querying the second device log from the target storage bucket through the keyword includes: determining the bucket identifier of the target storage bucket through the hash value corresponding to the keyword; generating an index query statement through the bucket identifier, and obtaining the index record corresponding to the index query statement; generating an original log query statement through the index record to obtain the second device log.
[0053] Among them, the index query statement generated by the bucket identifier is as follows:
[0054] {app_name="xxx", bucket_id="7", format="extracted", index_name="deviceId"}|="12345678";
[0055] The time range of the above index query statement is the entire query range, and bucket_id represents the bucket identifier. The set of index records obtained by the index query statement is as follows: Figure 3 shown.
[0056] Then, the original log query statement is generated through the index record, including: Figure 3 Take the first line of records in as an example, the time range is accurate to the moment, and the original log query statement is:
[0057] {app_name="xxx",format="raw",pod_id="192.168.0.100"}|="12345678";
[0058] In an exemplary embodiment, determining the bucket identifier of the target bucket by using the hash value corresponding to the keyword includes: determining whether the quantity of multiple buckets changes, wherein the multiple buckets include: the target bucket; in case the quantity changes, determining the bucket identifier by using the hash value and the quantity after the change; in case the quantity does not change, determining the bucket identifier by using the hash value and the quantity before the change.
[0059] It is understandable that the number of buckets should be a power of 2. If the number of buckets changes, for example, from 64 to 128, the corresponding bucket identifier will also change. In order to correctly query the device log after the number of buckets changes, it is necessary to determine the bucket identifier by combining the hash value calculated by the keyword and the number of buckets before and after the change. Specifically, when the number has not changed, the bucket identifier is obtained by taking the remainder of the number before the change through the hash value; when the number has changed, the remainder of the number after the change is taken through the hash value. If the remainder obtained is greater than the number before the change, it should be written as bucket_id = ~ "remainder|(remainder-number before change)". For example, if the remainder is 79, the matching condition bucket_id = "79" should be written as bucket_id = ~ "79|15".
[0060] In an exemplary embodiment, after querying the second device log from the target storage bucket through the keyword, the method also includes: determining a query speed for querying the second device log; when the query speed is less than a preset query speed, increasing the number of multiple storage buckets, wherein the multiple storage buckets include: the target storage bucket.
[0061] Obviously, the above-described embodiments are only part of the embodiments of the present application, not all of the embodiments. In order to better understand the above-mentioned method for querying the log information of IoT devices, the above-mentioned process is described below in conjunction with the embodiments, but it is not intended to limit the technical solutions of the embodiments of the present application, specifically:
[0062] According to the query scenario for a specific ID, the current decentralized storage of logs with the server IP address as the index has the problem of scattered results in multiple log streams. To query data for a specified keyword, you need to pull all the streamlined logs within the time period for query. Taking the amount of device status change data as an example, assume that there are 50 index log streams and an average of 200MB / h log streams. Therefore, a query of 1 hour requires filtering 10GB of logs, and the data volume is huge. Figure 4 shown.
[0063] To solve the problem of keyword log query, the general technical solution is to extract certain key fields from the original log to form a new log, and then add additional tags (such as adding a label format = extracted) as a new log stream. However, since the data of the same keyword is retrieved from logs in different data storage units, integrating this data requires a large number of aggregation operations, and the space complexity and time complexity are also huge.
[0064] The embodiment of the present application changes the log stream organization mode, such as Figure 5 As shown in the figure, the original file (IP) segmentation is replaced by keyword Hash (i.e. hash value) segmentation Bucket (i.e. storage bucket), and IP is used as the text content of the simplified log stream. Therefore, logs with the same keyword will only be sent to the same log stream. When querying, the keyword is Hash modulo, and only one log stream is queried. The amount of filtered logs is reduced according to the number of segmented Buckets. You can refer to the query speed to adjust the number of Buckets.
[0065] In addition to the keywords, a bucket_count, that is, the number of buckets (that is, the number of multiple storage buckets in the above embodiment) needs to be determined, which must be a power of 2 (such as 16, 32, 256, etc.).
[0066] The following operations are performed when collecting simplified logs, taking deviceId as an example:
[0067] The log (equivalent to the first device log in the above embodiment) text filters out the logs that do not contain the deviceId, and only retains the character string containing the deviceId.
[0068] Perform hash calculation on the deviceId string (currently supports xxhash, sha1, and md5)
[0069] The hash value modulo bucket_count is used as bucket_id.
[0070] Append the IP value in the original log label (label, which is the key information or label used to identify and classify logs) to the end of the log text line, separated by a space and deviceId.
[0071] Add index_name="deviceId" to label.
[0072] Only the following labels are retained, and the rest are deleted: app_name (name of the application to which the log belongs), format (log format), bucket_count (number of logs), bucket_id (bucket ID to which the log belongs), index_name (index name to which the log belongs).
[0073] The query is performed according to the following process, taking deviceId = 1234 as an example:
[0074] Step 1: Calculate the hash of the deviceId string (note that the encoding needs to be consistent with that during collection), take the modulus of bucket_count, and get bucket_id (assuming it is 7).
[0075] Step 2: Generate an index query statement, and the time range is the entire query range: {app_name = "xxx", bucket_id = "7", format = "extracted", index_name = "deviceId"} | = "12345678".
[0076] Step 3: Query to obtain a set of index records, such as Figure 3 shown.
[0077] Step 4: Generate a series of raw log query statements. Take the first line of records as an example. The time range is accurate to the moment: {app_name = "xxx", format = "raw", pod_id = "192.168.0.100"} | = "12345678".
[0078] It should be noted that if bucket_count changes at a certain moment, generally due to reasons such as increasing speed, bucket_count will be increased (for example, 64->128), and the corresponding bucket_id will also change. In order to correctly query the records of the time on both sides of the switching bucket count, the bucket_id here needs to match two values. If the calculated bucket_id after the switch is greater than the old bucket_count (assuming it is 79), the matching condition bucket_id = "79" should be written as bucket_id = ~ "79|15"
[0079] In summary, the embodiment of the present application provides a solution for segmenting and storing logs based on keywords. The Hash+bucket method allows data that need to be stored in a distributed manner to be stored in the same bucket, and data queries only need to query one bucket to obtain all relevant data. Furthermore, the embodiment of the present application solves the keyword query efficiency problem of massive logs with minimal time complexity and space complexity by using the Hash+bucket storage method.
[0080] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0081] In this embodiment, a device for querying log information of an IoT device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0082] Figure 6 It is a structural block diagram of an optional device for querying log information of an Internet of Things device according to an embodiment of the present application, and the device includes:
[0083] A storage module 62, configured to obtain a first device log of an IoT device, and store the first device log using a keyword in the first device log, wherein a query request for querying the device log stored using the keyword includes the keyword;
[0084] The query module 64 is configured to receive the query request and query the second device log from the target storage bucket using the keyword.
[0085] Through the above-mentioned device, the first device log of the IoT device is obtained, and the first device log is stored through the keyword in the first device log, wherein the query request for querying the device log stored through the keyword includes the keyword; the query request is received, and the second device log is queried from the target storage bucket through the keyword. That is to say, by storing the first device log to be stored according to the keyword in the first device log, the second device log can be queried from the target storage bucket through the keyword when a query request for the second device log with the keyword is received. Therefore, the above-mentioned technical solution is adopted to solve the problem in the related technology that the device log is dispersedly stored according to the server IP address as the index, resulting in huge space complexity and time complexity of querying the specified keyword log in the device log; and the technical effect of fast, efficient and concise query of the device log is achieved.
[0086] In an exemplary embodiment, the storage module 62 is also used to: perform hash calculation on the keyword to obtain a hash value of the keyword; determine the bucket identifier of the target storage bucket through the hash value; and store the first device log in the target storage bucket among multiple storage buckets through the bucket identifier.
[0087] In an exemplary embodiment, the storage module 62 is further configured to: perform a processing operation on the tag of the first device log to obtain a third device log; and store the third device log in the target storage bucket.
[0088] In an exemplary embodiment, the storage module 62 is also used to: add the first field in the label of the first device log after the text line of the first device log; add the second field in the label, wherein the second field is determined by the keyword; delete the remaining fields except the third field in the label to which the second field is added, to obtain the label after executing the processing operation, wherein the third field includes: the second field; and determine the third device log by the label after executing the processing operation.
[0089] In an exemplary embodiment, the query module 64 is also used to: determine the bucket identifier of the target storage bucket through the hash value corresponding to the keyword; generate an index query statement through the bucket identifier, and obtain the index record corresponding to the index query statement; generate an original log query statement through the index record to obtain the second device log.
[0090] In an exemplary embodiment, the query module 64 is also used to: determine whether the quantity of multiple storage buckets has changed, wherein the multiple storage buckets include: the target storage bucket; in the case where the quantity has changed, determine the bucket identifier by the hash value and the quantity after the change; in the case where the quantity has not changed, determine the bucket identifier by the hash value and the quantity before the change.
[0091] In an exemplary embodiment, the query module 64 is also used to: determine the query speed of querying the second device log; when the query speed is less than a preset query speed, increase the number of multiple storage buckets, wherein the multiple storage buckets include: the target storage bucket.
[0092] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0093] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0094] S1, obtaining a first device log of an IoT device, and storing the first device log by using a keyword in the first device log, wherein a query request for querying the device log stored by using the keyword includes the keyword;
[0095] S2, receiving the query request, and querying the second device log from the target storage bucket using the keyword.
[0096] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0097] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0098] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0099] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0100] S1, obtaining a first device log of an IoT device, and storing the first device log by using a keyword in the first device log, wherein a query request for querying the device log stored by using the keyword includes the keyword;
[0101] S2, receiving the query request, and querying the second device log from the target storage bucket using the keyword.
[0102] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0103] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0104] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0105] An embodiment of the present application also provides a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in any one of the above method embodiments.
[0106] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0107] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0108] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for querying log information of an Internet of Things device, characterized in that: include: Obtaining a first device log of an IoT device, and storing the first device log by using a keyword in the first device log, wherein a query request for querying the device log stored by using the keyword includes the keyword; The query request is received, and a second device log is queried from the target storage bucket using the keyword.
2. The method for querying log information of an Internet of Things device according to claim 1, characterized in that: Storing the first device log by using the keyword in the first device log includes: Performing hash calculation on the keyword to obtain a hash value of the keyword; Determine a bucket identifier of the target storage bucket by using the hash value; The first device log is stored in the target storage bucket among the multiple storage buckets according to the bucket identifier.
3. The method for querying log information of an Internet of Things device according to claim 2, characterized in that: Storing the first device log in the target storage bucket among the multiple storage buckets according to the bucket identifier includes: Performing a processing operation on the tag of the first device log to obtain a third device log; The third device log is stored in the target storage bucket.
4. The method for querying log information of an Internet of Things device according to claim 3, characterized in that: Performing a processing operation on the tag of the first device log to obtain a third device log includes: Adding the first field in the tag of the first device log after the text line of the first device log; Adding a second field to the tag, wherein the second field is determined by the keyword; The remaining fields except the third field in the tag to which the second field is added are deleted to obtain the tag after the processing operation is performed, wherein the third field includes: the second field The third device log is determined by the tag after executing the processing operation.
5. The method for querying log information of an Internet of Things device according to claim 1, characterized in that: Querying the second device log from the target storage bucket by using the keyword includes: Determine the bucket identifier of the target storage bucket by using the hash value corresponding to the keyword; Generate an index query statement through the bucket identifier, and obtain an index record corresponding to the index query statement; Generate an original log query statement through the index record to obtain the second device log.
6. The method for querying log information of an Internet of Things device according to claim 5, characterized in that: Determining the bucket identifier of the target storage bucket by using the hash value corresponding to the keyword includes: Determine whether the number of multiple storage buckets changes, wherein the multiple storage buckets include: the target storage bucket; In the case where the quantity changes, determining the bucket identifier by using the hash value and the changed quantity; When the quantity does not change, the bucket identifier is determined by the hash value and the quantity before the change.
7. The method for querying log information of an Internet of Things device according to claim 1, characterized in that: After querying the second device log from the target storage bucket using the keyword, the method further includes: Determine a query speed for obtaining the second device log; In the case where the query speed is lower than a preset query speed, the number of multiple storage buckets is increased, wherein the multiple storage buckets include: the target storage bucket.
8. A device for querying log information of an Internet of Things device, characterized in that: include: A storage module, used for obtaining a first device log of an IoT device, and storing the first device log by using a keyword in the first device log, wherein a query request for querying the device log stored by using the keyword includes the keyword; The query module is used to receive the query request and query the second device log from the target storage bucket using the keyword.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.