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/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 bb45503f9..0bd780db7 100644 --- a/examples/envoy/proxy.yaml +++ b/examples/envoy/proxy.yaml @@ -41,13 +41,15 @@ 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 - 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 @@ -57,8 +59,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: @@ -72,8 +74,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 egress "cluster" field -- "mock" - match: prefix: /header route: 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"