From 9908cbe73a2f30980f81adeaa5accaca8b26a7cd Mon Sep 17 00:00:00 2001 From: Yuki Sawa Date: Wed, 21 Oct 2020 15:54:18 -0700 Subject: [PATCH 1/5] Add example prom statsd exporter conf Signed-off-by: Yuki Sawa --- examples/prom-statsd-exporter/conf.yaml | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 examples/prom-statsd-exporter/conf.yaml diff --git a/examples/prom-statsd-exporter/conf.yaml b/examples/prom-statsd-exporter/conf.yaml new file mode 100644 index 000000000..0706548d8 --- /dev/null +++ b/examples/prom-statsd-exporter/conf.yaml @@ -0,0 +1,67 @@ +mappings: # Requires statsd exporter >= v0.6.0 since it uses the "drop" action. + - match: + "ratelimit.service.rate_limit.*.*.near_limit" + name: "ratelimit_service_rate_limit_near_limit" + timer_type: "histogram" + labels: + domain: "$1" + key1: "$2" + - match: + "ratelimit.service.rate_limit.*.*.over_limit" + name: "ratelimit_service_rate_limit_over_limit" + timer_type: "histogram" + labels: + domain: "$1" + key1: "$2" + - match: + "ratelimit.service.rate_limit.*.*.total_hits" + name: "ratelimit_service_rate_limit_total_hits" + timer_type: "histogram" + labels: + domain: "$1" + key1: "$2" + + - match: + "ratelimit.service.rate_limit.*.*.*.near_limit" + name: "ratelimit_service_rate_limit_near_limit" + timer_type: "histogram" + labels: + domain: "$1" + key1: "$2" + key2: "$3" + - match: + "ratelimit.service.rate_limit.*.*.*.over_limit" + name: "ratelimit_service_rate_limit_over_limit" + timer_type: "histogram" + labels: + domain: "$1" + key1: "$2" + key2: "$3" + - match: + "ratelimit.service.rate_limit.*.*.*.total_hits" + name: "ratelimit_service_rate_limit_total_hits" + timer_type: "histogram" + labels: + domain: "$1" + key1: "$2" + key2: "$3" + + - match: "ratelimit.service.call.should_rate_limit.*" + name: "ratelimit_service_should_rate_limit_error" + match_metric_type: counter + labels: + err_type: "$1" + + - match: "ratelimit.service.config_load_success" + name: "ratelimit_service_config_load_success" + match_metric_type: counter + - match: "ratelimit.service.config_load_error" + name: "ratelimit_service_config_load_error" + match_metric_type: counter + - match: "ratelimit.service.config_load_error" + name: "ratelimit_service_config_load_error" + match_metric_type: counter + - match: "." + match_type: "regex" + action: "drop" + name: "dropped" From c90a8294a2a523de55a24bec6fda9d70278b3c4b Mon Sep 17 00:00:00 2001 From: Yuki Sawa Date: Wed, 21 Oct 2020 15:54:33 -0700 Subject: [PATCH 2/5] Add example prom statsd exporter conf Signed-off-by: Yuki Sawa --- docker-compose-example.yml | 7 +++++++ examples/envoy/proxy.yaml | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docker-compose-example.yml b/docker-compose-example.yml index f96879ee4..9739feaaf 100644 --- a/docker-compose-example.yml +++ b/docker-compose-example.yml @@ -11,12 +11,19 @@ services: statsd: image: prom/statsd-exporter:v0.18.0 + entrypoint: /bin/statsd_exporter + command: + - "--statsd.mapping-config=/etc/statsd-exporter/conf.yaml" expose: - 9125 + - 9102 ports: - 9125:9125 + - 9102:9102 # Visit http://localhost:9102/metrics to see metrics in Prometheus format networks: - ratelimit-network + volumes: + - ./examples/prom-statsd-exporter/conf.yaml:/etc/statsd-exporter/conf.yaml ratelimit: image: envoyproxy/ratelimit:master diff --git a/examples/envoy/proxy.yaml b/examples/envoy/proxy.yaml index bb45503f9..74a58cef9 100644 --- a/examples/envoy/proxy.yaml +++ b/examples/envoy/proxy.yaml @@ -72,8 +72,8 @@ static_resources: cluster: mock rate_limits: - actions: - - source_cluster: {} - - destination_cluster: {} + - source_cluster: {} # This action's value is populated by the "service-cluster" arg passed in when starting Envoy. In this example, it's "proxy" (see docker-compose-example.yml) + - destination_cluster: {} # This action's value is populated by the value set in the above "cluster" field -- "mock". - match: prefix: /header route: From d920809af658a5791cf5cab67a09e5e2d268d323 Mon Sep 17 00:00:00 2001 From: Yuki Sawa Date: Tue, 3 Nov 2020 14:09:31 -0800 Subject: [PATCH 3/5] Convert example envoy conf to v3 Signed-off-by: Yuki Sawa --- examples/envoy/mock.yaml | 53 ++++++++++++++++++++------------------- examples/envoy/proxy.yaml | 11 ++++---- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/examples/envoy/mock.yaml b/examples/envoy/mock.yaml index bd85fc3d2..87574494b 100644 --- a/examples/envoy/mock.yaml +++ b/examples/envoy/mock.yaml @@ -1,31 +1,32 @@ static_resources: listeners: - - address: - socket_address: - address: 0.0.0.0 - port_value: 9999 - filter_chains: - - filters: - - name: envoy.http_connection_manager - config: - codec_type: auto - stat_prefix: ingress - route_config: - name: ingress - virtual_hosts: - - name: backend - domains: - - "*" - routes: - - match: - prefix: "/" - direct_response: - status: "200" - body: - inline_string: "Hello World" - http_filters: - - name: envoy.router - config: {} + - address: + socket_address: + address: 0.0.0.0 + port_value: 9999 + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + codec_type: AUTO + stat_prefix: ingress + route_config: + name: ingress + virtual_hosts: + - name: backend + domains: + - "*" + routes: + - match: + prefix: "/" + direct_response: + status: "200" + body: + inline_string: "Hello World" + http_filters: + - name: envoy.filters.http.router + typed_config: {} admin: access_log_path: "/dev/null" address: diff --git a/examples/envoy/proxy.yaml b/examples/envoy/proxy.yaml index 74a58cef9..4b01d5a5b 100644 --- a/examples/envoy/proxy.yaml +++ b/examples/envoy/proxy.yaml @@ -41,9 +41,10 @@ static_resources: port_value: 8888 filter_chains: - filters: - - name: envoy.http_connection_manager - config: - codec_type: auto + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + codec_type: AUTO stat_prefix: ingress http_filters: - name: envoy.rate_limit @@ -57,8 +58,8 @@ static_resources: grpc_service: envoy_grpc: cluster_name: ratelimit - - name: envoy.router - config: {} + - name: envoy.filters.http.router + typed_config: {} route_config: name: route virtual_hosts: From aeeaac8083f9943575a68d9c89c6bd6b25b6482d Mon Sep 17 00:00:00 2001 From: Yuki Sawa Date: Thu, 12 Nov 2020 19:31:42 -0800 Subject: [PATCH 4/5] rl http filter to v3 Signed-off-by: Yuki Sawa --- examples/envoy/proxy.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/envoy/proxy.yaml b/examples/envoy/proxy.yaml index 4b01d5a5b..6ce4af07a 100644 --- a/examples/envoy/proxy.yaml +++ b/examples/envoy/proxy.yaml @@ -47,8 +47,9 @@ static_resources: codec_type: AUTO stat_prefix: ingress http_filters: - - name: envoy.rate_limit - config: + - name: envoy.filters.http.ratelimit + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit domain: rl request_type: external stage: 0 From 6115df42d84acbad8a39cd8f49869fce0df4c329 Mon Sep 17 00:00:00 2001 From: Yuki Sawa Date: Mon, 16 Nov 2020 12:53:54 -0800 Subject: [PATCH 5/5] fix verbiage in comments Signed-off-by: Yuki Sawa --- examples/envoy/proxy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/envoy/proxy.yaml b/examples/envoy/proxy.yaml index 6ce4af07a..0bd780db7 100644 --- a/examples/envoy/proxy.yaml +++ b/examples/envoy/proxy.yaml @@ -75,7 +75,7 @@ static_resources: rate_limits: - actions: - source_cluster: {} # This action's value is populated by the "service-cluster" arg passed in when starting Envoy. In this example, it's "proxy" (see docker-compose-example.yml) - - destination_cluster: {} # This action's value is populated by the value set in the above "cluster" field -- "mock". + - destination_cluster: {} # This action's value is populated by the value set in the above egress "cluster" field -- "mock" - match: prefix: /header route: