自定义Istio指标会导致指标重复。

huangapple go评论108阅读模式
英文:

Customizing Istio metrics results in duplicated metrics

问题

我想通过使用EnvoyFilter将request.url_pathrequest.method信息添加到istio_request_total指标中。

Istio版本:1.8.5

使用我的EnvoyFilter,通过添加envoy_request_path__$(path-seperated-with-dashes)__前缀来复制istio_requests_total指标。

以下是我使用的EnvoyFilter:

  1. apiVersion: networking.istio.io/v1alpha3
  2. kind: EnvoyFilter
  3. metadata:
  4. name: customize-requests-total-metric
  5. spec:
  6. configPatches:
  7. - applyTo: HTTP_FILTER
  8. match:
  9. context: SIDECAR_OUTBOUND
  10. listener:
  11. filterChain:
  12. filter:
  13. name: envoy.filters.network.http_connection_manager
  14. subFilter:
  15. name: istio.stats
  16. proxy:
  17. proxyVersion: ^1\.8.*
  18. patch:
  19. operation: REPLACE
  20. value:
  21. name: istio.stats
  22. typed_config:
  23. "@type": type.googleapis.com/udpa.type.v1.TypedStruct
  24. type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
  25. value:
  26. config:
  27. configuration:
  28. "@type": type.googleapis.com/google.protobuf.StringValue
  29. value: |
  30. {
  31. "debug": "true",
  32. "stat_prefix": "istio",
  33. "metrics": [
  34. {
  35. "name": "requests_total",
  36. "dimensions": {
  37. "request_path": "request.url_path",
  38. "request_method": "request.method"
  39. }
  40. }
  41. ]
  42. }
  43. root_id: stats_outbound
  44. vm_config:
  45. code:
  46. local:
  47. inline_string: envoy.wasm.stats
  48. runtime: envoy.wasm.runtime.null
  49. vm_id: stats_outbound
  50. - applyTo: HTTP_FILTER
  51. match:
  52. context: SIDECAR_INBOUND
  53. listener:
  54. filterChain:
  55. filter:
  56. name: envoy.filters.network.http_connection_manager
  57. subFilter:
  58. name: istio.stats
  59. proxy:
  60. proxyVersion: ^1\.8.*
  61. patch:
  62. operation: REPLACE
  63. value:
  64. name: istio.stats
  65. typed_config:
  66. "@type": type.googleapis.com/udpa.type.v1.TypedStruct
  67. type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
  68. value:
  69. config:
  70. configuration:
  71. "@type": type.googleapis.com/google.protobuf.StringValue
  72. value: |
  73. {
  74. "debug": "true",
  75. "stat_prefix": "istio",
  76. "metrics": [
  77. {
  78. "name": "requests_total",
  79. "dimensions": {
  80. "request_path": "request.url_path",
  81. "request_method": "request.method"
  82. }
  83. }
  84. ]
  85. }
  86. root_id: stats_inbound
  87. vm_config:
  88. code:
  89. local:
  90. inline_string: envoy.wasm.stats
  91. runtime: envoy.wasm.runtime.null
  92. vm_id: stats_inbound

这将通过添加envoy_request_path__$(path-seperated-with-dashes)__前缀来复制istio_requests_total指标。以下是一个示例:

  1. # TYPE envoy_request_path____catalog_lint___istio_requests_total counter
  2. 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

  1. apiVersion: networking.istio.io/v1alpha3
  2. kind: EnvoyFilter
  3. metadata:
  4. name: customize-requests-total-metric
  5. spec:
  6. configPatches:
  7. - applyTo: HTTP_FILTER
  8. match:
  9. context: SIDECAR_OUTBOUND
  10. listener:
  11. filterChain:
  12. filter:
  13. name: envoy.filters.network.http_connection_manager
  14. subFilter:
  15. name: istio.stats
  16. proxy:
  17. proxyVersion: ^1\.8.*
  18. patch:
  19. operation: REPLACE
  20. value:
  21. name: istio.stats
  22. typed_config:
  23. "@type": type.googleapis.com/udpa.type.v1.TypedStruct
  24. type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
  25. value:
  26. config:
  27. configuration:
  28. "@type": type.googleapis.com/google.protobuf.StringValue
  29. value: |
  30. {
  31. "debug": "true",
  32. "stat_prefix": "istio",
  33. "metrics": [
  34. {
  35. "name": "requests_total",
  36. "dimensions": {
  37. "request_path": "request.url_path",
  38. "request_method": "request.method"
  39. }
  40. }
  41. ]
  42. }
  43. root_id: stats_outbound
  44. vm_config:
  45. code:
  46. local:
  47. inline_string: envoy.wasm.stats
  48. runtime: envoy.wasm.runtime.null
  49. vm_id: stats_outbound
  50. - applyTo: HTTP_FILTER
  51. match:
  52. context: SIDECAR_INBOUND
  53. listener:
  54. filterChain:
  55. filter:
  56. name: envoy.filters.network.http_connection_manager
  57. subFilter:
  58. name: istio.stats
  59. proxy:
  60. proxyVersion: ^1\.8.*
  61. patch:
  62. operation: REPLACE
  63. value:
  64. name: istio.stats
  65. typed_config:
  66. "@type": type.googleapis.com/udpa.type.v1.TypedStruct
  67. type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
  68. value:
  69. config:
  70. configuration:
  71. "@type": type.googleapis.com/google.protobuf.StringValue
  72. value: |
  73. {
  74. "debug": "true",
  75. "stat_prefix": "istio",
  76. "metrics": [
  77. {
  78. "name": "requests_total",
  79. "dimensions": {
  80. "request_path": "request.url_path",
  81. "request_method": "request.method"
  82. }
  83. }
  84. ]
  85. }
  86. root_id: stats_inbound
  87. vm_config:
  88. code:
  89. local:
  90. inline_string: envoy.wasm.stats
  91. runtime: envoy.wasm.runtime.null
  92. 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.

  1. # TYPE envoy_request_path____catalog_lint___istio_requests_total counter
  2. 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_pathmethod不是自动提取的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.

huangapple
  • 本文由 发表于 2023年7月27日 14:30:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76777029.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定