Flume metadata information analysis and extraction method and related components
By identifying and extracting the target delimiter in the Event Body in Flume, matching the metadata field information and converting it into a standard format, the problem of unclear metadata of Flume output data is solved, the data processing efficiency is improved, and the subsequent data processing process is simplified. .
Patent Information
- Application Number
- CN202011552583.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-24
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-12-24
AI Technical Summary
The metadata information of Flume's output data is unclear, resulting in low efficiency in data application and processing of subsequent big data components. Additional metadata analysis and extraction of data is required, which affects processing efficiency.
By obtaining the Event Body in the Event data, identifying the target delimiter, extracting the metadata field information, matching the metadata field names, converting the metadata information in a standard format according to the preset format, and adding it to the Event data, the metadata is realized. Extraction and processing of data information.
It improves the processing efficiency of Flume output data, simplifies the subsequent data processing process, reduces the metadata analysis steps for connecting big data components, and improves the overall processing efficiency.
Smart Images

Figure CN112685364B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a Flume metadata information analysis and extraction method, an interceptor, a device and a readable storage medium. Background Art
[0002] Flume is a distributed, highly available system for collecting, aggregating, and transmitting massive amounts of logs. In the era of big data, Flume is an excellent data collection tool that is widely used in multiple scenarios.
[0003] Flume mainly includes four parts: Source (component in Flume used to obtain data), interceptor (component in Flume used for data processing), Channel (storage component in Flume) and Sink (data transmission component in Flume) to complete log collection, aggregation and transmission.
[0004] Although the data processed by Flume is in a standardized format, the metadata information is unclear. The metadata information can only be obtained after further analysis and extraction of the data output by Flume. Metadata information plays an important role in the subsequent data application and processing of big data components. As a result, each time the subsequent big data components apply data, they need to perform metadata analysis and extraction before they can execute the actual processing steps, resulting in low processing efficiency.
[0005] In summary, how to improve the processing efficiency of Flume output data is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0006] The purpose of the present invention is to provide a Flume metadata information analysis and extraction method, an interceptor, a device and a readable storage medium, which can improve the processing efficiency of Flume output data.
[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0008] A Flume metadata information analysis and extraction method, comprising:
[0009] Obtaining the Event data to be processed; wherein the Event data includes: Event Header and EventBody;
[0010] Identify a target delimiter for the Event Body, and extract metadata field information from the Event Body according to the identified target delimiter to obtain metadata field information;
[0011] Matching the metadata field information with a corresponding metadata field name to obtain a data pair of the metadata field name and the field information;
[0012] Convert the data into a standard format according to a preset metadata storage format.
[0013] The metadata information in the standard format is added to the Event data.
[0014] Optionally, before matching the metadata field information with a corresponding metadata field name, the method further includes:
[0015] Determining whether the number of the metadata field information matches the number of pre-configured metadata field names;
[0016] If there is a match, performing the step of matching the metadata field information with the corresponding metadata field name;
[0017] If they do not match, the Event data is taken as error data and written into the error data record file.
[0018] Optionally, after writing the Event data as error data into an error data record file, the method further includes:
[0019] Determine whether the amount of error data written in the error data record file reaches a first threshold;
[0020] If reached, stop the data collection channel of the Source component and output an error prompt;
[0021] If not reached, the step of determining whether the number of target delimiters in the Event Body matches the number of fields is performed.
[0022] Optionally, determining whether the number of the metadata field information matches the number of pre-configured metadata field names includes:
[0023] Determine whether the number of target delimiters in the Event Body is the difference between the number of metadata field names and 1;
[0024] If so, determining that the number of the metadata field information matches the number of pre-configured metadata field names;
[0025] If not, it is determined that the number of the metadata field information does not match the number of the pre-configured metadata field names.
[0026] Optionally, before performing the step of identifying a target delimiter on the Event Body, the method further includes:
[0027] If the amount of error data written in the error data record file reaches the first threshold, determining whether to enable dirty data checking;
[0028] If enabled, determine whether the data type of all field data in the Event Body is the target configuration type;
[0029] If yes, executing the step of identifying the target delimiter of the Event Body;
[0030] If not, the Event data is treated as dirty data and written into the dirty data record file;
[0031] If it is not enabled, the step of identifying the target delimiter of the Event Body is performed.
[0032] Optionally, the Flume metadata information analysis and extraction method further includes:
[0033] Determining whether the amount of dirty data written in the dirty data record file reaches a second threshold;
[0034] If reached, stop the data collection channel of the Source component and output a dirty data prompt;
[0035] If not reached, the step of identifying the target delimiter of the Event Body is executed.
[0036] Optionally, converting the data pair according to a preset metadata unified storage format to generate metadata information in a standard format includes:
[0037] Construct the data pair in Json format to generate metadata in Json format;
[0038] The metadata in the Json format is used as the metadata information in the standard format.
[0039] A Flume metadata information analysis and extraction interceptor, comprising:
[0040] A data acquisition unit, used to acquire the event data to be processed; wherein the event data includes: an event header and an event body;
[0041] An information extraction unit, configured to identify a target delimiter for the Event Body, and extract metadata field information from the Event Body according to the identified target delimiter to obtain metadata field information;
[0042] A field matching unit, used to match the metadata field information with the corresponding metadata field name to obtain a data pair of the metadata field name and the field information;
[0043] A format conversion unit, used to convert the data pair into a format according to a preset metadata unified storage format, and generate metadata information in a standard format;
[0044] An information adding unit is used to add the metadata information in the standard format to the Event data.
[0045] A computer device comprising:
[0046] Memory for storing computer programs;
[0047] A processor is used to implement the steps of the above-mentioned Flume metadata information analysis and extraction method when executing the computer program.
[0048] A readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned Flume metadata information analysis and extraction method.
[0049] The method provided by the embodiment of the present invention identifies and extracts field information separated by a target delimiter in an Event Body as metadata field information, matches metadata field names corresponding to the field information to determine the objects expressed by each metadata field information, obtains data pairs of metadata field names and field information, and converts them into a unified storage format to generate metadata information stored in a standard format for subsequent unified data processing, and adds the format-converted metadata information to the Event data for subsequent data processing based on the metadata information, thereby facilitating data analysis and determination.
[0050] Correspondingly, an embodiment of the present invention also provides a Flume metadata information analysis and extraction interceptor, device and readable storage medium corresponding to the above-mentioned Flume metadata information analysis and extraction method, which has the above-mentioned technical effects and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0052] Figure 1 A schematic diagram of Flume data collection architecture;
[0053] Figure 2 It is an implementation flow chart of a Flume metadata information analysis and extraction method in an embodiment of the present invention;
[0054] Figure 3 This is a flowchart of an overall data verification implementation in an embodiment of the present invention;
[0055] Figure 4 This is a schematic diagram of the structure of a Flume metadata information analysis and extraction interceptor in an embodiment of the present invention;
[0056] Figure 5 This is a schematic diagram of the structure of another Flume metadata information analysis and extraction interceptor in an embodiment of the present invention;
[0057] Figure 6 The figure is a schematic diagram of the structure of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0058] The core of the present invention is to provide a Flume metadata information analysis and extraction method, which can improve the processing efficiency of Flume output data.
[0059] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only 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 making creative work are within the scope of protection of the present invention.
[0060] As attached Figure 1 The figure below is a schematic diagram of the architecture of Flume data collection. Source (which can be from log files, network ports, Kafka, etc.) collects data from multiple data sources and encapsulates it into Event (the basic unit of data transmission in Flume, consisting of Event Header and Event Body). Event can be processed through a series of interceptors and written to Channel. After the data is successfully written to Channel, Sink (the data transmission component in Flume) will actively pull data from Channel and write it to HDFS, HBase, Hive, ES and other big data components for subsequent data processing.
[0061] There are many kinds of interceptors in Flume, including timestamp adding interceptor, host adding interceptor, regular extraction interceptor, etc. The timestamp adding interceptor adds the current time stamp to the event header in the transmitted event. The host adding interceptor can add the current host name at the time of transmission to the event header in the transmitted event. The regular extraction interceptor can extract fields in the event body into the event header through regular expressions.
[0062] In actual production environments, the original data is often "1, zhansan, 18", which is separated by delimiters, and these three data can correspond to the three fields "id, name, age" in a data table. When transmitting to the destination for data processing, the original data such as {"id":1,"name":"zhangsan","age":"18"} is often required, which makes it easier to process the data after it is written, but there is no such function in the existing Flume interceptor.
[0063] To address this problem, this application provides a Flume metadata information analysis and extraction method, which can be applied in Flume as a metadata assembly interceptor to implement the metadata assembly function. Figure 1 , Figure 2 This is a flowchart of a Flume metadata information analysis and extraction method in an embodiment of the present invention, the method comprising the following steps:
[0064] S101, obtaining the Event data to be processed;
[0065] Get the Event data to be processed. Event is the basic unit of data transmission in Flume. Event data is the data encapsulated by the Source component in the Flume system, which consists of Event Header and Event Body.
[0066] It should be noted that the Event data to be processed obtained in this embodiment can be the Event data directly output by the Source component in the Flume system, or it can be the Event data that has been processed by the interceptor but not written to the Channel. That is, the Flume metadata information analysis and extraction process provided in this application can be used as the first interceptor to process the data encapsulated by the Source component, or it can be used as one of the processing steps of multiple interceptors to process the Event data that has been processed by the interceptor.
[0067] S102, identifying a target delimiter for the Event Body, and extracting metadata field information for the Event Body according to the identified target delimiter to obtain metadata field information;
[0068] Event Body is the part of the Event data that records the data itself, while Event Header is mainly used to store keywords, tags and other information of the data. In this embodiment, the analysis and extraction of metadata information can only identify the target delimiter of Event Body to improve the retrieval efficiency. Among them, the target delimiter is the pre-set field delimiter of the metadata information in the current Event data. The delimiter type of metadata information in different Event data may be different. The target delimiter can be determined according to the type of Event data currently being processed.
[0069] Currently commonly used separators include commas "," , spaces, or semicolons ";". In actual production environments, metadata information is often stored in Event data in the form of "1, zhansan, 18". In this way, commas are used as separators to separate field data. This embodiment mainly takes the target separator as a comma as an example for introduction. The implementation methods corresponding to other types of target separators can refer to the introduction of this embodiment and will not be repeated here.
[0070] After the target delimiter is determined, the specific recognition and implementation process of the target delimiter recognition for the data in the Event Body can refer to the implementation method of the recognition delimiter in the relevant technology, which will not be repeated in this embodiment.
[0071] After the target delimiter is identified in the Event Body, the position of the target delimiter can be determined. The metadata field information of the Event Body can be extracted according to the identified target delimiter, and the field information separated by the target delimiter can be obtained. The determined field information can be directly used as metadata information, or the obtained field information can be filtered and then used as metadata information. It can be determined according to factors such as the type of metadata to be extracted. In this embodiment, only the former is used as an example. For example, the target delimiter "," is identified in the original data of "1, zhansan, 18", and it can be determined that the field information separated by the target delimiter is "1", "zhansan" and "18", and the above three field information is used as metadata field information.
[0072] S103, matching metadata field information with corresponding metadata field names to obtain a data pair of metadata field names and field information;
[0073] After identifying the metadata field information separated by the target delimiter, the corresponding field name can be matched for the identified metadata field information according to the arrangement rule of the metadata fields in the currently processed Event data. For example, if the arrangement rule of the metadata in the currently processed Event data is "id, name, age", then match them one by one, match the field information "1" with the field name "id", match the field information "zhansan" with the field name "name", and match the field information "18" with the field name "age" to obtain the data pairs of id-1, name-zhansan, and age-18.
[0074] It should be noted that the present embodiment does not limit the implementation method for matching metadata field information with corresponding metadata field names. The above mainly introduces an implementation method for matching identified metadata field information with corresponding field names according to the arrangement rules of metadata fields in Event data. In addition, the field names corresponding to each metadata field information specified by the user can be received in a user-specified manner, thereby obtaining metadata field names that match the metadata field information. Only the above two implementation methods are used as examples for introduction. The matching implementation methods of other field names can refer to the introduction of this embodiment and will not be repeated here.
[0075] S104, converting the data pair into a format according to a preset metadata unified storage format to generate metadata information in a standard format;
[0076] For ease of viewing, in this embodiment, the obtained data pairs are format-converted according to a preset metadata unified storage format, so that metadata information stored in a unified standard format can be obtained, which facilitates unified management of metadata information.
[0077] In this embodiment, the standard format for conversion, that is, the specific format type of the unified metadata storage format is not limited, and can be set accordingly according to actual viewing needs. An implementation method for converting the data pair according to the preset unified metadata storage format to generate metadata information in a standard format is as follows:
[0078] (1) Construct the data pair in Json format and generate metadata in Json format;
[0079] (2) The metadata in Json format is used as metadata information in a standard format.
[0080] Json format is a lightweight data exchange format that is easy for users to read and understand, and easy for machines to parse. After constructing the data pairs of id-1, name-zhansan, and age-18 in Json format, you can get the Json data of {"id":1,"name":"zhangsan","age":"18"}. The converted data can be directly stored, viewed, and called as metadata information.
[0081] It should be noted that, in this embodiment, only the above-mentioned format conversion method is introduced as an example, and other format conversion methods for the convenience of viewing and calling can refer to the above introduction, which will not be repeated here.
[0082] S105: Add metadata information in a standard format to the Event data.
[0083] Add metadata information in a standard format to the Event data to facilitate the calling and viewing of other interceptors or other data processors.
[0084] In this embodiment, there is no limitation on the specific location where the metadata information in the standard format is added in the Event data. The corresponding location can be set according to the actual needs of metadata reading. For example, the metadata information in the standard format can be added to the Event Header. Specifically, for example, the Key in the metadata in the Json format can be put into the Key of the EventHeader tag, and the corresponding Value can be put into the Event Header Value.
[0085] Based on the above introduction, the technical solution provided by the embodiment of the present invention identifies and extracts the field information separated by the target delimiter in the Event Body as metadata field information, matches the metadata field name corresponding to the field information to determine the object expressed by each metadata field information, obtains the data pair of the metadata field name and the field information, and converts it into a unified storage format to generate metadata information stored in a standard format to facilitate subsequent unified data processing, and adds the metadata information after format conversion to the Event data to facilitate the subsequent data processing process according to the metadata information, so as to facilitate data analysis and determination.
[0086] It should be noted that, based on the above embodiments, the embodiments of the present invention also provide corresponding improved solutions. In the preferred / improved embodiments, the same steps or corresponding steps as those in the above embodiments can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, which will not be described one by one in the preferred / improved embodiments of this article.
[0087] In the current data collection and processing process of the Flume system, there are often some erroneous data, such as data with incorrect format, which may have a certain negative impact on the subsequent data analysis and processing process, resulting in low efficiency or even downtime.
[0088] To avoid the impact of the above situation on the stability of system operation, you can perform the following steps before matching the metadata field information with the corresponding metadata field name:
[0089] (1) determining whether the number of metadata field information matches the number of pre-configured metadata field names;
[0090] (2) If there is a match, executing the step of matching the metadata field information with the corresponding metadata field name;
[0091] (3) If there is a mismatch, the Event data is treated as error data and written into the error data log file.
[0092] In this embodiment, the data whose number of data separated by fields does not match the number of metadata field names in the configuration is regarded as error data. It is judged according to the configured delimiters whether the number of delimiters in the Event Body matches the number of pre-configured metadata field names. The matching criterion is not limited in this embodiment, and can be judged by the difference, such as judging whether the number of target delimiters in the Event Body is the difference between the number of metadata field names and 1. If so, it is determined to be matched, and the current Event data is not error data, and the subsequent steps of matching the metadata field information with the corresponding metadata field name can be executed; if not, the two do not match, and the current Event data is determined to be error data. In order to avoid the negative impact of the error data on the subsequent data analysis and processing, in this embodiment, no subsequent data processing is performed on it, but it is written into the error data record file, so as to facilitate the subsequent technical personnel to process the error data written into the error data record file.
[0093] If there are too many error data, the excessive error data recorded in the error data record file may have a certain impact on the operation of the system. To avoid the above shortcomings, after writing the Event data as error data into the error data record file, it is possible to further determine whether the amount of error data written in the error data record file reaches the first threshold; if so, stop the data acquisition channel of the Source component to avoid the continued generation of error data affecting the operation of the system, and output an error prompt to prompt the technician to handle it in time; if not, the amount of data stored in the error data record file is small and can be temporarily not processed, and continue to execute the step of determining whether the number of target delimiters in the Event Body matches the number of fields.
[0094] Among them, the numerical setting of the first threshold is not limited in this embodiment and can be set according to empirical values. At the same time, the above process can be performed in days. The total number of error data recorded in the error data file can be cleared after the recording time exceeds 24 hours to avoid interference of historical error data in the analysis of current errors.
[0095] In addition, in addition to the form of erroneous data such as the number of metadata field information not matching the number of pre-configured metadata field names, in the actual system operation, there is also data where the data type corresponding to the field does not match the actual data type, which will have a negative impact on the subsequent metadata matching and other data processing. To avoid the above shortcomings, before executing the step of identifying the target delimiter for the Event Body, you can further perform the following steps:
[0096] If the amount of error data written in the error data record file reaches a first threshold, determine whether to enable dirty data checking;
[0097] If enabled, determine whether the data type of all field data in the Event Body is the target configuration type;
[0098] If yes, execute the step of identifying the target delimiter of the Event Body;
[0099] If not, the Event data is treated as dirty data and written into the dirty data record file;
[0100] If it is not enabled, perform the steps to identify the target delimiter for the Event Body.
[0101] In this embodiment, data whose data types corresponding to each field do not match the actual data type are regarded as dirty data, and whether the dirty data filtering mode is turned on is checked. If it is turned on, the subsequent dirty data filtering steps are continued. Specifically, the dirty data filtering steps mainly include obtaining each field of the data according to the delimiter, and judging whether its data type conforms to the preset metadata field type configuration. If so, it is determined to be non-dirty data and the subsequent data processing steps can be continued. If not, it is determined to be dirty data, and the subsequent processing flow is no longer triggered for the dirty data to avoid interference with the stability of the subsequent flow. The data is written into the dirty data record file for subsequent review and maintenance by relevant technical personnel.
[0102] When the amount of data stored in the dirty data record file is too large, it may have a certain impact on the system operation speed. To ensure the system processing speed, the dirty data count is increased by 1 each time a dirty data is added, and it is determined whether the amount of dirty data written in the dirty data record file reaches the second threshold; if it reaches, the data acquisition channel of the Source component is stopped to avoid excessive occupation of the system storage space by too much dirty data, and a dirty data prompt is output to prompt relevant technical personnel to handle it as soon as possible; if it does not reach, the step of identifying the target delimiter of the Event Body is executed. The setting of the second threshold is not limited in this embodiment, and can refer to the setting of the first threshold, which will not be repeated here.
[0103] like Figure 3 The figure shows an overall data verification implementation flow chart, including the verification of erroneous data and the verification of dirty data. The overall implementation process is as follows:
[0104] (1) Initialize configuration and obtain configuration parameters;
[0105] A configuration parameter table is shown in Table 1 below:
[0106]
[0107] Table 1
[0108] (2) Get Event data from the Source component;
[0109] (3) Based on the configured delimiters, determine whether the number of delimiters in the Event Body is the number of configured fields minus 1. If this is not the case, execute step 4.1 but step 5.
[0110] (4.1) Write the data into the error data record file;
[0111] Among them, the error data recording file: records the error data in the collection process, and the first line of the file will record the number of error data and the total amount of error data for the day. The error data for the day will be cleared at dawn every day.
[0112] (4.2) Add the total number of error data recorded in the error data file to the number of error data on that day + 1;
[0113] (4.3) If the number of erroneous data on the day is greater than the first threshold, stop the acquisition channel; otherwise, execute step 3;
[0114] (5) Check whether the dirty data filtering mode is enabled according to the configuration file. If yes, execute step 6.1 instead of step 7.
[0115] (6.1) Obtain each field of the data according to the delimiter and determine whether its data type complies with the metadata field type configuration. If it complies, execute 7; if it does not, execute 6.2.
[0116] (6.2) Write the data into the dirty data record file;
[0117] The dirty data file is used to record the dirty data during the collection process. The first line of the file will record the number of dirty data and the total amount of dirty data for the day. The number of dirty data for the day will be cleared at dawn every day.
[0118] (6.3) Add the total number of dirty data recorded in the dirty data record file to the number of dirty data on that day + 1;
[0119] (6.4) If the number of dirty data on that day is greater than the value set in the configuration file, stop the collection channel; otherwise, execute step 3;
[0120] (7) Pass the data to the converter of the interceptor;
[0121] (8) Execute step 3.
[0122] Based on the above introduction, the method provided in this embodiment can convert data separated by fixed delimiters into metadata information in Json format according to the configured metadata information, thereby adding metadata information to the Event data to facilitate subsequent processing of the data; at the same time, dirty data and error data are stored and counted for analysis and backtracking; when the amount of dirty data or error data on the day is too much, the corresponding data collection channel can be stopped to avoid a large amount of error data accumulation; at the same time, the relevant fields of the converted data can be extracted and put into the Event Header to facilitate the distribution of the data.
[0123] It should be noted that other implementation methods based on the present application can refer to the above introduction and will not be described in detail here.
[0124] Corresponding to the above method embodiment, the embodiment of the present invention further provides a Flume metadata information analysis and extraction interceptor. The Flume metadata information analysis and extraction interceptor described below and the Flume metadata information analysis and extraction method described above can refer to each other.
[0125] See also Figure 4 As shown, the interceptor includes the following modules:
[0126] The data acquisition unit 110 is mainly used to acquire the event data to be processed; wherein the event data includes: event header and event body;
[0127] The information extraction unit 120 is mainly used to identify the target delimiter of the Event Body, and extract the metadata field information of the Event Body according to the identified target delimiter to obtain the metadata field information;
[0128] The field matching unit 130 is mainly used to match the metadata field information with the corresponding metadata field name to obtain a data pair of the metadata field name and the field information;
[0129] The format conversion unit 140 is mainly used to convert the data pair into a format according to a preset metadata unified storage format, and generate metadata information in a standard format;
[0130] The information adding unit 150 is mainly used to add metadata information in a standard format to Event data.
[0131] The above embodiment introduces a unit division form. In addition, in order to achieve the above purpose, other unit division forms can also be adopted, such as Figure 5 The figure shows another structural diagram of Flume metadata information analysis and extraction interceptor. In this division form, Flume metadata information analysis and extraction interceptor mainly includes three units: data verification, data conversion, and data extraction. The collected data will pass through these three units in sequence. The data verification unit verifies the data with fixed delimiters according to the configuration file, and continues to filter and record the data that does not meet the verification rules. When the amount of abnormal data on the day is too much, it supports stopping the channel to prevent the accumulation of a large amount of erroneous data; the data conversion unit converts the data with fixed delimiters into data in Json format according to the configuration file; the data extraction unit can extract fields according to the configuration requirements and extract the data into the Event Header.
[0132] Based on Figure 5 The unit division form shown in the figure, one way to implement the Flume metadata information analysis and extraction function by cooperating with each other is as follows:
[0133] Step 1: Initialize each unit according to the configuration file;
[0134] Step 2: Call the data verification unit to verify the data according to the configuration file, write the abnormal data into the file, and make statistics. If there are too many abnormal data on the day, stop the data channel;
[0135] The specific workflow of the data verification unit can be referred to Figure 3 The introduction of the corresponding embodiments will not be repeated here.
[0136] Step 3: Call the data conversion unit to convert the data separated by fixed delimiters into Json format data according to the configuration;
[0137] A processing flow of the data conversion unit is as follows:
[0138] 1. Get the configuration of the interceptor and initialize the unit;
[0139] 2. Separate the original fields according to the configured separator field;
[0140] 3. According to the metadata field name configuration, construct Json format data. The Key of the Json data is a field information of the configured metadata information, and the Value is the corresponding data field after separation. Put the converted Json into EventBody;
[0141] 4. Extract the data sent by the processed Event and re-execute step 2.
[0142] Step 4: Call the data extraction unit to extract the relevant fields in the Json data into the EventHeader according to the configuration to facilitate data distribution.
[0143] A processing flow of the data extraction unit is as follows:
[0144] 1. Get the configuration of the interceptor and initialize the unit;
[0145] 2. Get the data and find the Key and corresponding Value of the Json data according to the configuration of the data extraction field;
[0146] 3. Put the Key obtained in step 2 into the Key of the Event Header tag, and the corresponding Value into the Event Header Value;
[0147] 4. Extract the data sent by the processed Event and re-execute step 2.
[0148] In the unit division form introduced in this embodiment, the interceptor includes three units: data verification, data conversion, and data extraction. The data verification unit can verify the data according to the configuration, and record and count the erroneous data and dirty data. When there are too many erroneous data and dirty data, the collection channel can be closed to avoid the influx of a large amount of erroneous data; the data conversion unit can convert the data separated by fixed delimiters into Json format data according to the configuration, so as to facilitate the subsequent data analysis and processing; the data extraction unit can extract the corresponding fields of the converted Json data into the Event Header according to the Key value, so as to facilitate data distribution according to the information in the Event Header.
[0149] It should be noted that, in this application, only the above two unit division forms are introduced as examples, and the unit coordination processes corresponding to other unit division forms can refer to the introduction of the above embodiments, which will not be repeated here.
[0150] Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer device. The computer device described below and the Flume metadata information analysis and extraction method described above can refer to each other.
[0151] The computer equipment includes:
[0152] Memory for storing computer programs;
[0153] The processor is used to implement the steps of the Flume metadata information analysis and extraction method of the above method embodiment when executing a computer program.
[0154] For details, please refer to Figure 6 , is a specific structural diagram of a computer device provided in this embodiment. The computer device may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 322 (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer applications 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the central processing unit 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the computer device 301.
[0155] The computer device 301 may also include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0156] The steps in the Flume metadata information analysis and extraction method described above can be implemented by the structure of a computer device.
[0157] Corresponding to the above method embodiment, an embodiment of the present invention further provides a readable storage medium. The readable storage medium described below and the Flume metadata information analysis and extraction method described above can refer to each other.
[0158] A readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the Flume metadata information analysis and extraction method of the above method embodiment.
[0159] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.
[0160] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
Claims
1. A Flume metadata information analysis and extraction method, characterized in that: include: Obtain the event data to be processed; wherein the event data includes: an event header and an event body; the event body is the part of the event data that records the data itself, and the event header is used to store keywords and tags of the data; If the amount of error data written in the error data record file reaches a first threshold, determine whether to enable dirty data checking; If it is not enabled, executing the step of identifying the target delimiter of the Event Body; If enabled, determine whether the data type of all field data in the Event Body is the target configuration type; If not, the Event data is treated as dirty data and written into the dirty data record file; If yes, determining whether the amount of dirty data written in the dirty data record file reaches a second threshold; If reached, the data collection channel of the Source component will output a dirty data prompt; If not, identify the target delimiter for the Event Body, and extract metadata field information from the Event Body according to the identified target delimiter to obtain metadata field information; wherein the target delimiter is determined according to the type of Event data currently being processed; and determine whether the number of target delimiters in the Event Body is the difference between the number of metadata field names and 1; If so, determining that the number of the metadata field information matches the number of pre-configured metadata field names; If not, determining that the number of the metadata field information does not match the number of the pre-configured metadata field names; If they do not match, the Event data is taken as error data and written into the error data record file; Determine whether the amount of error data written in the error data record file reaches a first threshold; If reached, stop the data collection channel of the Source component and output an error prompt; If not, executing the step of determining whether the number of the metadata field information matches the number of the pre-configured metadata field names; If there is a match, the metadata field information is matched with the corresponding metadata field name according to the arrangement rule of the metadata field in the currently processed Event data or by the user-specified method to obtain a data pair of the metadata field name and the field information; Convert the data into a standard format according to a preset metadata storage format. The metadata information in the standard format is added to the Event data.
2. The Flume metadata information analysis and extraction method according to claim 1, characterized in that: The step of converting the data pair into a format according to a preset metadata unified storage format to generate metadata information in a standard format includes: Construct the data pair in Json format to generate metadata in Json format; The metadata in the Json format is used as the metadata information in the standard format.
3. A Flume metadata information analysis and extraction interceptor, characterized in that: include: A data acquisition unit, used to acquire the event data to be processed; wherein the event data includes: an event header and an event body; the event body is the part of the event data that records the data itself, and the event header is used to store keywords and tags of the data; An information extraction unit is used to determine whether dirty data checking is enabled if the number of error data written in the error data record file reaches a first threshold; if not, to perform a step of identifying a target delimiter for the Event Body; if enabled, to determine whether the data type of all field data in the Event Body is a target configuration type; if not, to write the Event data into a dirty data record file as dirty data; if so, to determine whether the number of dirty data written in the dirty data record file reaches a second threshold; if so, to open the data collection channel of the Source component and output a dirty data prompt; if not, to identify a target delimiter for the Event Body, and to extract metadata field information from the Event Body according to the identified target delimiter to obtain metadata field information; wherein the target delimiter is determined according to the type of Event data currently being processed; A field matching unit is used to determine whether the number of target delimiters in the Event Body is the difference between the number of metadata field names and 1; if so, determine that the number of metadata field information matches the number of pre-configured metadata field names; if not, determine that the number of metadata field information does not match the number of pre-configured metadata field names; if not, write the Event data into an error data record file as error data; determine whether the number of error data written in the error data record file reaches a first threshold; if reached, stop the data acquisition channel of the Source component and output an error prompt; if not reached, execute the step of determining whether the number of metadata field information matches the number of pre-configured metadata field names; if matched, match the metadata field information with the corresponding metadata field name according to the arrangement rules of the metadata fields in the currently processed Event data or in a user-specified manner, and obtain a data pair of the metadata field name and the field information; A format conversion unit, used to convert the data pair into a format according to a preset metadata unified storage format, and generate metadata information in a standard format; An information adding unit is used to add the metadata information in the standard format to the Event data.
4. A computer device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the FLUME metadata information analysis and extraction method as claimed in any one of claims 1 to 2 when executing the computer program.
5. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the FLUME metadata information analysis and extraction method according to any one of claims 1 to 2 are implemented.
