Method for converting MQTT message into InfluxDB data, data conversion system and electronic equipment

Through the conversion method of MQTT messages to InfluxDB data, data bridges and conversion modules are used to convert and cache data at edge nodes, which solves the problem of complexity and low efficiency of time series data entry in the Internet of Vehicles, and achieves efficient data entry.

CN118740930APending Publication Date: 2024-10-01NEUSOFT REACH AUTOMOBILE TECH (SHENYANG) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410880184.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

The process of inputting the Internet of Vehicles time series data into the InfluxDB database is complex and inefficient, requiring the cloud to adjust the code to input the time series data in MQTT messages.

Method used

Provides a method of converting MQTT messages to InfluxDB data, establishing a channel through the data bridge module. The data conversion module converts MQTT messages into InfluxDB data according to pre-configured conversion rules, and caches and writes them at the target edge node according to the write strategy. Database, which simplifies the data entry process.

Benefits of technology

It realizes the efficient conversion of MQTT messages into InfluxDB data and directly writes it into the InfluxDB database, which improves the efficiency of time series data entry for the Internet of Vehicles, simplifies the process, and alleviates the problems of complexity and low efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740930A_ABST
    Figure CN118740930A_ABST
Patent Text Reader

Abstract

The invention provides a method for converting an MQTT message into InfluxDB data, a data conversion system and electronic equipment, and in the conversion method, the MQTT message can be efficiently converted into the InfluxDB data, so that the InfluxDB data can be efficiently written into a target InfluxDB server, the purpose of inputting Internet of Vehicles time series data into an InfluxDB database is achieved, and the efficiency of the Internet of Vehicles time series data is improved. The efficiency of inputting the time series data of the Internet of Vehicles into the InfluxDB database is improved, and the data inputting process is simplified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of vehicle networking, and in particular to a method for converting MQTT messages to InfluxDB data, a data conversion system and an electronic device. Background Art

[0002] The time series data of the Internet of Vehicles needs to be entered into the InfluxDB time series database in order to monitor and analyze the time series data of the Internet of Vehicles. At present, the process of entering the time series data of the Internet of Vehicles into the InfluxDB database is very complicated. It is necessary to send the MQTT message to the cloud first, and then the cloud will enter the time series data of the Internet of Vehicles into the InfluxDB database in a corresponding way. When a new MQTT message is generated, the cloud needs to adjust and modify the code to enter the time series data of the Internet of Vehicles in the new MQTT message into the InfluxDB database, which is not convenient.

[0003] MQTT is a machine-to-machine communication protocol based on the publish / subscribe model, suitable for data transmission between IoT devices. MQTT has the characteristics of lightweight, low power consumption, high reliability, etc., which can realize the connection of a large number of devices and the exchange of messages. InfluxDB is a database designed specifically for time series data, with the ability to efficiently store and query large amounts of time series data. InfluxDB supports SQL-like query languages, which can aggregate and analyze time series data to realize the visualization and monitoring of IoT data.

[0004] The inventors have considered that the process of entering traditional Internet of Vehicles time series data into the InfluxDB database is complicated. If the MQTT message can be converted into InfluxDB data, the purpose of directly writing the InfluxDB data into the InfluxDB database can be achieved.

[0005] In summary, how to convert MQTT messages into InfluxDB data so as to conveniently enter the Internet of Vehicles time series data into the InfluxDB database has become a technical problem that needs to be solved urgently. Summary of the invention

[0006] In view of this, the purpose of the present invention is to provide a method, a data conversion system and an electronic device for converting MQTT messages to InfluxDB data, so as to alleviate the technical problems of the complexity and low efficiency of the existing process of entering the time series data of the Internet of Vehicles into the InfluxDB database.

[0007] In a first aspect, an embodiment of the present invention provides a method for converting an MQTT message to InfluxDB data, which is applied to a data conversion system, wherein the data conversion system is deployed on a target edge node, wherein the data conversion system includes: a data bridge module, a data conversion module and a writing module, and the method includes:

[0008] The data bridge module establishes a data channel with a target MQTT server and a target InfluxDB server according to pre-configured connection parameters, and then obtains an MQTT message sent by the target MQTT server based on the data channel;

[0009] The data conversion module converts the MQTT message into InfluxDB data according to a preconfigured conversion rule, and caches the InfluxDB data in the target edge node according to a target write strategy corresponding to the InfluxDB data;

[0010] When the InfluxDB data in the cache reaches a writing opportunity, the writing module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server.

[0011] Furthermore, the process of determining the target edge node includes:

[0012] Obtaining the QoS requirements of the MQTT message;

[0013] Determining, according to the QoS requirement, an initial edge node that meets the QoS requirement among edge nodes;

[0014] Acquire performance parameters of each of the initial edge nodes, and calculate a comprehensive score of each of the initial edge nodes according to the performance parameters;

[0015] The target edge node is determined among the initial edge nodes according to the comprehensive scores of the initial edge nodes.

[0016] Furthermore, the data conversion module converts the MQTT message into InfluxDB data according to a preconfigured conversion rule, including:

[0017] Determining tags and fields corresponding to the MQTT message according to the conversion rule, wherein the conversion rule includes at least one of the following: a scenario-based conversion rule, an adaptive conversion rule, and a configuration file-based conversion rule;

[0018] The data in the MQTT message is organized according to the row protocol format of InfluxDB based on the tag and the field to obtain the InfluxDB data, wherein the row protocol format of InfluxDB includes: measurement value, tag, field, and timestamp.

[0019] Further, caching the InfluxDB data in the target edge node according to the target write strategy corresponding to the InfluxDB data includes:

[0020] Determining a target write strategy corresponding to the InfluxDB data according to a correspondence between a data type of the InfluxDB data and a write strategy, wherein the write strategy includes: a priority-based write mode, a compression-based write mode, and a cache-based write mode;

[0021] The InfluxDB data is cached in the target edge node according to the target write strategy.

[0022] Further, the writing module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server, including:

[0023] Determine the target database and the target data table corresponding to the InfluxDB data, wherein the target database and the target data table are named according to the type of the InfluxDB data, and / or the purpose of the InfluxDB data, and / or the partition and sharding of the InfluxDB data;

[0024] Determine the retention period corresponding to the InfluxDB data;

[0025] The InfluxDB data in the cache is added with the retention time and written into the target data table in the target database via HTTP or UDP protocol.

[0026] Furthermore, the partitioning and sharding of the InfluxDB data is partitioning and sharding of the InfluxDB data according to a preset dimension.

[0027] Furthermore, the method further comprises:

[0028] The InfluxDB query tool is used to visualize and monitor the InfluxDB data in the target InfluxDB server.

[0029] In a second aspect, an embodiment of the present invention further provides a data conversion system, which is deployed at a target edge node, wherein the data conversion system comprises: a data bridge module, a data conversion module and a writing module, wherein:

[0030] The data bridge module establishes a data channel with a target MQTT server and a target InfluxDB server according to pre-configured connection parameters, and then obtains an MQTT message sent by the target MQTT server based on the data channel;

[0031] The data conversion module converts the MQTT message into InfluxDB data according to a preconfigured conversion rule, and caches the InfluxDB data in the target edge node according to a target write strategy corresponding to the InfluxDB data;

[0032] When the InfluxDB data in the cache reaches a writing opportunity, the writing module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server.

[0033] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the methods described in the first aspect when executing the computer program.

[0034] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to execute any method described in the first aspect above.

[0035] In an embodiment of the present invention, a method for converting an MQTT message to InfluxDB data is provided, which is applied to a data conversion system, and the data conversion system is deployed in a target edge node, wherein the data conversion system includes: a data bridge module, a data conversion module and a write module, and the method includes: the data bridge module establishes a data channel with a target MQTT server and a target InfluxDB server according to pre-configured connection parameters, and then obtains an MQTT message sent by the target MQTT server based on the data channel; the data conversion module converts the MQTT message into InfluxDB data according to a pre-configured conversion rule, and caches the InfluxDB data in the target edge node according to a target write strategy corresponding to the InfluxDB data; when the InfluxDB data in the cache reaches a write timing, the write module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server. From the above description, it can be seen that in the MQTT message to InfluxDB data conversion method of the present invention, the MQTT message can be efficiently converted into InfluxDB data, and then the InfluxDB data can be efficiently written into the target InfluxDB server, so as to achieve the purpose of entering the Internet of Vehicles time series data into the InfluxDB database, improve the efficiency of entering the Internet of Vehicles time series data into the InfluxDB database, simplify the data entry process, and alleviate the technical problems of the existing complex and inefficient process of entering the Internet of Vehicles time series data into the InfluxDB database. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0037] Figure 1 A flowchart of a method for converting MQTT messages to InfluxDB data provided by an embodiment of the present invention;

[0038] Figure 2 A schematic diagram of tags and fields provided for an embodiment of the present invention;

[0039] Figure 3 A schematic diagram of an MQTT message provided in an embodiment of the present invention;

[0040] Figure 4 A schematic diagram of InfluxDB data provided by an embodiment of the present invention;

[0041] Figure 5 A schematic diagram of a configuration file provided in an embodiment of the present invention;

[0042] Figure 6 A schematic diagram of loading a configuration file and applying conversion rules provided in an embodiment of the present invention;

[0043] Figure 7 A schematic diagram of a data conversion system provided by an embodiment of the present invention;

[0044] Figure 8 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0045] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] The process of entering traditional Internet of Vehicles time series data into the InfluxDB database is complex and inefficient.

[0047] Based on this, the MQTT message to InfluxDB data conversion method of the present invention can efficiently convert MQTT messages into InfluxDB data, and then realize the efficient writing of InfluxDB data into the target InfluxDB server, so as to achieve the purpose of entering the Internet of Vehicles time series data into the InfluxDB database, improve the efficiency of entering the Internet of Vehicles time series data into the InfluxDB database, and simplify the data entry process.

[0048] To facilitate understanding of this embodiment, a method for converting an MQTT message to InfluxDB data disclosed in an embodiment of the present invention is first introduced in detail.

[0049] Embodiment 1:

[0050] According to an embodiment of the present invention, an embodiment of a method for converting an MQTT message to InfluxDB data is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.

[0051] Figure 1 is a flowchart of a method for converting MQTT messages to InfluxDB data according to an embodiment of the present invention. Figure 1As shown, the method comprises the following steps:

[0052] Step S102, the data bridge module establishes a data channel with the target MQTT server and the target InfluxDB server according to the pre-configured connection parameters, and then obtains the MQTT message sent by the target MQTT server based on the data channel;

[0053] In an embodiment of the present invention, the above-mentioned MQTT message to InfluxDB data conversion method can be applied to a data conversion system, which is deployed on a target edge node, wherein the data conversion system includes: a data bridge module, a data conversion module and a writing module. The system can realize local (i.e., local to the target edge node) conversion and storage of data, reduce data transmission delay and network load (compared to traditional solutions that need to be sent to the cloud), and improve the timeliness and security of data.

[0054] The data bridge module is responsible for establishing a data channel between the target MQTT server and the target InfluxDB server, subscribing to MQTT topics, receiving MQTT messages, and forwarding the converted InfluxDB data to the target InfluxDB server.

[0055] During implementation, based on the container deployment method, the data bridge module is encapsulated as a lightweight container, which can be quickly deployed and run on the target edge node, and realize the conversion and storage of data on the target edge node.

[0056] In addition, based on the cache data management mechanism, the cache area of ​​the data bridge module (i.e., the cache area of ​​the target edge node) is divided into two parts, one for storing the MQTT messages to be converted, and the other for storing the converted InfluxDB data, to achieve local conversion and storage of data, reduce data transmission delay and network load, and improve data timeliness and security.

[0057] The above-mentioned pre-configured connection parameters are pre-configured on the central node and subsequently sent to the target edge node. The connection parameters include: connection parameters of the target MQTT server and connection parameters of the target InfluxDB server, where the connection parameters of the target MQTT server include: address, port, user name, password, topic; the connection parameters of the target InfluxDB server include: address, port, user name, password, database.

[0058] Step S104, the data conversion module converts the MQTT message into InfluxDB data according to the pre-configured conversion rules, and caches the InfluxDB data in the target edge node according to the target write strategy corresponding to the InfluxDB data;

[0059] Specifically, the conversion rules include data format, label, field, timestamp, etc. There are many types of the above conversion rules, which will be described in detail below.

[0060] The above InfluxDB data is obtained by organizing the MQTT message according to the line protocol format of InfluxDB, that is, organizing the data in the format of measurement value, tag, field, and timestamp.

[0061] The above-mentioned target write strategy is one or more write strategies among the multiple write strategies, and a corresponding target write strategy is pre-configured for each InfluxDB data. In this way, the InfluxDB data can be cached in the target edge node according to the target write strategy corresponding to the InfluxDB data.

[0062] Step S106: When the InfluxDB data in the cache reaches a write timing, the write module writes the InfluxDB data in the cache into a target data table in a target database in a target InfluxDB server.

[0063] In an embodiment of the present invention, a method for converting an MQTT message to InfluxDB data is provided, which is applied to a data conversion system, and the data conversion system is deployed in a target edge node, wherein the data conversion system includes: a data bridge module, a data conversion module and a write module, and the method includes: the data bridge module establishes a data channel with a target MQTT server and a target InfluxDB server according to pre-configured connection parameters, and then obtains an MQTT message sent by the target MQTT server based on the data channel; the data conversion module converts the MQTT message into InfluxDB data according to a pre-configured conversion rule, and caches the InfluxDB data in the target edge node according to a target write strategy corresponding to the InfluxDB data; when the InfluxDB data in the cache reaches a write timing, the write module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server. From the above description, it can be seen that in the MQTT message to InfluxDB data conversion method of the present invention, the MQTT message can be efficiently converted into InfluxDB data, and then the InfluxDB data can be efficiently written into the target InfluxDB server, so as to achieve the purpose of entering the Internet of Vehicles time series data into the InfluxDB database, improve the efficiency of entering the Internet of Vehicles time series data into the InfluxDB database, simplify the data entry process, and alleviate the technical problems of the existing complex and inefficient process of entering the Internet of Vehicles time series data into the InfluxDB database.

[0064] The above content briefly introduces the method for converting MQTT messages to InfluxDB data of the present invention. The specific contents involved are described in detail below.

[0065] In an optional embodiment of the present invention, the process of determining the target edge node specifically includes the following steps:

[0066] (1) Obtain QoS requirements for MQTT messages;

[0067] Specifically, according to the network conditions and data characteristics, the optimal edge node (i.e., the target edge node, that is, in the complex and dynamic network environment of the Internet of Vehicles, the optimal edge node is selected) is dynamically evaluated and selected as the deployment location of the data conversion system to ensure data stability and reliability.

[0068] When implementing, first obtain the QoS requirements (i.e., service quality requirements) of the MQTT message.

[0069] (2) determining an initial edge node that meets the QoS requirement among the edge nodes according to the QoS requirement;

[0070] (3) Obtaining performance parameters of each initial edge node, and calculating a comprehensive score of each initial edge node based on the performance parameters;

[0071] Specifically, the above performance parameters include: processing capacity, storage space, network connection quality, etc. The above comprehensive score reflects the applicability of the initial edge node to process specific data tasks.

[0072] (4) Determine the target edge node among the initial edge nodes according to the comprehensive score of each initial edge node.

[0073] Specifically, the initial edge node with the highest comprehensive score is used as the target edge node.

[0074] The following is a specific example to illustrate the above process:

[0075] Assume there is a car A and roadside edge nodes B, C, and D. Car A needs to send its sensor data to InfluxDB via MQTT messages for storage and analysis. In order to optimize the efficiency and reliability of data transmission, the system needs to select the optimal node (i.e., the target edge node) among edge nodes B, C, and D to deploy the data conversion system.

[0076] Collect performance parameters of each edge node:

[0077] Edge node B: processing power 8 / 10, storage space 7 / 10, network connection quality 9 / 10.

[0078] Edge node C: processing power 6 / 10, storage space 9 / 10, network connection quality 7 / 10.

[0079] Edge node D: processing power 7 / 10, storage space 8 / 10, network connection quality 8 / 10.

[0080] Comprehensive score calculation:

[0081] Edge node B: 8 (processing power) + 7 (storage space) + 9 (network connection quality) = 24;

[0082] Edge node C: 6+9+7=22;

[0083] Edge node D: 7+8+8=23;

[0084] Conditional matching and dynamic selection:

[0085] QoS requirements for data tasks (i.e. QoS requirements for MQTT messages): high processing power and network connection quality are prioritized.

[0086] The initial edge nodes that meet QoS requirements include: edge nodes B, C, and D;

[0087] The initial edge node B has the highest comprehensive score of 24, which meets the QoS requirements. The target edge node B is selected as the deployment location of the data conversion system.

[0088] In an optional embodiment of the present invention, the data conversion module converts the MQTT message into InfluxDB data according to a preconfigured conversion rule, specifically including the following steps:

[0089] (1) determining tags and fields corresponding to the MQTT message according to a conversion rule, wherein the conversion rule includes at least one of the following: a scenario-based conversion rule, an adaptive conversion rule, and a configuration file-based conversion rule;

[0090] Specifically, according to different scenarios and needs, different conversion rules are selected to improve the quality and efficiency of data; according to the content and structure of the data, the key information of the data is automatically identified and extracted, and appropriate labels and fields are generated based on the key information.

[0091] 1) Scenario-based data conversion rules: adding different labels to data according to vehicle ID, type, status, etc., and adding different fields to data according to data format and structure to improve data quality and efficiency;

[0092] For example, suppose there are different types of vehicle data to be processed:

[0093] Vehicle ID: "A123", Type: "Truck", Status: "In Operation"

[0094] Vehicle ID: "B456", Type: "Sedan", Status: "Parked"

[0095] For these different types of vehicle data, add different labels and fields to the data, such as Figure 2 As shown:

[0096] Truck data:

[0097] Tag: vehicle_type="truck"

[0098] Fields: location, speed, cargo_weight

[0099] Car data:

[0100] Tag: vehicle_type="car"

[0101] Fields: location, speed, driver_status

[0102] 2) Based on adaptive data conversion rules, identify and extract key information of the data according to the content and structure of the data, generate appropriate labels and fields, and simplify the data conversion process;

[0103] For example: Assume that the system receives an MQTT message such as Figure 3 As shown, according to the content and structure of the data, key information is automatically identified and extracted, and appropriate labels and fields are generated:

[0104] Automatic identification rules:

[0105] Identify vehicle type based on vehicle_id

[0106] Extract location, speed, cargo_weight fields

[0107] The converted InfluxDB data is as follows Figure 4 shown.

[0108] 3) Based on the conversion rules of the configuration file, the data conversion rules are saved in a configuration file, which can be easily modified and updated to achieve flexibility and scalability of data conversion;

[0109] For example: The configuration file defines the data conversion rules to facilitate modification and updating. Figure 5 As shown, load the configuration file and apply the transformation rules, such as Figure 6 shown.

[0110] (2) Based on the tags and fields, the data in the MQTT message is organized according to the row protocol format of InfluxDB to obtain InfluxDB data, where the row protocol format of InfluxDB includes: measurement value, tag, field, and timestamp.

[0111] In an optional embodiment of the present invention, the InfluxDB data is cached in the target edge node according to the target write strategy corresponding to the InfluxDB data, specifically including the following steps:

[0112] (1) determining a target write strategy corresponding to the InfluxDB data according to a correspondence between the data type of the InfluxDB data and the write strategy, wherein the write strategy includes: a priority-based write mode, a compression-based write mode, and a cache-based write mode;

[0113] Specifically, different writing methods are selected according to the importance and real-time nature of the data, such as batch writing or single-point writing.

[0114] 1) Priority-based writing method: different priorities are assigned to data according to its importance and real-time nature. High-priority data is written in a single point, while low-priority data is written in batches, to achieve efficient data writing;

[0115] For example, in the Internet of Vehicles system, there are two types of data that need to be processed:

[0116] High priority data: The vehicle’s immediate location information. This data needs to be processed and stored in real time so that the vehicle can be quickly located in an emergency.

[0117] Low-priority data: historical location information of vehicles. This type of data is usually used for later analysis and statistics, and has low real-time requirements.

[0118] High priority data:

[0119] High-priority data is written in a single point. Whenever the system receives the vehicle's real-time location information, it immediately converts the information into the InfluxDB line protocol format and writes it to the database. This ensures the real-time and timely update of the data.

[0120] Low priority data:

[0121] Low-priority data is written in batches. The system will temporarily store the received historical location information in a cache. When the data in the cache reaches a certain amount, the system will write the data to the database at once. This can reduce the number of IO operations on the database and improve writing efficiency.

[0122] 2) Compression-based writing method: According to the format and structure of the data, different compression algorithms are used to compress the data, reduce the size of the data, and improve the writing speed and efficiency of the data. For example, for text data, LZ77, LZ78 or their variants, such as DEFLATE, can be used; and for numerical time series data, a compression algorithm designed specifically for time series data, such as the Gorilla compression algorithm, may be selected;

[0123] For example: when processing a large amount of numerical time series data, such as vehicle sensor data, the data volume is large and frequent.

[0124] Data Compression:

[0125] In order to reduce the amount of data transmission and storage, a compression algorithm can be used to compress the data. For text data, LZ77, LZ78 or its variants, such as DEFLATE, can be used;

[0126] Compressed data is smaller and can be transferred and written faster, thus improving overall efficiency.

[0127] Data format:

[0128] Example of raw data (i.e. InfluxDB data) row: sensor_data,sensor_id=S123temperature=25.3,humidity=60 1627673427

[0129] Example of compressed data row (illustration): sensor_data_comp, sensor_id = S123data = compressed_data 1627673427

[0130] 3) Based on the cache writing method, different cache strategies are adopted according to the batch and real-time nature of the data to cache the data (cache on the target edge node), reduce the number of data writes, and improve the data writing speed and efficiency. Data classification: First, classify the data according to the characteristics of the data, such as real-time requirements, update frequency, access mode, etc. For example, different cache strategies can be adopted for data with high real-time requirements (such as the vehicle's real-time location information) and batch data (such as historical location information). For data with high real-time requirements: more frequent write strategies or instant writes can be adopted to ensure timely update of data. At the same time, consider using memory cache to temporarily store data to respond to queries as quickly as possible. For batch data: delayed write or batch write strategies can be adopted to merge multiple data points into a batch operation for storage to reduce the number of IO operations on the storage system and improve write efficiency.

[0131] For example: the system needs to process different types of data, which have different requirements in real time and batch.

[0132] High real-time data:

[0133] Data with high real-time requirements, such as the vehicle's instant location information or engine temperature, requires fast response and timely updates. The system caches this data in memory and sets a lower cache threshold. When the data in the cache reaches the threshold or is triggered within a set time interval (e.g., a few seconds), the system immediately writes the data in the cache to the database.

[0134] Data row format example: vehicle_realtime_data, vehicle_id = A123 speed = 80, engine_temp = 90 1627673427

[0135] Low real-time data:

[0136] For batch data with low real-time requirements, such as historical data of vehicles or regular reports from environmental sensors, the system caches this data in a larger cache and sets a higher cache threshold. When the data in the cache reaches the threshold, the system writes this data to the database in batches at one time. This can reduce IO operations on the database and improve write efficiency.

[0137] Data row format example: vehicle_history_data, vehicle_id = A123 speed = 80, engine_temp = 90 1627673427

[0138] Cache strategy:

[0139] For high-real-time data, the system adopts a more frequent writing strategy or instant writing to ensure timely data updates and quick responses to queries.

[0140] For low real-time data, the system adopts a delayed write or batch write strategy to merge multiple data points into one batch operation for storage, reducing the number of IO operations on the storage system and improving write efficiency.

[0141] (2) Cache the InfluxDB data in the target edge node according to the target write strategy.

[0142] In an optional embodiment of the present invention, the writing module writes the InfluxDB data in the cache into a target data table in a target database in a target InfluxDB server, specifically including the following steps:

[0143] (1) determining a target database and a target data table corresponding to the InfluxDB data, wherein the target database and the target data table are named according to the type of the InfluxDB data, and / or the purpose of the InfluxDB data, and / or the partition and sharding of the InfluxDB data;

[0144] (2) Determine the retention period for InfluxDB data;

[0145] Specifically, the above retention period is used to control the expiration and deletion of InfluxDB data.

[0146] 1) Based on the type of InfluxDB data, select the appropriate database and table according to the type of data, such as vehicle location, speed, temperature, etc., and set data retention policies and indexes to control data expiration and deletion;

[0147] For example, the Internet of Vehicles system needs to process and store different types of vehicle data, such as the vehicle's location, speed, temperature, etc. These different data types have different storage and query requirements.

[0148] Vehicle location data:

[0149] Database: Vehicle location data requires high-frequency updates and efficient queries, so choose a database dedicated to storing location data, for example, vehicle_location_db.

[0150] Table: Create a table vehicle_positions in the database to store position data.

[0151] Retention policy: Set a shorter data retention policy, for example, keep 30 days of data, because historical location data is usually more useful in the short term.

[0152] Vehicle speed data:

[0153] Databases: Vehicle speed data can be stored in another database vehicle_speed_db in order to separate different types of data.

[0154] Table: Create a table vehicle_speeds in the database to store speed data.

[0155] Retention policy: Set a moderate data retention policy, for example, keep 90 days of data to allow for velocity pattern analysis and optimization.

[0156] Vehicle temperature data:

[0157] Database: Vehicle temperature data can be stored in vehicle_temperature_db.

[0158] Table: Create a table named vehicle_temperatures in the database to store temperature data.

[0159] Retention policy: Set a longer data retention policy, for example, save 180 days of data to enable long-term temperature change analysis.

[0160] 2) Selection of databases and tables based on the purpose of InfluxDB data. According to the purpose of the data, such as vehicle operation, management, maintenance, etc., select appropriate databases and tables, and set data retention policies and indexes to control data expiration and deletion;

[0161] For example, the Internet of Vehicles system needs to process data for different purposes, such as vehicle operation, management, and maintenance. These purposes determine the storage structure and query requirements of the data.

[0162] Vehicle operation data:

[0163] Purpose: Used to monitor the vehicle's operating status in real time.

[0164] Database: Select vehicle_operation_db to store operation data.

[0165] Table: Create table operation_status to store operation data such as engine status, fuel level, etc.

[0166] Retention policy: Set a shorter data retention policy, for example, save 60 days of data, because this data is mainly used for real-time monitoring and short-term analysis.

[0167] Vehicle management data:

[0168] Application: Used for daily management and dispatch of vehicles.

[0169] Database: Select vehicle_management_db to store management data.

[0170] Table: Create table management_info to store management data such as vehicle scheduling and driver information.

[0171] Retention policy: Set a moderate data retention policy, for example, keep 180 days of data to facilitate management decisions and optimization.

[0172] Vehicle maintenance data:

[0173] Purpose: To record and analyze vehicle maintenance history and maintenance plan.

[0174] Database: Select vehicle_maintenance_db to store maintenance data.

[0175] Table: Create the maintenance_records table to store maintenance data such as maintenance date, maintenance item, and maintenance personnel.

[0176] Retention policy: Set a longer data retention policy, for example, keep data for 365 days or longer, for long-term maintenance analysis and record keeping.

[0177] 3) Based on the selection of databases and tables for partitioning and sharding of InfluxDB data, the data is divided according to certain rules according to the time or other dimensions of the data to form different partitions and shards, thereby improving the performance and effect of data query and analysis.

[0178] For example, the Internet of Vehicles system needs to process a large amount of time series data, which requires efficient storage and query. Partitioning and sharding technologies can improve the performance and scalability of the system.

[0179] Time partition:

[0180] Partitioning strategy: Partition the data based on its time dimension. For example, partition by month and store each month's data in a separate partition.

[0181] Database: In the database vehicle_data_db, create a table vehicle_data partitioned by month.

[0182] Example: Store the data for January 2023 in the vehicle_data_202301 partition, and store the data for February 2023 in the vehicle_data_202302 partition.

[0183] Geographic Sharding:

[0184] Sharding strategy: Geographic sharding is performed based on the location of the vehicle, for example, sharding by city or region, storing data from different regions in different shards.

[0185] Database: In the database vehicle_geo_db, create a table vehicle_geo_data that is sharded by geographic location.

[0186] Example: Store the data in the Beijing area in the vehicle_geo_data_beijing shard, and store the data in the Shanghai area in the vehicle_geo_data_shanghai shard.

[0187] Hybrid Partition Sharding:

[0188] Partition sharding strategy: Combine time partitioning and geographic sharding to perform hybrid partitioning based on time and location.

[0189] Database: In the database vehicle_combined_db, create a table vehicle_combined_data that is sharded by time and geographic location.

[0190] Example: Store the data of the Beijing region in January 2023 in the vehicle_combined_data_202301_beijing partition shard, and store the data of the Shanghai region in January 2023 in the vehicle_combined_data_202301_shanghai partition shard.

[0191] (3) The InfluxDB data in the cache is added with the retention period and written into the target data table in the target database via HTTP or UDP protocol.

[0192] In an optional embodiment of the present invention, the partitioning and sharding of the InfluxDB data is partitioning and sharding of the InfluxDB data according to a preset dimension.

[0193] In an optional embodiment of the present invention, the method further comprises:

[0194] Use InfluxDB's query tool to visualize and monitor InfluxDB data in the target InfluxDB server.

[0195] Specifically, the target InfluxDB server is used to collect and analyze time series data of distributed energy storage devices.

[0196] When monitoring and analyzing, you can choose any of the following methods:

[0197] Tool-based data visualization and monitoring: According to the needs of data display and presentation, select appropriate tools, such as Grafana, to visualize and monitor data, realize real-time monitoring and intelligent analysis of Internet of Vehicles data, and provide data support for vehicle operation and management;

[0198] Data visualization and monitoring based on algorithms and models. According to the characteristics and purpose of the data, select appropriate algorithms and models, such as regression, classification, clustering, anomaly detection, etc., to analyze and process the data, realize real-time monitoring and intelligent analysis of Internet of Vehicles data, and provide data support for vehicle operation and management.

[0199] The present invention has the following advantages:

[0200] Improve the efficiency and quality of data conversion: The present invention realizes efficient conversion and transmission of data by deploying a data bridge module between the MQTT server and the InfluxDB server. At the same time, through configuration, appropriate data conversion rules are selected according to different scenarios and requirements to improve the quality and efficiency of data.

[0201] Improve the performance and effect of data storage and management: The present invention writes the converted data into InfluxDB through a writing module, and selects a suitable database and table according to the type and purpose of the data, and sets a data retention policy and index to control the expiration and deletion of the data.

[0202] Improve the real-time and intelligence of data analysis and monitoring: The present invention queries and analyzes the converted data from InfluxDB through query analysis. At the same time, according to the characteristics and purpose of the data, appropriate algorithms and models are selected to perform real-time monitoring and intelligent analysis of the data, providing data support for the operation and management of the vehicle.

[0203] Embodiment 2:

[0204] The embodiment of the present invention further provides a data conversion system, which is mainly used to execute the conversion method from MQTT message to InfluxDB data provided in the first embodiment of the present invention. The data conversion system provided in the embodiment of the present invention is specifically introduced below.

[0205] Figure 7 is a schematic diagram of a data conversion system according to an embodiment of the present invention. Figure 7 As shown, the system mainly includes: a data bridge module 10, a data conversion module 20 and a writing module 30, wherein:

[0206] The data bridge module establishes a data channel with the target MQTT server and the target InfluxDB server according to the pre-configured connection parameters, and then obtains the MQTT message sent by the target MQTT server based on the data channel;

[0207] The data conversion module converts the MQTT message into InfluxDB data according to the pre-configured conversion rules, and caches the InfluxDB data in the target edge node according to the target write strategy corresponding to the InfluxDB data;

[0208] When the InfluxDB data in the cache reaches the writing time, the writing module writes the InfluxDB data in the cache to the target data table in the target database in the target InfluxDB server.

[0209] In an embodiment of the present invention, a data conversion system is provided, which is deployed on a target edge node, wherein the data conversion system includes: a data bridge module, a data conversion module and a write module, wherein: the data bridge module establishes a data channel with a target MQTT server and a target InfluxDB server according to pre-configured connection parameters, and then obtains an MQTT message sent by the target MQTT server based on the data channel; the data conversion module converts the MQTT message into InfluxDB data according to a pre-configured conversion rule, and caches the InfluxDB data in the target edge node according to a target write strategy corresponding to the InfluxDB data; when the InfluxDB data in the cache reaches a write timing, the write module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server. From the above description, it can be seen that in the data conversion system of the present invention, MQTT messages can be efficiently converted into InfluxDB data, and then the InfluxDB data can be efficiently written into the target InfluxDB server, so as to achieve the purpose of entering the Internet of Vehicles time series data into the InfluxDB database, improve the efficiency of entering the Internet of Vehicles time series data into the InfluxDB database, simplify the data entry process, and alleviate the technical problems of the existing complex and inefficient process of entering the Internet of Vehicles time series data into the InfluxDB database.

[0210] Optionally, the data conversion system is also used to: obtain the QoS requirements of the MQTT message; determine the initial edge node that meets the QoS requirements among the edge nodes based on the QoS requirements; obtain the performance parameters of each initial edge node, and calculate the comprehensive score of each initial edge node based on the performance parameters; determine the target edge node among the initial edge nodes based on the comprehensive score of each initial edge node.

[0211] Optionally, the data conversion module is also used to: determine the tags and fields corresponding to the MQTT message according to the conversion rules, wherein the conversion rules include at least one of the following: scenario-based conversion rules, adaptive conversion rules, and configuration file-based conversion rules; organize the data in the MQTT message according to the row protocol format of InfluxDB based on the tags and fields to obtain InfluxDB data, wherein the row protocol format of InfluxDB includes: measurement values, tags, fields, and timestamps.

[0212] Optionally, the data conversion module is also used to: determine the target write strategy corresponding to the InfluxDB data according to the correspondence between the data type of the InfluxDB data and the write strategy, wherein the write strategy includes: a priority-based write method, a compression-based write method, and a cache-based write method; and cache the InfluxDB data in the target edge node according to the target write strategy.

[0213] Optionally, the writing module is also used to: determine a target database and a target data table corresponding to the InfluxDB data, wherein the target database and the target data table are named according to the type of the InfluxDB data, and / or the purpose of the InfluxDB data, and / or the partition and fragmentation of the InfluxDB data; determine the retention time corresponding to the InfluxDB data; add the retention time to the InfluxDB data in the cache and write it to the target data table in the target database via the HTTP or UDP protocol.

[0214] Optionally, the partitioning and sharding of the InfluxDB data is partitioning and sharding of the InfluxDB data according to a preset dimension.

[0215] Optionally, the data conversion system is further used to: use an InfluxDB query tool to visualize and monitor InfluxDB data in the target InfluxDB server.

[0216] The implementation principle and technical effects of the system provided in the embodiment of the present invention are the same as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the system embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0217] like Figure 8 As shown, an electronic device 600 provided in an embodiment of the present application includes: a processor 601, a memory 602 and a bus, wherein the memory 602 stores machine-readable instructions executable by the processor 601. When the electronic device is running, the processor 601 communicates with the memory 602 through the bus, and the processor 601 executes the machine-readable instructions to perform the steps of the above-mentioned method for converting MQTT messages to InfluxDB data.

[0218] Specifically, the above-mentioned memory 602 and processor 601 can be general-purpose memories and processors, which are not specifically limited here. When the processor 601 runs the computer program stored in the memory 602, it can execute the above-mentioned method of converting MQTT messages to InfluxDB data.

[0219] The processor 601 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 601. The above processor 601 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 602, and the processor 601 reads the information in the memory 602 and completes the steps of the above method in combination with its hardware.

[0220] Corresponding to the above-mentioned method for converting MQTT messages to InfluxDB data, an embodiment of the present application also provides a computer-readable storage medium, which stores machine-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the steps of the above-mentioned method for converting MQTT messages to InfluxDB data.

[0221] The data conversion system provided in the embodiment of the present application can be specific hardware on the device or software or firmware installed on the device. The system provided in the embodiment of the present application, its implementation principle and the technical effect produced are the same as those in the aforementioned method embodiment. For the sake of brief description, the parts not mentioned in the system embodiment can refer to the corresponding contents in the aforementioned method embodiment. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can all refer to the corresponding processes in the aforementioned method embodiment, and will not be repeated here.

[0222] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0223] For another example, the flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the device, method and computer program product according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0224] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0225] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0226] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for an electronic device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method for converting MQTT messages to InfluxDB data described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program code.

[0227] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0228] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solution of the present application, rather than to limit it. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the aforementioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solution recorded in the aforementioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solution deviate from the scope of the technical solution of the embodiment of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for converting MQTT messages to InfluxDB data, characterized in that: Applied to a data conversion system, the data conversion system is deployed at a target edge node, wherein the data conversion system comprises: a data bridge module, a data conversion module and a writing module, and the method comprises: The data bridge module establishes a data channel with a target MQTT server and a target InfluxDB server according to pre-configured connection parameters, and then obtains an MQTT message sent by the target MQTT server based on the data channel; The data conversion module converts the MQTT message into InfluxDB data according to a preconfigured conversion rule, and caches the InfluxDB data in the target edge node according to a target write strategy corresponding to the InfluxDB data; When the InfluxDB data in the cache reaches a writing opportunity, the writing module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server.

2. The method according to claim 1, characterized in that The process of determining the target edge node includes: Obtaining the QoS requirements of the MQTT message; Determining, according to the QoS requirement, an initial edge node that meets the QoS requirement among edge nodes; Acquire performance parameters of each of the initial edge nodes, and calculate a comprehensive score of each of the initial edge nodes according to the performance parameters; The target edge node is determined among the initial edge nodes according to the comprehensive scores of the initial edge nodes.

3. The method according to claim 1, characterized in that The data conversion module converts the MQTT message into InfluxDB data according to a pre-configured conversion rule, including: Determining tags and fields corresponding to the MQTT message according to the conversion rule, wherein the conversion rule includes at least one of the following: a scenario-based conversion rule, an adaptive conversion rule, and a configuration file-based conversion rule; The data in the MQTT message is organized according to the row protocol format of InfluxDB based on the tag and the field to obtain the InfluxDB data, wherein the row protocol format of InfluxDB includes: measurement value, tag, field, and timestamp.

4. The method according to claim 1, characterized in that: Caching the InfluxDB data in the target edge node according to the target write strategy corresponding to the InfluxDB data includes: Determining a target write strategy corresponding to the InfluxDB data according to a correspondence between a data type of the InfluxDB data and a write strategy, wherein the write strategy includes: a priority-based write mode, a compression-based write mode, and a cache-based write mode; The InfluxDB data is cached in the target edge node according to the target write strategy.

5. The method according to claim 1, characterized in that The writing module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server, including: Determine the target database and the target data table corresponding to the InfluxDB data, wherein the target database and the target data table are named according to the type of the InfluxDB data, and / or the purpose of the InfluxDB data, and / or the partition and sharding of the InfluxDB data; Determine the retention period corresponding to the InfluxDB data; The InfluxDB data in the cache is added with the retention time and written into the target data table in the target database via HTTP or UDP protocol.

6. The method according to claim 1, characterized in that The partitioning and sharding of the InfluxDB data is partitioning and sharding of the InfluxDB data according to a preset dimension.

7. The method according to claim 1, characterized in that The method further comprises: The InfluxDB query tool is used to visualize and monitor the InfluxDB data in the target InfluxDB server.

8. A data conversion system, characterized in that: The data conversion system is deployed at the target edge node, wherein the data conversion system comprises: a data bridge module, a data conversion module and a writing module, wherein: The data bridge module establishes a data channel with a target MQTT server and a target InfluxDB server according to pre-configured connection parameters, and then obtains an MQTT message sent by the target MQTT server based on the data channel; The data conversion module converts the MQTT message into InfluxDB data according to a preconfigured conversion rule, and caches the InfluxDB data in the target edge node according to a target write strategy corresponding to the InfluxDB data; When the InfluxDB data in the cache reaches a writing opportunity, the writing module writes the InfluxDB data in the cache into a target data table in a target database in the target InfluxDB server.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to execute the method according to any one of claims 1 to 7.