A method to classify Istio traffic metrics based on application program interfaces

By intercepting and matching application interface requests in the Istio sidecar container, and using the attributegen plug-in to generate the request_operation tag, the problem that Istio traffic metric records cannot distinguish application interfaces is solved, the sidecar proxy request performance is improved, and the monitoring system performance is reduced Influence.

CN118760538BActive Publication Date: 2024-11-19BEIJING ALAUDA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411230372.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-11-19
Estimated Expiration
2044-09-04

AI Technical Summary

Technical Problem

The existing Istio traffic metric records are service dimensions by default and cannot be distinguished according to the application program interface, resulting in a large amount of time series data generated in the REST application program interface with parameters, increasing Prometheus memory consumption and query delay, and affecting monitoring performance.

Method used

By intercepting application program interface requests for client services in Istio sidecar container, using the extended attributegen plug-in to perform url path matching, generating request_operation tags, using hash map and multi-forktree matching algorithm, quickly matching and recording application interface names, Improve side car agent request performance.

Benefits of technology

It effectively solves the problem of poor side car proxy request performance, improves Istio's performance in scenarios with multiple application program interfaces and high QPS, and reduces the performance impact of the monitoring system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760538B_ABST
    Figure CN118760538B_ABST
Patent Text Reader

Abstract

The present application discloses a method for classifying Istio traffic indicators according to application program interfaces, including: intercepting application program interface requests initiated by client services to application services; sending application program interface requests to application service containers for processing; the application service container obtains reply content after processing the application program interface request, and returns the reply content to the sidecar container; receiving the reply content returned by the application service container, and matching the application program interface through the attributegen plug-in; generating the request_operation label of the request indicator according to the matched application program interface. The present application solves the problem of poor performance of existing sidecar proxy requests and improves the performance of sidecar proxy requests by extending the Istio attributegen plug-in and adopting a new application program interface url path matching algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of Istio traffic indicator classification, and in particular to a method for classifying Istio traffic indicators according to application program interfaces. Background Art

[0002] A service mesh is an infrastructure layer for handling inter-service communication in a microservice architecture. It is usually composed of a set of specialized tools and agents designed to simplify the connection, monitoring, management, and security between services. With the widespread promotion of the service mesh concept, Istio (an open source service mesh platform for managing, protecting, and observing communication between microservices) is also increasingly being used in production environments to observe services in a non-invasive way.

[0003] Currently, in the metrics of recording service HTTP (Hypertext Transfer Protocol) requests, the default is service dimension, and no distinction is made based on application program interfaces. However, in backend services, statistics based on application program interface dimensions are generally required to view the request and response status of each application program interface.

[0004] If you simply record the URL path of the application program interface into the indicator, the cardinality of the value will be too large for the REST application program interface with parameters. For example, the / user / {id} application program interface that obtains user information through the user ID may have a large number of users, which will generate a lot of corresponding time series data, resulting in increased Prometheus memory consumption, slower queries, and affected monitoring system performance.

[0005] Istio officially provides an attributegen wasm plug-in that can define application interfaces, for example, aggregating application interfaces by HTTP method and URL path. However, this plug-in matches each application interface in a loop, which has poor performance. In scenarios with many application interfaces and high QPS, it affects the performance of Istio sidecar proxy requests. Summary of the invention

[0006] To this end, the present application provides a method for classifying Istio traffic indicators according to application program interfaces to solve the problem of poor performance of sidecar proxy requests in the prior art.

[0007] In order to achieve the above objectives, this application provides the following technical solutions:

[0008] In a first aspect, a method for classifying Istio traffic indicators according to an application program interface includes a client service and an application service, wherein the client service and the application service are both deployed in a Pod in a kubenetes cluster, and after the client service is injected with an Istio sidecar application service, a sidecar container is added to the Pod where the application service is deployed, and the sidecar container shares a network space with the application service container, and the sidecar container uses iptables rules to configure network traffic redirection, and the method is applied to the sidecar container, including:

[0009] Intercepting an application program interface request initiated by the client service to the application service;

[0010] Send the application interface request to the application service container for processing; the application service container processes the application interface request to obtain a reply content, and returns the reply content to the sidecar container;

[0011] Receive the reply content returned by the application service container, and match the application program interface through the attributegen plug-in;

[0012] Generates request_operation tags for request metrics based on matching APIs.

[0013] Preferably, matching the application interface through the attributegen plug-in specifically includes: searching the hash map for a URL path, and if so, recording the name of the application interface; if not, splitting the URL path according to " / ", and matching it layer by layer from the multi-branch tree, and if no leaf node is matched, processing it as matching {arg}, and if a leaf node is matched, recording the name of the application interface.

[0014] Preferably, the attributegen plug-in needs to pre-read the application interface aggregation configuration, store the application interface without parameters in a hash map, split the application interface with parameters according to the " / " in the URL path, and replace the parameter part with {arg}, and store it as a multi-branch tree.

[0015] Preferably, the application program interface aggregation configuration is generated after the management component detects the ApiAttribute resource and according to the application program interface list specified by the ApiAttribute resource.

[0016] Preferably, the management component detects ApiAttribute resources through the Watch application program interface of Kubernetes.

[0017] Preferably, the ApiAttribute resource is created by the user through the kubectl tool.

[0018] In a second aspect, a device for classifying Istio traffic indicators according to an application program interface is provided, wherein the device is used to implement a method for classifying Istio traffic indicators according to an application program interface, including:

[0019] An interception module, used to intercept an application program interface request initiated by the client service to the application service;

[0020] A request sending module, used to send the application interface request to the application service container for processing; the application service container processes the application interface request to obtain a reply content, and returns the reply content to the sidecar container;

[0021] A data receiving module, used for receiving the reply content returned by the application service container, and matching the application program interface through the attributegen plug-in;

[0022] The label generation module is used to generate the request_operation label of the request indicator according to the matching application interface.

[0023] In a third aspect, a computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the steps of a method for classifying Istio traffic indicators according to an application program interface.

[0024] In a fourth aspect, a computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of a method for classifying Istio traffic indicators according to an application program interface.

[0025] In a fifth aspect, a computer program product includes a computer program or instructions, which, when executed by a processor, implement the steps of a method for classifying Istio traffic indicators according to an application program interface.

[0026] Compared with the prior art, this application has at least the following beneficial effects:

[0027] The present application provides a method for classifying Istio traffic indicators according to application program interfaces, including: intercepting application program interface requests initiated by client services to application services; sending application program interface requests to application service containers for processing; the application service container obtains reply content after processing the application program interface requests, and returns the reply content to the sidecar container; receiving the reply content returned by the application service container, and matching the application program interface through the attributegen plug-in; generating the request_operation label of the request indicator according to the matched application program interface. The present application solves the problem of poor performance of existing sidecar proxy requests by extending the Istio attributegen plug-in and adopting a new application program interface url path matching algorithm. When Istio aggregates application program interface requests through attributegen, it can more quickly match and generate the application program interface name corresponding to the url path, thereby improving the performance of sidecar proxy requests. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more intuitively illustrate the prior art and the present application, exemplary drawings are given below. It should be understood that the specific shapes and structures shown in the drawings should not generally be regarded as limiting conditions for implementing the present application; for example, those skilled in the art are capable of easily making conventional adjustments or further optimizations to the addition / reduction / attribution division, specific shapes, positional relationships, connection methods, dimensional ratios, etc. of certain units (components) based on the technical concepts and exemplary drawings disclosed in the present application.

[0029] Figure 1 A flow chart of a method for classifying Istio traffic indicators according to application program interfaces provided in Example 1 of the present application;

[0030] Figure 2 The attributegen architecture diagram provided in Example 1 of the present application;

[0031] Figure 3 A schematic diagram of the application program interface URL path matching structure provided in Example 1 of the present application. DETAILED DESCRIPTION

[0032] The present application is further described below in detail through specific embodiments in conjunction with the accompanying drawings.

[0033] In the description of this application: unless otherwise specified, "plurality" means two or more. The terms "first", "second", "third", etc. in this application are intended to distinguish the objects referred to, and do not have special meanings in terms of technical connotations (for example, they should not be understood as emphasizing the importance or order, etc.). Expressions such as "including", "comprising", "having", etc. also mean "not limited to" (certain units, components, materials, steps, etc.).

[0034] The terms such as "upper", "lower", "left", "right", "middle", etc. cited in this application are usually used to indicate the general relative position relationship for the purpose of intuitive understanding by referring to the drawings, and are not absolute limitations on the position relationship in the actual product.

[0035] Embodiment 1

[0036] See also Figure 1 and Figure 2 This embodiment provides a method for classifying Istio traffic indicators according to application program interfaces, including client services and application services, both of which are deployed in Pods in a kubenetes cluster. After the client service is injected with the Istio sidecar application service, a sidecar container is added to the Pod where the application service is deployed. The sidecar container shares the network space with the application service container, and the sidecar container uses iptables rules to configure network traffic redirection, thereby intercepting inbound and outbound traffic. The method is applied to the sidecar container, including:

[0037] S1: intercepts the API request initiated by the client service to the application service;

[0038] Specifically, when the client service initiates an application interface request to the application service, the Istio sidecar container intercepts the application interface.

[0039] S2: Send the API request to the application service container for processing; the application service container processes the API request, obtains a reply, and returns the reply to the sidecar container;

[0040] Specifically, the Istio sidecar container forwards the intercepted application interface to the application service container. After processing, the application service container returns the reply content to the Istio sidecar container.

[0041] S3: Receives the reply content returned by the application service container and matches the application program interface through the attributegen plug-in;

[0042] S4: Generate request_operation tag of request indicator according to the matched application interface.

[0043] Specifically, when matching the application interface through the attributegen plug-in, it includes: looking for the URL path in the hash map, if it exists, recording the name of the application interface; if it does not exist, the URL path is split according to " / ", and matched layer by layer from the multi-branch tree. If the leaf node cannot be matched, it is processed as matching to {arg}. If the leaf node is matched, the name of the application interface is recorded.

[0044] Example:

[0045] The Istio sidecar proxy / user / count request (to get the total number of users) looks up / user / count from the hash map, and after finding it, records the application interface to the indicator request_operation label, generating the following indicators:

[0046] istio_requests_total{

[0047] destination_workload="test-server",

[0048] destination_workload_namespace="test-ns",

[0049] reporter="destination",

[0050] request_method="GET",

[0051] request_operation="UserCount",

[0052] request_protocol="http",

[0053] response_code="200",

[0054] }

[0055] Istio sidecar proxy / user / 003 request (get user information with id 003), look for / user / 003 in hash map, if not found, try to match from multitree. Split / user / 003 into user and 003, match layer by layer in multitree, the first layer can match user, the second layer cannot match 003, but there is {arg} node in this layer, and it is a leaf node, so it is judged to match GetUser application interface, record this application interface in the indicator request_operation label, and generate the following indicators:

[0056] istio_requests_total{

[0057] destination_workload="test-server",

[0058] destination_workload_namespace="test-ns",

[0059] reporter="destination",

[0060] request_method="GET",

[0061] request_operation="GetUser",

[0062] request_protocol="http",

[0063] response_code="200",

[0064] }

[0065] In this embodiment, by performing hash map and multi-tree matching on the application interface, the application interface request without parameters can quickly generate a request_operation tag, and the application interface with parameters, such as / user / 003 and / user / 004, can be quickly aggregated into the request_operation of GetUser.

[0066] In this embodiment, the attributegen plug-in needs to pre-read the application interface aggregation configuration and store the application interface without parameters in a hash map, such as: / user / count and / user / image; the application interface with parameters is split according to the " / " in the URL path, and the parameter part is replaced with {arg}, and stored as a multi-branch tree, such as: / user / {id}, / user / update / {name} and / order / {id}.

[0067] Example:

[0068] Configuration reads:

[0069] {

[0070] "value": "UserCount",

[0071] "condition": "request.url_path== ' / user / count' && request.method =='GET'"

[0072] }

[0073] See also Figure 3 When request.url_path == ' / user / count is read, it is judged as an application interface without parameters based on ==, and the path / user / count is added to the hash map.

[0074] {

[0075] "value": "GetUser",

[0076] "condition": "request.url_path.matches(' / user / [^ / ]+') &&request.method == 'GET'"

[0077] }

[0078] When request.url_path.matches(' / user / [^ / ]+') is read, it is determined to be an application program interface with parameters based on matches and stored in a multitree (see Figure 3). The stored procedure is: split / user / [^ / ]+ into user and {arg} (the parameter part [^ / ]+ is replaced by {arg}). First, search the root node of the multitree to see if there is a user child node. If not, insert the user node. Then, search the user node to see if there is a {arg} child node. If not, insert the {arg} node. Because the {arg} node is already a leaf node, the insertion is complete.

[0079] In this embodiment, the application interface aggregation configuration is generated according to the application interface list specified by the ApiAttribute resource after the management component detects the ApiAttribute resource through the Watch application interface of Kubernetes.

[0080] Example:

[0081] API Version: networking.istio.io / v1alpha3

[0082] kind: EnvoyFilter

[0083] metadata:

[0084] name: test-server

[0085] namespace: test-ns

[0086] spec:

[0087] configPatches:

[0088] patch:

[0089] operation: INSERT_BEFORE

[0090] value:

[0091] name: istio.attributegen

[0092] typed_config:

[0093] "@type": type.googleapis.com / udpa.type.v1.TypedStruct

[0094] type_url: type.googleapis.com / envoy.extensions.filters.http.wasm.v3.Wasm

[0095] value:

[0096] config:

[0097] configuration:

[0098] "@type": type.googleapis.com / google.protobuf.StringValue

[0099] value: >

[0100] {

[0101] "attributes": [

[0102] {

[0103] "output_attribute": "istio_operation",

[0104] "match": [

[0105] {

[0106] "value": "UserCount",

[0107] "condition": "request.url_path== ' / user / count' && request.method == 'GET'"

[0108] },

[0109] {

[0110] "value": "GetUser",

[0111] "condition": "request.url_path.matches(' / user / [^ / ]+') && request.method == 'GET'"

[0112] } ]

[0114] } ]

[0116] }

[0117] vm_config:

[0118] code:

[0119] local:

[0120] inline_string: envoy.wasm.attributegen

[0121] runtime: envoy.wasm.runtime.null

[0122] In this embodiment, the ApiAttribute resource is created by the user through the kubectl tool. Specifically, the user writes the ApiAttribute resource and creates it through the kubectl tool. The resource specifies the list of application interfaces to be aggregated. For example, in the following example, the list of application interfaces to be aggregated is specified through spec.apis, including the application interface with parameters: GetUser / user / {id} and the application interface without parameters: UserCount / user / count.

[0123] ApiAttribute example:

[0124] API Version: asm.alauda.io / v1alpha1

[0125] kind: ApiAttribute

[0126] metadata:

[0127] name: test-server

[0128] namespace: test-ns

[0129] spec:

[0130] APIs:

[0131] - method: GET

[0132] operation: GetUser

[0133] path: / user / {id}

[0134] - method: GET

[0135] operation: UserCount

[0136] path: / user / count

[0137] In this embodiment, by extending the Istio attributegen plug-in, the Istio sidecar can load the plug-in and the application interface aggregation configuration. When proxying requests, the Istio sidecar can match the application interface URL path and record the matched application interface name.

[0138] This embodiment provides a method for classifying Istio traffic indicators according to application interfaces. By extending the Istio attributegen plug-in and adopting a new application interface URL path matching algorithm, it solves the problem of poor performance of existing sidecar proxy requests. When Istio aggregates application interface requests through attributegen, it can more quickly match and generate application interface names corresponding to URL paths, thereby improving the performance of sidecar proxy requests.

[0139] Embodiment 2

[0140] This embodiment provides a device for classifying Istio traffic indicators according to an application program interface. The device is used to implement a method for classifying Istio traffic indicators according to an application program interface, including:

[0141] An interception module, used to intercept an application program interface request initiated by the client service to the application service;

[0142] A request sending module, used to send the application interface request to the application service container for processing; the application service container processes the application interface request to obtain a reply content, and returns the reply content to the sidecar container;

[0143] A data receiving module, used for receiving the reply content returned by the application service container, and matching the application program interface through the attributegen plug-in;

[0144] The label generation module is used to generate the request_operation label of the request indicator according to the matching application interface.

[0145] For the specific implementation content of each module in a device for classifying Istio traffic indicators according to an application program interface, please refer to the above definition of a method for classifying Istio traffic indicators according to an application program interface, which will not be repeated here.

[0146] Embodiment 3

[0147] This embodiment provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, a method for classifying Istio traffic indicators according to an application program interface is implemented.

[0148] Embodiment 4

[0149] This embodiment provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of a method for classifying Istio traffic indicators according to an application program interface are implemented.

[0150] Embodiment 5

[0151] This embodiment provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps of a method for classifying Istio traffic indicators according to an application program interface.

[0152] The technical features of the above embodiments may be arbitrarily combined (as long as there is no contradiction in the combination of these technical features). To make the description concise, not all possible combinations of the technical features in the above embodiments are described; these embodiments that are not explicitly written should also be considered to be within the scope of this specification.

Claims

1. A method for classifying Istio traffic indicators according to application program interfaces, characterized in that: The method comprises a client service and an application service, wherein the client service and the application service are both deployed in a Pod in a kubenetes cluster. After the client service is injected with an Istio sidecar application service, a sidecar container is added to the Pod where the application service is deployed. The sidecar container shares a network space with the application service container, and the sidecar container uses iptables rules to configure network traffic redirection. The method is applied to the sidecar container, comprising: Intercepting an application program interface request initiated by the client service to the application service; Send the application interface request to the application service container for processing; the application service container processes the application interface request to obtain a reply content, and returns the reply content to the sidecar container; Receive the reply content returned by the application service container, and match the application program interface through the attributegen plug-in; Generate request_operation tag of request metric based on matching API; Matching the application interface through the attributegen plug-in specifically includes: searching the hash map for a URL path, and if so, recording the name of the application interface; if not, splitting the URL path according to " / ", and matching it layer by layer from the multi-branch tree, and if no leaf node is matched, processing it as matching {arg}, and if a leaf node is matched, recording the name of the application interface; The attributegen plug-in needs to pre-read the API aggregation configuration, store the API without parameters in a hash map, split the API with parameters according to the " / " in the URL path, and replace the parameter part with {arg}, and store it as a multi-fork tree; The application program interface aggregation configuration is generated according to the application program interface list specified by the ApiAttribute resource after the management component detects the ApiAttribute resource; The management component detects ApiAttribute resources through the Watch application program interface of Kubernetes; The ApiAttribute resource is created by the user through the kubectl tool.

2. A device for classifying Istio traffic indicators according to application program interfaces, characterized in that: The device is used to implement the method for classifying Istio traffic indicators according to application program interfaces according to claim 1, comprising: An interception module, used to intercept an application program interface request initiated by the client service to the application service; A request sending module, used to send the application interface request to the application service container for processing; the application service container processes the application interface request to obtain a reply content, and returns the reply content to the sidecar container; A data receiving module, used for receiving the reply content returned by the application service container, and matching the application program interface through the attributegen plug-in; The label generation module is used to generate the request_operation label of the request indicator according to the matching application interface.

3. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to claim 1 are implemented.

4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to claim 1 are implemented.

5. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to claim 1 are implemented.