英文:
Customizing Istio metrics results in duplicated metrics
问题
我想通过使用EnvoyFilter将request.url_path
和request.method
信息添加到istio_request_total
指标中。
Istio版本:1.8.5
使用我的EnvoyFilter,通过添加envoy_request_path__$(path-seperated-with-dashes)__
前缀来复制istio_requests_total
指标。
以下是我使用的EnvoyFilter:
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: customize-requests-total-metric
spec:
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_OUTBOUND
listener:
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
subFilter:
name: istio.stats
proxy:
proxyVersion: ^1\.8.*
patch:
operation: REPLACE
value:
name: istio.stats
typed_config:
"@type": type.googleapis.com/udpa.type.v1.TypedStruct
type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
value:
config:
configuration:
"@type": type.googleapis.com/google.protobuf.StringValue
value: |
{
"debug": "true",
"stat_prefix": "istio",
"metrics": [
{
"name": "requests_total",
"dimensions": {
"request_path": "request.url_path",
"request_method": "request.method"
}
}
]
}
root_id: stats_outbound
vm_config:
code:
local:
inline_string: envoy.wasm.stats
runtime: envoy.wasm.runtime.null
vm_id: stats_outbound
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
subFilter:
name: istio.stats
proxy:
proxyVersion: ^1\.8.*
patch:
operation: REPLACE
value:
name: istio.stats
typed_config:
"@type": type.googleapis.com/udpa.type.v1.TypedStruct
type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
value:
config:
configuration:
"@type": type.googleapis.com/google.protobuf.StringValue
value: |
{
"debug": "true",
"stat_prefix": "istio",
"metrics": [
{
"name": "requests_total",
"dimensions": {
"request_path": "request.url_path",
"request_method": "request.method"
}
}
]
}
root_id: stats_inbound
vm_config:
code:
local:
inline_string: envoy.wasm.stats
runtime: envoy.wasm.runtime.null
vm_id: stats_inbound
这将通过添加envoy_request_path__$(path-seperated-with-dashes)__
前缀来复制istio_requests_total
指标。以下是一个示例:
# TYPE envoy_request_path____catalog_lint___istio_requests_total counter
envoy_request_path____catalog_lint___istio_requests_total{response_code="200",reporter="destination",source_workload="my-service",source_workload_namespace="my-namespace",source_principal="unknown",source_app="my-service",source_version="unknown",destination_workload="api-linter",destination_workload_namespace="my-namespace",destination_principal="unknown",destination_app="my-service",destination_version="unknown",destination_service="my-service",destination_service_name="my-service",destination_service_namespace="my-namespace",request_protocol="http",response_flags="-",grpc_response_status="",connection_security_policy="none",source_canonical_service="my-service",destination_canonical_service="api-linter",source_canonical_revision="latest",destination_canonical_revision="latest",request_method="GET"} 4204
我的问题是,如何像上面的示例中的request_method="GET"
一样,将请求路径作为标签添加到主要的istio_requests_total
指标中?
英文:
I want to add request.url_path
and request.method
information to the istio_request_total
metric by using an EnvoyFilter.
Istio Version: 1.8.5
Using my EnvoyFilter duplicates istio_requests_total
metric by adding envoy_request_path__$(path-seperated-with-dashes)__
prefix.
Below is the EnvoyFilter I use
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: customize-requests-total-metric
spec:
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_OUTBOUND
listener:
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
subFilter:
name: istio.stats
proxy:
proxyVersion: ^1\.8.*
patch:
operation: REPLACE
value:
name: istio.stats
typed_config:
"@type": type.googleapis.com/udpa.type.v1.TypedStruct
type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
value:
config:
configuration:
"@type": type.googleapis.com/google.protobuf.StringValue
value: |
{
"debug": "true",
"stat_prefix": "istio",
"metrics": [
{
"name": "requests_total",
"dimensions": {
"request_path": "request.url_path",
"request_method": "request.method"
}
}
]
}
root_id: stats_outbound
vm_config:
code:
local:
inline_string: envoy.wasm.stats
runtime: envoy.wasm.runtime.null
vm_id: stats_outbound
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
subFilter:
name: istio.stats
proxy:
proxyVersion: ^1\.8.*
patch:
operation: REPLACE
value:
name: istio.stats
typed_config:
"@type": type.googleapis.com/udpa.type.v1.TypedStruct
type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
value:
config:
configuration:
"@type": type.googleapis.com/google.protobuf.StringValue
value: |
{
"debug": "true",
"stat_prefix": "istio",
"metrics": [
{
"name": "requests_total",
"dimensions": {
"request_path": "request.url_path",
"request_method": "request.method"
}
}
]
}
root_id: stats_inbound
vm_config:
code:
local:
inline_string: envoy.wasm.stats
runtime: envoy.wasm.runtime.null
vm_id: stats_inbound
This duplicates istio_requests_total
metric by adding envoy_request_path__$(path-seperated-with-dashes)__
prefix. Below is an example of it.
# TYPE envoy_request_path____catalog_lint___istio_requests_total counter
envoy_request_path____catalog_lint___istio_requests_total{response_code="200",reporter="destination",source_workload="my-service",source_workload_namespace="my-namespace",source_principal="unknown",source_app="my-service",source_version="unknown",destination_workload="api-linter",destination_workload_namespace="my-namespace",destination_principal="unknown",destination_app="my-service",destination_version="unknown",destination_service="my-service",destination_service_name="my-service",destination_service_namespace="my-namespace",request_protocol="http",response_flags="-",grpc_response_status="",connection_security_policy="none",source_canonical_service="my-service",destination_canonical_service="api-linter",source_canonical_revision="latest",destination_canonical_revision="latest",request_method="GET"} 4204
**
My question is, how can I add request path as a label to the main istio_requests_total
metric like I did for request_method="GET"
in the example above?**
答案1
得分: 0
url_path
和method
不是自动提取的DefaultStatTags
的一部分。
要使其工作,您必须向部署添加extraStatTags
注释(sidecar.istio.io/extraStatTags: request_path,request_method
)(或通过网格配置在整个网格范围内进行配置)。请参阅文档中的示例。
此外,您应考虑升级到较新版本的Istio,因为1.8版本于2020年发布,不再受支持。
英文:
The url_path
and method
are not part of the DefaultStatTags
that get extracted automatically.
To make it work, you must add the extraStatTags
annotation (sidecar.istio.io/extraStatTags: request_path,request_method
) to the deployment (or configure it mesh-wide via mesh config). See the example in the docs.
Also, you should consider upgrading to the newer version of Istio as 1.8 was released in 2020 and not supported anymore.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论