A data processing method and system based on time series and structured database
Through data processing methods based on time series and structured databases, the deficiencies of traditional monitoring systems in correlation, tag identification, storage cost and query performance are solved, and automatic collection, processing and correlation of Traces, Metrics and Logs data are realized, improving improve the efficiency and flexibility of the monitoring system.
Patent Information
- Application Number
- CN202410851302.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-28
AI Technical Summary
Existing link tracking, log storage, and indicator monitoring systems have deficiencies in aspects such as correlation, tag identification, storage cost, and query performance, resulting in difficulty in problem location, high cost, and limited performance.
Using data processing methods based on time series and structured databases, through dynamic automated collection modules, data processing and storage modules, and visual correlation modules, automatic collection, processing, and storage of Traces, Metrics, and Logs data are realized, and data are realized through tag metadata. Seamless connections and jumps between.
It improves data collection efficiency, reduces development and maintenance complexity, optimizes storage and query performance, and enables more flexible and sophisticated data management and analysis.
Smart Images

Figure CN118409935B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data technology, and in particular to a data processing method and system based on time series and structured database. Background Art
[0002] As microservice distributed systems become increasingly complex, more and more components are becoming distributed, such as distributed services, distributed databases, and distributed caches, making backend services form a complex distributed network. While service capabilities are improving, complex network architectures also make problem location more difficult.
[0003] In this context, APM monitoring systems represented by the skywalking link tracking system, log storage systems represented by ELK, and cloud native monitoring systems represented by prometheus have emerged. They have solved the problems of link tracking, log storage, and indicator monitoring respectively, and are also leaders in their respective fields, but they also have many shortcomings:
[0004] Poor correlation: In the field of link tracking, log storage and indicator monitoring, each operates independently. Traces, logs and metrics data are stored separately and belong to different platforms. The connection between the three is weak, and it is impossible to realize the correlation jump between traces, logs and metrics data. Users need to log in to different monitoring systems separately to view the corresponding monitoring data, which makes it difficult to troubleshoot problems.
[0005] Lack of label identification information: Traditional monitoring systems have the problem of insufficient monitoring information and inability to effectively distinguish monitoring data. This is mainly because traditional monitoring systems usually adopt indicator-based monitoring methods, and monitoring data lacks detailed label information, which makes it impossible to accurately distinguish monitoring data generated by different systems or instances.
[0006] High storage cost: Traditional logs and call chains are relatively expensive to store large-scale data, especially when high redundancy and availability are required. Deployment, configuration, and maintenance are relatively complex and require more manpower and resource investment.
[0007] Limited query performance: Traditional architecture is not suitable for large-scale data queries. High-frequency deep paging exports lead to downtime and cannot accurately deduplicate statistics. Performance degrades significantly when multiple fields are aggregated and calculated. Summary of the invention
[0008] The technical task of the present invention is to address the above shortcomings and provide a data processing method and system based on time series and structured database, which can solve the problems of poor correlation, lack of label identification information, storage cost, query performance, data consistency and persistence in traditional methods, and can realize automatic deployment of the collection end, automatic injection of labels, storage, processing and display of monitoring data.
[0009] The technical solution adopted by the present invention to solve its technical problem is:
[0010] A data processing method based on time series and structured database, including a dynamic automatic collection module, a data processing and storage module and a visual association module. Through the collaborative work of these three modules, the automatic collection, processing and storage of Traces, Metrics and Logs data are realized, and visual association is realized through tag metadata;
[0011] The dynamic automatic collection module: This module is responsible for the dynamic automatic collection of traces, metrics and logs monitoring data. Due to the particularity of traces, metrics and logs data collection, different collection methods are used for different data, and visual tag metadata information is dynamically injected in real time;
[0012] The data processing and storage module: This module is responsible for preprocessing the data collected by the acquisition module according to predefined rules and storing the data according to the designed data model;
[0013] The visualization association module: This module realizes the association between Traces, Metrics and Logs data and the seamless jump between data according to the automatically injected tag metadata information and the Traces, Metrics and Logs data models.
[0014] Furthermore, the dynamic automated collection module automatically completes the automatic injection of tag metadata (platform, tenant, system, environment, developer), and runs in different modes in the Kubernetes cluster according to the different characteristics of Traces, Metrics, and Logs: the Traces collection module runs in Deployment mode and completes data collection in combination with CRD; the Metrics collection module runs in Deployment and Daemonset modes, and combines configmap to realize the separate collection of different types of monitoring data; the Logs collection module runs in Daemonset mode and completes log file collection and standard output mode collection in combination with CRD.
[0015] Furthermore, the collection end of the Traces collection module is a Kubernetes Operator for deploying and managing Traces collection components. The automatic injection (auto-instrumentation) of the Traces Operator is mainly implemented through the mutating webhook of Kubernetes, including:
[0016] Webhook registration: The Traces Operator registers a mutating webhook with Kubernetes, specifying the resource type (such as Pod) and the corresponding operation (such as create, update, etc.) to be intercepted.
[0017] Request interception: When a new Pod is created, Kubernetes sends a request to the registered mutating webhook, which contains the description of the Pod.
[0018] Injection logic: After receiving the request, the mutating webhook will execute the pre-defined injection logic. The logic usually includes determining whether the Pod meets the automatic injection conditions (whether it needs to be injected, whether it has been injected, etc.), and then injecting the Sidecar container or environment variables into the Pod.
[0019] Modify request: After the injection logic is executed, the mutating webhook modifies the Pod description information in the original request, adding or modifying the injected content.
[0020] Return modification request: The mutating webhook returns the modified Pod description information to Kubernetes, and Kubernetes creates a new Pod using the modified description information;
[0021] The Metrics collection module collects the Ingress-nginx logs in the Kubernetes cluster by collecting standard output and collects application logs by using Daemonset. The implementation is as follows:
[0022] Define CRD rules (CRD, Custom Resource Definition). CRD rules mainly include application tag information that needs to be matched, source collection rules, log parsing and processing, and destination configuration for log sending.
[0023] After the CRD rules are configured, they are automatically sent to the Logs Agent.
[0024] The directory where the Kubernetes Node stores logs will be mounted to the Logs Agent by mounting a volume.
[0025] Logs Agent collects application logs through CRD rules, parses and processes the logs, and sends them to the destination.
[0026] The Logs collection module adopts an all-in-one design. All collection work is implemented with one collection module. It supports the remote_write writing protocol and supports writing data to time series databases such as prometheus and VictoriaMetrics.
[0027] Furthermore, the data processing and storage module designs a data storage model, and uses MaterializedView to implement preprocessing and automatic updating of data from a source table to a target table, precalculates query results, and stores these results on disk;
[0028] When a query request arrives, the system first checks whether a Materialized View already exists. If so, it reads data directly from the Materialized View, avoiding repeated calculations and data access overhead and improving query efficiency.
[0029] Furthermore, Metrics data processing: Metrics data is processed and stored in two parts. One part is directly stored in time series databases such as Prometheus and VictoriaMetrics; the other part is stored in structured databases such as ClickHouse. Metrics data stored in structured databases such as ClickHouse needs to be processed. The processing method is mainly to pre-process the original table through Materialized View and insert the processed data into the target table.
[0030] Traces data processing: Traces data is stored in structured databases such as ClickHouse. The processing method is mainly to pre-process the original table through Materialized View and insert the processed data into the target table;
[0031] Logs data processing: Logs data selects Kafka cache as the log cache, and uses the Kafka engine table to consume the Logs data into structured databases such as ClickHouse. Then, the Kafka engine table is read through Materialized View and persisted into the target table.
[0032] Furthermore, the visualization association module uses pre-defined tag metadata and Traces, Metrics, and Logs data models to deeply analyze the association relationship between data, extract the hidden logical relationship between data, and realize the association jump between Traces, Metrics, and Logs data, providing a new idea for solving the problem.
[0033] Furthermore, after introducing tag metadata (platform, tenant, system, environment, developer), the data model of Metrics, Traces, and Logs data is as follows:
[0034] Metrics data model: LabelSet+Timestamp+Number,
[0035] Among them, LabelSet is Series, which is a combination of several label name / value. The indicator name is also a label name / value.
[0036] Timestamp is the timestamp, the precision is millimeter,
[0037] Number is a numeric value, the type is float64;
[0038] Logs data model: LabelSet+Timestamp+String,
[0039] Among them, LabelSet is Series, which is a combination of several label name / value. The indicator name is also a label name / value.
[0040] Timestamp is a timestamp with nanosecond precision.
[0041] String is a numeric value, and its type is float64;
[0042] Traces data model: Operation Name+Start / End Timestamp+Attributes+Events+Parent+SpanContext,
[0043] Among them, Operation Name: operation name,
[0044] Start / End Timestamp: start and end time,
[0045] Attributes: KV pairs, including Status (such as OK, Cancelled, Permission Denied), SpanKind (CLIENT, SERVER, PRODUCER, CONSUMER, INTERNAL, etc.), and custom information.
[0046] Events: A list of several tuples, each tuple includes timestamp, name, and attributes, which are used to record a series of important events.
[0047] Parent contains the father's Span ID and Trace ID.
[0048] SpanContext contains its own Span ID and Trace ID.
[0049] Furthermore, the association jumps between Traces, Metrics, and Logs data specifically include:
[0050] 1) Metrics and Traces are associated as follows:
[0051] 1.1) When the application exposes metrics through the standard / metrics port, Prometheus will also store exemplars when collecting data through / metrics. Exemplar information contains TraceId information, so that the information of Traces can be queried in Prometheus, thus realizing a seamless jump from metrics to traces;
[0052] 1.2) The spanattributes field in the Traces data contains Metric indicators. The Metric indicators in Traces are consistent with those in Metrics, thus achieving a seamless jump from Traces to Metrics;
[0053] 1.3) Metrics and Traces are associated through label metadata labels. Label metadata labels contain pre-defined platform, tenant, system, environment, developer, and component information. Label metadata labels are used to locate the component level. Metrics and Traces data in the same time period can be associated by combining timestamps.
[0054] 2) Traces and Logs are associated as follows:
[0055] 2.1) By using the SDK of the Traces library, each request will carry a TraceId, and the log format is defined according to the format requirements. The TraceId is written into the log file, and the unique Traces is located by the TraceId. Both Traces and Logs contain the same TraceId, and the TraceId is used to achieve seamless switching between Traces and Logs data.
[0056] 2.2) Like Metrics and Traces, Traces and Logs also implement interrelated queries through label metadata;
[0057] 3) Metrics and Logs are associated as follows:
[0058] 3.1) Seamlessly switch from Metrics to Logs through the TraceId information stored in Exemplar in Metrics and the TraceId recorded in Logs;
[0059] 3.2) Like Metrics and Traces, Metrics and Logs also implement interrelated queries through label metadata.
[0060] The present invention also claims a data processing system based on a time series and a structured database, comprising:
[0061] Dynamic automatic collection module is responsible for dynamically and automatically collecting traces, metrics and logs monitoring data. Due to the particularity of traces, metrics and logs data collection, different collection methods are used for different data, and visual tag metadata information is dynamically injected in real time;
[0062] The data processing and storage module is responsible for preprocessing the data collected by the acquisition module according to predefined rules and storing the data according to the designed data model;
[0063] Visual association module, which is used to realize the association between Traces, Metrics and Logs data and seamless jump between data according to the tag metadata information automatically injected by the collection and the Traces, Metrics and Logs data models;
[0064] The system specifically uses the above-mentioned data processing method based on time series and structured database to realize the automatic collection, processing, and storage of Traces, Metrics, and Logs data, as well as the visual association through tag metadata.
[0065] The present invention also claims a data processing device based on a time series and a structured database, comprising: at least one memory and at least one processor;
[0066] The at least one memory is used to store a machine-readable program;
[0067] The at least one processor is used to call the machine-readable program to implement the above method.
[0068] The present invention also claims protection for a computer-readable medium having computer instructions stored thereon, which, when executed by a processor, cause the processor to perform the above-mentioned method.
[0069] Compared with the prior art, the data processing method and system based on time series and structured database of the present invention have the following beneficial effects:
[0070] 1. By innovating the collection methods of Traces, Metrics, and Logs and creatively introducing the concept of tag metadata, this provides new ideas for collecting Traces, Metrics, and Logs data and standardizes the data collection method. Specifically, the Helm application package manager is introduced to achieve unified management of Traces, Metrics, and Logs data collection, and the custom kubernetes CustomResourceDefinition (CRD, custom resource) is introduced to achieve dynamic injection and custom collection of collection component agents, which provides great convenience for the collection of Traces, Metrics, and Logs data and improves the collection efficiency. At the same time, the design concept of the collection end is non-intrusive, which means that when implementing data collection, there is no need to modify the existing application code. This greatly reduces the complexity of development and maintenance. This non-intrusive design not only improves the collection efficiency, but also reduces the risk of introducing errors.
[0071] 2. Use time series database and structured database to process and store collected data. Compared with traditional storage, it has the advantages of high data compression efficiency, high hardware resource utilization and high query performance. At the same time, due to the unified storage of traces, metrics and logs data, it has great advantages in data association query compared with traditional mode.
[0072] 3. The introduction of tag metadata allows users to add customized tag information to monitoring data, so as to manage monitoring data more flexibly and finely, help users to distinguish and manage monitoring data more finely, and realize more detailed data classification, more flexible data query and more accurate data analysis.
[0073] In summary, the present invention provides a standardized collection method for observation data such as Traces, Metrics and Logs, an innovative data processing and storage method, and a seamless jump between Traces, Metrics and Log data through label metadata. It solves a series of problems in traditional methods and meets the observability requirements of cloud-native microservice business components. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1 It is a diagram showing the overall architecture of a data processing method based on a time series and a structured database provided by an embodiment of the present invention;
[0075] Figure 2 is an implementation diagram of a Traces acquisition module provided by an embodiment of the present invention;
[0076] Figure 3 is an implementation diagram of a Logs collection module provided by an embodiment of the present invention;
[0077] Figure 4 is an implementation diagram of a Metrics collection module provided by an embodiment of the present invention;
[0078] Figure 5 is a schematic diagram of the implementation principle of Materialized View provided by an embodiment of the present invention;
[0079] Figure 6 It is a diagram of processing and storing Metrics, Traces and Logs data provided by one embodiment of the present invention;
[0080] Figure 7 It is a diagram showing the logical relationship among Metrics, Traces and Logs data provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0081] The present invention will be further described below in conjunction with specific embodiments.
[0082] The embodiment of the present invention provides a data processing method based on a time series and a structured database, specifically providing a method for automatic collection, processing, storage and display based on a time series and a structured database, including a dynamic automatic collection module, a data processing and storage module and a visual association module. Through the collaborative work of these three modules, automatic collection, processing and storage of Traces, Metrics and Logs data are realized, and visual association is realized through tag metadata;
[0083] The dynamic automatic collection module: This module is responsible for the dynamic automatic collection of traces, metrics and logs monitoring data. Due to the particularity of traces, metrics and logs data collection, different collection methods are used for different data, and visual tag metadata information is dynamically injected in real time;
[0084] The data processing and storage module: This module is responsible for preprocessing the data collected by the acquisition module according to predefined rules and storing the data according to the designed data model;
[0085] The visualization association module: This module realizes the association between Traces, Metrics and Logs data and the seamless jump between data according to the automatically injected tag metadata information and the Traces, Metrics and Logs data models.
[0086] Among them, the dynamic automatic collection module automatically completes the automatic injection of label metadata (platform, tenant, system, environment, developer), and runs in different modes in the Kubernetes cluster according to the different characteristics of Traces, Metrics, and Logs: the Traces collection module runs in Deployment mode and completes data collection in combination with CRD; the Metrics collection module runs in Deployment and Daemonset modes, and combines configmap to realize the separate collection of different types of monitoring data; the Logs collection module runs in Daemonset mode and combines CRD to complete log file collection and standard output mode collection.
[0087] The data processing and storage module designs a data storage model, and uses Materialized View to implement preprocessing and automatic updating of data from a source table to a target table, precalculates query results, and stores these results on a disk; when a query request arrives, the system first checks whether a Materialized View already exists, and if so, reads data directly from the Materialized View, thereby avoiding repeated calculations and data access overhead, and improving query efficiency.
[0088] The visualization association module mainly uses pre-defined tag metadata and Traces, Metrics, and Logs data models to deeply analyze the association relationship between data, extract the hidden logical relationship between data, and realize the association jump between Traces, Metrics, and Logs data, providing a new idea for solving the problem.
[0089] The specific implementation is as follows:
[0090] 1. Collection Module
[0091] Traditional monitoring data collection modules have disadvantages such as complex deployment and configuration, and poor scalability. Monitoring items and indicators need to be manually configured, which is prone to configuration errors or omissions.
[0092] Based on the shortcomings of the traditional mode collection module, the collection module of the present invention realizes automatic deployment of the collection end and automatic injection of labels based on the self-developed application automatic assembly platform. Without using the application automatic assembly platform, the collection end can realize automatic maintenance of the collection end based on the Kubernetes application package manager helm.
[0093] The collection end is mainly divided into three parts: Traces collection module, Logs collection module and Metrics collection module.
[0094] 1. Traces acquisition module:
[0095] The Traces collection module is maintained through the Helm package manager. The application assembly platform automatically obtains system labels (platform, system, tenant, developer, environment, etc.) and automatically injects them into the Traces collection terminal. The Traces collection terminal is a Kubernetes Operator for deploying and managing Traces collection components. It is a custom Kubernetes controller that uses the Operator mode to automate the deployment, configuration, and management process of the traces collection component environment. The Traces collection component can be centrally managed through CRD, such as automatically creating and managing configuration files, automatically injecting collector and agent configurations, and automatically monitoring and expanding.
[0096] Figure 2 This is the implementation diagram of the Traces acquisition module. The detailed description of this architecture diagram is as follows:
[0097] The automatic injection (auto-instrumentation) of the Traces Operator is mainly achieved through the mutating webhook of kubernetes. Mutating webhook is a mechanism provided by Kubernetes that allows users to intercept and modify requests through webhooks when creating or updating resources. The Traces Operator mainly uses the mutating webhook mechanism to automatically inject the sidecar container or pre-defined environment variables when the pod is created to achieve automatic instrumentation of the application. The specific principles are as follows:
[0098] (1) Webhook registration: The Traces Operator registers a mutating webhook with Kubernetes, specifying the resource type (such as Pod) and the corresponding operation (such as create, update, etc.) to be intercepted.
[0099] (2) Request interception: When a new Pod is created, Kubernetes sends a request to the registered mutating webhook, which contains the description information of the Pod.
[0100] (3) Injection logic: After receiving the request, the mutating webhook will execute the pre-defined injection logic. The logic usually includes determining whether the Pod meets the automatic injection conditions (whether injection is required, whether it has been injected, etc.), and then injecting the Sidecar container or environment variables into the Pod.
[0101] (4) Modifying the request: After the injection logic is executed, the mutating webhook can modify the Pod description information in the original request and add or modify the injected content.
[0102] (5) Return the modified request: The mutating webhook returns the modified Pod description information to Kubernetes, and Kubernetes uses the modified description information to create a new Pod.
[0103] Traces Operator supports automatic injection of common SDKs such as Java, Go, and Python. Instrumentation needs to define indicators such as environment variables (env), container image address, and collection frequency. Then, in the application that needs to be collected, turn on the Traces collection switch, which will automatically add injection tags to the application's annotations. Then, Kubernetes will inject sidercar and environment variable information into the Pod based on the information defined by Instrumentation to collect Traces call chain data.
[0104] 2. Logs collection module:
[0105] The Logs collection module is maintained through the Helm package manager, and the application assembly platform automatically obtains system tags (platform, system, tenant, developer, environment, etc.) and automatically injects them into the Logs collection terminal. The Logs collection introduced this time is mainly for cloud native container log collection.
[0106] The difficulties of container log collection are mainly reflected in the following points: First, Pods will frequently migrate in K8s, and it is not practical to manually change the configuration of log collection on the node. At the same time, the log storage in the cloud native environment is diverse, including container standard output and HostPath, EmptyDir, PV, etc. In addition, after collecting logs, they are generally retrieved and filtered according to the dimensions of Namespace, Pod, Container, Node, and even container environment variables, Labels, etc. of the cloud native environment. These meta information needs to be injected during log collection.
[0107] There are three common approaches to collecting logs in cloud-native environments:
[0108] a. Only collect standard output,
[0109] The conventional way to collect standard output logs is to mount the directories under / var / lib / docker and / var / log / pods, and inject k8s metadata.
[0110] b. Collect data using Daemonset method.
[0111] Logs can be stored in EmptyDir, HostPath or PV storage, and the log collection agent can be deployed to the k8s node through DaemonSet. EmptyDir and other storage directories mapped to the node can be configured to the Agent for collection in a wildcard manner, and the Agent reads the log files under the configured path.
[0112] The disadvantage is that the format of the logs to be collected needs to be kept uniform, and the requirements for the log format are relatively strict.
[0113] c. Sidecar method,
[0114] Each business Pod adds a log collection Agent SideCar when it is deployed, and injects the log collection Agent into the Pod through the container platform or k8s webhook. The Agent can collect the logs of the business container by mounting the same HostPath or EmptyDir.
[0115] The disadvantage is that it is highly invasive to Pods and consumes more resources when there are many Pods.
[0116] Taking into account the advantages and disadvantages of cloud-native container log collection and combining it with actual business needs, we use the standard output method to collect Ingress-nginx logs in the Kubernetes cluster and use Daemonset to collect application logs.
[0117] Figure 3 This is the implementation diagram of the Logs collection module. The detailed description of this architecture diagram is as follows:
[0118] (1) Define CRD rules (Custom Resource Definition). CRD rules mainly include application tag information that needs to be matched, source collection rules, log parsing and processing, and destination configuration for log sending.
[0119] (2) After the CRD rules are configured, they will be automatically sent to the Logs Agent.
[0120] (3) The directory where the Kubernetes Node stores logs will be mounted to the LogsAgent by mounting a volume.
[0121] (4) Logs Agent collects application logs through CRD rules, parses and processes the logs, and sends them to the destination.
[0122] 3. Metrics collection module:
[0123] The Metrics collection module is maintained through the Helm package manager. The application assembly platform automatically obtains system tags (platform, system, tenant, developer, environment, etc.) and automatically injects them into the Metrics collection terminal. The Metrics collection module adopts an all-in-one design. All collection work is implemented with one collection module. It supports the remote_write writing protocol and supports writing data to time series databases such as prometheus and VictoriaMetrics.
[0124] Figure 4 This is the implementation diagram of the Metrics collection module. The detailed description of this architecture diagram is as follows:
[0125] The Metrics collection module Metrics Agent supports the collection of common components such as Kubernetes, MySQL, Redis, Cpu / Mem / Disk, etc. The indicators collected by Metrics Agent will automatically add label information such as platform, tenant, system, environment, and developer.
[0126] 2. Data Processing and Storage
[0127] 1. Tag metadata management:
[0128] Tag metadata needs to be automatically injected into metrics, traces, and log data indicators by the collection end for data filtering and analysis. The default tags that need to be injected are: platform (iwidip_platform), system (iwidip_project), component (iwidip_service), tenant (iwidip_tenant), developer (iwidip_developer), and environment (iwidip_env).
[0129] 2. Data processing:
[0130] Figure 5 This is the implementation principle diagram of Materialized View. The implementation principle is as follows:
[0131] After data collection is completed, data processing is mainly achieved through Materialized View. Materialized View is a special trigger that stores the results of executing SELECT queries on data into a target table. The most powerful feature of Materialized View is that when data is inserted into the source table, the data in the target table will be automatically updated using the SELECT statement. Therefore, there is no need to refresh the data in the Materialized View additionally, and the database will automatically complete all operations. With the powerful functions of Materialized View, it is possible to pre-process Traces, Metrics, and Logs data, pre-calculate query results, and store these results on disk. When a query request arrives, the system will first check whether a Materialized View already exists. If so, it will read the data directly from the Materialized View, avoiding the overhead of repeated calculations and data access, and improving query efficiency.
[0132] Figure 6 This is a diagram for processing and storing Metrics, Traces, and Logs data. The implementation is as follows:
[0133] After the collection end automatically injects the tag metadata, the data needs to be processed and stored. The processing method is as follows:
[0134] Metrics data processing: Metrics data is processed and stored in two parts. One part is directly stored in time series databases such as Prometheus and VictoriaMetrics. The other part is stored in structured databases such as Clickhouse. Metrics data stored in structured databases such as Clickhouse needs to be processed. The processing method is mainly to pre-process the original table through Materialized View and insert the processed data into the target table.
[0135] Traces data processing: Traces data is stored in structured databases such as ClickHouse. The processing method is mainly to pre-process the original table through Materialized View and insert the processed data into the target table.
[0136] Logs data processing: Logs data selects Kafka cache as the log cache, and uses the Kafka engine table to consume the Logs data into structured databases such as ClickHouse. Then, the Kafka engine table is read through Materialized View and persisted into the target table.
[0137] 3. Data storage model
[0138] For the storage of collected data, we designed data storage models for Metrics, Traces, and Logs.
[0139] The following metrics data model structure is mainly as follows (only key fields are listed):
[0140] timeunix: sampling time; iwidip_platform: platform; iwidip_project: system;
[0141] iwidip_tenant: tenant; iwidip_developer: developer; iwidip_env: environment;
[0142] iwidip_service: component name; metricname: indicator name; value: indicator value.
[0143] The call chain data storage model format is as follows (only key fields are listed):
[0144] timestamp: sampling time; iwidip_platform: platform; iwidip_project: system;
[0145] iwidip_tenant: tenant; iwidip_developer: developer; iwidip_env: environment;
[0146] iwidip_service: component name; TraceId: tracing ID; SpanId: spanid;
[0147] ParentSpanId: parent spanid; SpanName: span name; SpanKind: span type;
[0148] ResourceAttributes: metadata attributes; SpanAttributes: Span attributes;
[0149] Duration: response time; StatusCode: status code.
[0150] The log data logs storage model format is as follows (only key fields are listed):
[0151] timestamp: sampling time; iwidip_platform: platform; iwidip_project: system;
[0152] iwidip_tenant: tenant; iwidip_developer: developer; iwidip_env: environment;
[0153] iwidip_service: component name; TraceId: tracing ID; level: log level;
[0154] message: log content.
[0155] 3. Visualizing Associations
[0156] Observability includes three measurement angles: Metrics, Logs, and Traces.
[0157] Metrics: Indicators are aggregate statistics of a certain type of information in the system, such as QPS, latency, error rate, etc.
[0158] Logs: A log is a record of the actions taken by the system. It is discrete and has no correlation. In order to distinguish the importance of this record, the main levels (DEBUG, INFO, WARN, ERROR, FATAL) are used.
[0159] Traces: call chain, which reflects the running status of a request through a component. The data passing through the component is called Span. Span can reflect the status of the component, some key attributes and events, and context information. Spans are associated through Trace ID.
[0160] After introducing tag metadata (platform, tenant, system, environment, developer), the data model of metrics, traces, and logs data is as follows:
[0161] 1. Metrics data model: LabelSet+Timestamp+Number
[0162] LabelSet is a Series, which is a combination of several label name / value. The indicator name is also a labelname / value.
[0163] Timestamp is a timestamp with millimeter precision.
[0164] Number is a numeric value, and its type is float64.
[0165] 2. Logs data model: LabelSet+Timestamp+String
[0166] LabelSet is a Series, which is a combination of several label name / value. The indicator name is also a labelname / value.
[0167] Timestamp is a timestamp with nanosecond precision.
[0168] String is a numeric value, and its type is float64.
[0169] 3. Traces data model: Operation Name+Start / End Timestamp+Attributes+Events+Parent+SpanContext
[0170] Operation Name: Operation name.
[0171] Start / End Timestamp: start and end time.
[0172] Attributes: KV pairs, including Status (such as OK, Cancelled, Permission Denied),
[0173] SpanKind (CLIENT, SERVER, PRODUCER, CONSUMER, INTERNAL, etc.), custom information, etc.
[0174] Events: A list of several tuples, each tuple includes timestamp, name, and attributes, which are used to record a series of important events.
[0175] Parent contains the Span ID and Trace ID of the father.
[0176] SpanContext contains its own Span ID and Trace ID.
[0177] Figure 7 This is a logical relationship diagram of Metrics, Traces, and Logs data, which is described in detail as follows:
[0178] After analyzing the data models of Metrics, Traces, and Logs, you can achieve seamless visualization and switching of Metrics, Traces, and Logs in the following ways:
[0179] Metrics->Traces: Based on Prometheus's Exemplars and label metadata labels.
[0180] Traces->Metrics: Based on metrics and label metadata labels from spans.
[0181] Traces->Logs: Based on TraceId and label metadata labels.
[0182] Logs->Traces: Based on TraceId and label metadata labels.
[0183] Metrics->Logs: Based on Prometheus's Exemplars and label metadata labels.
[0184] Logs->Metrics: Based on label metadata labels.
[0185] (1) Metrics and Traces association:
[0186] (1.1) When the application exposes metrics through the standard / metrics port, Prometheus will also store exemplars when collecting data through / metrics. The exemplar information contains TraceId information, so that the information of Traces can be queried in Prometheus, thus realizing a seamless jump from metrics to traces.
[0187] (1.2) The spanattributes field in the Traces data contains Metric indicators. The Metric indicators in Traces are consistent with those in Metrics, thus achieving a seamless jump from Traces to Metrics.
[0188] (1.3) Metrics and Traces are associated through label metadata. Label metadata contains pre-defined information such as platform, tenant, system, environment, developer and component. Label metadata can be used to locate the component level. At the same time, combined with timestamps, metrics and traces data in the same time period can be associated.
[0189] (2) Traces and Logs association:
[0190] (2.1) By using the SDK of the Traces library, each request will carry a TraceId, and the log format can be defined according to the format requirements. The TraceId can be written into the log file. The unique Traces can be located through the TraceId. Both Traces and Logs contain consistent TraceIds. The TraceId can be used to achieve seamless switching between Traces and Logs data.
[0191] (2.2) Like Metrics and Traces, Traces and Logs can also be queried through tag metadata.
[0192] (3) Metrics and Logs Association:
[0193] (3.1) Through the TraceId information stored in Exemplar in the Metrics indicator and the TraceId recorded in Logs, a seamless jump from Metrics to Logs can be achieved.
[0194] (3.2) Like Metrics and Traces, Metrics and Logs can also be queried through tag metadata.
[0195] The method is further described in detail below through the specific implementation of each module.
[0196] Implementation of the acquisition module:
[0197] 1. Tag metadata planning: Tag metadata (platform, tenant, system, environment, developer) needs to be planned in advance. Tag metadata is used to inject collected data.
[0198] 2. Initialize environment settings: You need to deploy helm in the kubernetes cluster in advance. Helm requires version 3.0 or above.
[0199] 3. Traces acquisition module implementation:
[0200] (1) Define the Traces module CRD, which defines the information that needs to be collected, such as the traces data label metadata injection (platform, tenant, system, environment, developer), the image version used, the Kubernetes metadata information that needs to be injected, the sampling method (such as parentbased_traceidratio), the sampling ratio, and the destination address for sending the collected data.
[0201] (2) Use the helm package manager to deploy the Traces collection module. After successful deployment, the Traces collection module will run in the Kubernetes cluster as a deployment.
[0202] (3) For the application that needs to be collected, add annotations declarations in the deployment yaml file. The annotations declaration specifies the specific information of the Traces module CRD. Since the Traces module CRD defines the detailed rules for collecting data from the Traces module, after adding the annotations declaration, the target application will automatically inject the collection agent of the Traces collection module and load it into the target application to collect Traces data according to the predetermined rules.
[0203] 4. Metrics collection module implementation:
[0204] (1) Define the label metadata injection (platform, tenant, system, environment, developer) in the Metrics module configmap, the image version used, the Kubernetes metadata information that needs to be injected, the host CPU, memory, disk, network that needs to be monitored, and the Kubernetes cluster kubelet, apiserver, pod, deployment and other monitoring information.
[0205] (2) Use the helm package manager to deploy the Metrics collection module. After successful deployment, the Metrics collection module will run in the kubernetes cluster in two modes: deployment and daemoset. The deployment mode is suitable for collecting monitoring information such as kubelet, apiserver, pod, deployment, etc. in the kubernetes cluster. The daemoset mode is suitable for collecting information such as host CPU, memory, disk, network, etc.
[0206] (3) The collection of metrics data does not require any modification to the application, thus avoiding intrusion into business applications.
[0207] 5. Logs collection module implementation:
[0208] (1) Define the information in the Logs module CRD that needs to be injected into the Logs data labels (platform, tenant, system, environment, developer), the image version used, the Kubernetes metadata information that needs to be injected, the log collection path, collection rules, log formatting rules, label matching method, and the destination address for sending collected data.
[0209] (2) Use the helm package manager to deploy the Logs collection module. After deployment, the Logs collection module runs in daemonset mode.
[0210] (3) For business applications that need to be collected, you first need to set the log path to a temporary volume in the deployment, and then add a label tag that is consistent with the CRD definition in the deployment yaml file so that the Logs collection module can automatically collect the corresponding logs. For the ingress-nginx-controller component running in the container, you need to first set the log format according to the specification, and then configure the Logs collection module CRD to collect standard output logs (stout). Then the ingress-nginx-controller label needs to match the label set by the Logs collection module CRD. After the setting is completed, the standard output log of the ingress-nginx-controller component can be automatically collected.
[0211] Implementation of data processing and storage modules:
[0212] 1. Install the Kafka cluster, which is used as a cache for collecting logs to prevent data loss. The Kafka cluster is used to process high-throughput data streams and can process millions of messages per second, making it very suitable for caching and transmitting log data. The Kafka cluster can also persist log messages to disk, providing reliable data storage and preventing data loss.
[0213] 2. Install the time series database prometheus. As a time series database, prometheus is mainly used to store the metrics data collected by the collection module. Prometheus needs to enable remote-write-receiver so that the metrics data collected by the metrics collection module can be directly written to the prometheus time series database storage through remote-write.
[0214] 3. Install the structured database clickhouse as a storage for Metrics, Traces, and Logs data.
[0215] The following uses nginx request log as an example to introduce the initialization process of Logs data.
[0216] Nginx request logs use Kafka as log cache. A new Kafka engine table is created in the database. The engine table needs to specify the address and port of the Kafka Broker, the subscribed Topic name, the engine processing type, etc.
[0217] Create the destination table in the database;
[0218] Data is read from the Kafka engine table through Materialized View and persisted to the target table.
[0219] Implementation of visual association:
[0220] After data processing is completed, the introduction of tag metadata can better help us group, filter and aggregate data, so as to better understand and analyze it. We need to use a visualization system to achieve filtering and seamless jumps between Traces, Metrics and Logs data.
[0221] The embodiment of the present invention further provides a data processing system based on time series and structured database, comprising:
[0222] Dynamic automatic collection module is responsible for dynamically and automatically collecting traces, metrics and logs monitoring data. Due to the particularity of traces, metrics and logs data collection, different collection methods are used for different data, and visual tag metadata information is dynamically injected in real time;
[0223] The data processing and storage module is responsible for preprocessing the data collected by the acquisition module according to predefined rules and storing the data according to the designed data model;
[0224] Visual association module, which is used to realize the association between Traces, Metrics and Logs data and seamless jump between data according to the tag metadata information automatically injected by the collection and the Traces, Metrics and Logs data models;
[0225] The system specifically realizes the automatic collection, processing, and storage of Traces, Metrics, and Logs data and realizes visual association through tag metadata through the data processing method based on time series and structured database described in the above embodiment.
[0226] An embodiment of the present invention further provides a data processing device based on time series and structured database, comprising: at least one memory and at least one processor;
[0227] The at least one memory is used to store a machine-readable program;
[0228] The at least one processor is used to call the machine-readable program to implement the data processing method based on time series and structured database described in the above embodiment.
[0229] The embodiment of the present invention further provides a computer-readable medium, on which computer instructions are stored, and when the computer instructions are executed by a processor, the processor executes the data processing method based on time series and structured database described in the above embodiment. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code for implementing the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or device reads out and executes the program code stored in the storage medium.
[0230] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0231] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer via a communication network.
[0232] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0233] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0234] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.
Claims
1. A data processing method based on time series and structured database, characterized by comprising a dynamic automatic acquisition module, a data processing and storage module and a visual association module. Through the collaborative work of these three modules, the automatic acquisition, processing and storage of Traces, Metrics and Logs data are realized, and visual association is realized through tag metadata; The dynamic automatic collection module: This module is responsible for the dynamic automatic collection of traces, metrics and logs monitoring data, adopts different collection methods for different data, and dynamically injects visual tag metadata information in real time; The data processing and storage module: This module is responsible for preprocessing the data collected by the acquisition module according to predefined rules and storing the data according to the designed data model; The visualization association module: This module realizes the association between Traces, Metrics and Logs data and the seamless jump between data according to the tag metadata information automatically injected by the collection and the Traces, Metrics and Logs data models; The visualization association module uses predefined tag metadata and Traces, Metrics, and Logs data models to deeply analyze the association relationship between data, extract the hidden logical relationship between data, and realize the association jump between Traces, Metrics, and Logs data; After introducing tag metadata, the data model of Metrics, Traces, and Logs data is as follows: Metrics data model: LabelSet+Timestamp+Number, Among them, LabelSet is Series, which is a combination of several label name / value. The indicator name is also a labelname / value. Timestamp is the timestamp, the precision is millimeter, Number is a numeric value, the type is float64; Logs data model: LabelSet+Timestamp+String, Among them, LabelSet is Series, which is a combination of several label name / value. The indicator name is also a labelname / value. Timestamp is a timestamp with nanosecond precision. String is a numeric value, and its type is float64; Traces data model: Operation Name+Start / End Timestamp+Attributes+Events+Parent+SpanContext, Among them, Operation Name: operation name, Start / End Timestamp: start and end time, Attributes: KV pairs, including Status, SpanKind, and custom information. Events: A list of several tuples, each tuple includes timestamp, name, and attributes, which are used to record a series of important events. Parent contains the father's Span ID and Trace ID. SpanContext contains its own Span ID and Trace ID; The association jumps between Traces, Metrics, and Logs data include: 1) Metrics and Traces are associated as follows: 1.1) When the application exposes metrics through the standard / metrics port, Prometheus will also store exemplars when collecting data through / metrics. Exemplar information contains TraceId information, so that the information of Traces can be queried in Prometheus, thus realizing a seamless jump from metrics to traces; 1.2) The spanattributes field in the Traces data contains Metric indicators. The Metric indicators in Traces are consistent with those in Metrics, thus achieving a seamless jump from Traces to Metrics; 1.3) Metrics and Traces are associated through label metadata labels. Label metadata labels contain pre-defined platform, tenant, system, environment, developer, and component information. Label metadata labels are used to locate the component level. Metrics and Traces data in the same time period can be associated by combining timestamps. 2) Traces and Logs are associated as follows: 2.1) By using the SDK of the Traces library, each request will carry a TraceId, and the log format is defined according to the format requirements. The TraceId is written into the log file, and the unique Traces is located by the TraceId. Both Traces and Logs contain the same TraceId, and the TraceId is used to achieve seamless switching between Traces and Logs data. 2.2) Like Metrics and Traces, Traces and Logs also implement interrelated queries through label metadata; 3) Metrics and Logs are associated as follows: 3.1) Seamlessly switch from Metrics to Logs through the TraceId information stored in Exemplar in Metrics and the TraceId recorded in Logs; 3.2) Like Metrics and Traces, Metrics and Logs also implement interrelated queries through label metadata.
2. The data processing method based on time series and structured database according to claim 1, characterized in that: The dynamic automatic collection module automatically completes the automatic injection of label metadata, and runs in different modes in the Kubernetes cluster according to the different characteristics of Traces, Metrics, and Logs: the Traces collection module runs in Deployment mode and completes data collection in combination with CRD; the Metrics collection module runs in Deployment and Daemonset modes, and combines configmap to realize the separate collection of different types of monitoring data; the Logs collection module runs in Daemonset mode and completes log file collection and standard output mode collection in combination with CRD.
3. The data processing method based on time series and structured database according to claim 2, characterized in that: The Traces collection module, the collection end is a Kubernetes Operator for deploying and managing Traces collection components. The automatic injection of Traces Operator is implemented through the mutating webhook of Kubernetes, including: Webhook registration: The Traces Operator registers a mutating webhook with Kubernetes, specifying the resource type and corresponding operation to be intercepted. Request interception: When a new Pod is created, Kubernetes sends a request to the registered mutating webhook, which contains the description of the Pod. Injection logic: After receiving the request, the mutating webhook will execute the pre-defined injection logic. The logic usually includes determining whether the Pod meets the automatic injection conditions, and then injecting the Sidecar container or environment variables into the Pod. Modify request: After the injection logic is executed, the mutating webhook modifies the Pod description information in the original request, adding or modifying the injected content. Return modification request: Mutating webhook returns the modified Pod description information to Kubernetes, and Kubernetes creates a new Pod using the modified description information; The Metrics collection module collects the Ingress-nginx logs in the Kubernetes cluster by collecting standard output and collects application logs by using Daemonset. The implementation is as follows: Define CRD rules, which include application tag information that needs to be matched, source collection rules, log parsing and processing, and destination configuration for log sending. After the CRD rules are configured, they are automatically sent to the Logs Agent. The directory where the Kubernetes Node stores logs will be mounted to the Logs Agent by mounting a volume. Logs Agent collects application logs through CRD rules, parses and processes the logs, and sends them to the destination. The Logs collection module adopts an all-in-one design. All collection work is implemented with one collection module. It supports the remote_write writing protocol and supports writing data into a time series database.
4. The data processing method based on time series and structured database according to claim 1, characterized in that: The data processing and storage module designs a data storage model, and uses Materialized View to implement preprocessing and automatic updating of data from a source table to a target table, precalculates query results, and stores these results on disk; When a query request comes in, the system first checks whether a Materialized View already exists. If so, the data is read directly from the Materialized View.
5. The data processing method based on time series and structured database according to claim 4, characterized in that: Metrics data processing: Metrics data is processed and stored in two parts. One part of the data is directly stored in the time series database. Another set of data is stored in a structured database. The Metrics data stored in the structured database is preprocessed on the original table through MaterializedView, and the processed data is inserted into the target table. Traces data processing: Traces data is stored in a structured database, the original table is preprocessed through Materialized View, and the processed data is inserted into the target table; Logs data processing: Logs data selects Kafka cache as the log cache, and uses the Kafka engine table to consume the Logs data into a structured database. Then, the Kafka engine table is read through Materialized View and persisted into the target table.
6. A data processing system based on time series and structured database, characterized in that: include: Dynamic automatic collection module, which is responsible for dynamically and automatically collecting traces, metrics and logs monitoring data, adopts different collection methods for different data, and dynamically injects visual tag metadata information in real time; The data processing and storage module is responsible for preprocessing the data collected by the acquisition module according to predefined rules and storing the data according to the designed data model; Visual association module, which is used to realize the association between Traces, Metrics and Logs data and seamless jump between data according to the tag metadata information automatically injected by the collection and the Traces, Metrics and Logs data models; The system specifically realizes the automatic collection, processing, storage of Traces, Metrics, and Logs data and realizes visual association through tag metadata through the data processing method based on time series and structured database described in any one of claims 1 to 5.
7. A data processing device based on time series and structured database, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to implement the method described in any one of claims 1 to 5.
8. A computer readable medium, characterized in that The computer readable medium stores computer instructions, and when the computer instructions are executed by a processor, the processor executes the method according to any one of claims 1 to 5.
