envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.95k stars 4.8k forks source link

Unable to use HTTP local rate limit #13761

Closed leyvReyn closed 4 years ago

leyvReyn commented 4 years ago

Good day.

Trying to follow guide for HTTP local rate limit on documentation page

But getting error on envoy start:

[2020-10-26 16:39:19.407][8][critical][main] [source/server/server.cc:102] error initializing configuration '/etc/envoy/envoy.yaml': Didn't find a registered implementation for name: 'envoy.filters.http.local_ratelimit'

Envoy version: docker container envoyproxy/envoy-alpine:v1.16.0

I guess the problem might be because well known names missing envoy.filters.http.local_ratelimit

Possibly related pull request

Full config:

static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address:
          address: 0.0.0.0
          port_value: 8090
      filter_chains:
        - filters:
          - name: envoy.filters.http.local_ratelimit
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              stat_prefix: http_local_rate_limiter
              token_bucket:
                max_tokens: 10000
                tokens_per_fill: 1000
                fill_interval: 1s
              filter_enabled:
                runtime_key: local_rate_limit_enabled
                default_value:
                  numerator: 100
                  denominator: HUNDRED
              filter_enforced:
                runtime_key: local_rate_limit_enforced
                default_value:
                  numerator: 100
                  denominator: HUNDRED
              response_headers_to_add:
                - append: false
                  header:
                    key: x-local-rate-limit
                    value: 'true'
          - name: envoy.filters.network.http_connection_manager
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
              stat_prefix: ingress_http
              http_filters:
                - name: envoy.filters.http.router
              route_config:
                name: local_route
                virtual_hosts:
                  - name: local_service
                    domains: ["*"]
                    routes:
                      - match:
                          prefix: /stub1
                        route:
                          cluster: stub_cluster1
                          regex_rewrite:
                            pattern:
                              regex: ^/stub1[/]*(.*)$ 
                              google_re2: {}
                            substitution: /\1
                      - match:
                          prefix: /stub2
                        route:
                          cluster: stub_cluster2
                          regex_rewrite:
                            pattern:
                              regex: ^/stub2[/]*(.*)$
                              google_re2: {}
                            substitution: /\1
  clusters:
    - name: stub_cluster1
      connect_timeout: 0.25s
      type: STRICT_DNS
      load_assignment:
        cluster_name: stub_cluster1
        endpoints:
          - lb_endpoints:
              - endpoint: {address: {socket_address: {address: stub1 , port_value: 8080}}}
    - name: stub_cluster2
      connect_timeout: 0.25s
      type: STRICT_DNS
      load_assignment:
        cluster_name: stub_cluster2
        endpoints:
          - lb_endpoints:
              - endpoint: {address: {socket_address: {address: stub2 , port_value: 8081}}}

Full log:

envoy_1  | [2020-10-26 16:50:12.838][7][info][main] [source/server/server.cc:305] initializing epoch 0 (base id=0, hot restart version=11.104)
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:307] statically linked extensions:
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.thrift_proxy.transports: auto, framed, header, unframed
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.resolvers: envoy.ip
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.filters.listener: envoy.filters.listener.http_inspector, envoy.filters.listener.original_dst, envoy.filters.listener.original_src, envoy.filters.listener.proxy_protocol, envoy.filters.listener.tls_inspector, envoy.listener.http_inspector, envoy.listener.original_dst, envoy.listener.original_src, envoy.listener.proxy_protocol, envoy.listener.tls_inspector
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.thrift_proxy.protocols: auto, binary, binary/non-strict, compact, twitter
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.dubbo_proxy.filters: envoy.filters.dubbo.router
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.udp_packet_writers: udp_default_writer, udp_gso_batch_writer
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.transport_sockets.upstream: envoy.transport_sockets.alts, envoy.transport_sockets.quic, envoy.transport_sockets.raw_buffer, envoy.transport_sockets.tap, envoy.transport_sockets.tls, envoy.transport_sockets.upstream_proxy_protocol, raw_buffer, tls
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.health_checkers: envoy.health_checkers.redis
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.retry_priorities: envoy.retry_priorities.previous_priorities
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.guarddog_actions: envoy.watchdog.abort_action, envoy.watchdog.profile_action
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.tracers: envoy.dynamic.ot, envoy.lightstep, envoy.tracers.datadog, envoy.tracers.dynamic_ot, envoy.tracers.lightstep, envoy.tracers.opencensus, envoy.tracers.xray, envoy.tracers.zipkin, envoy.zipkin
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.udp_listeners: quiche_quic_listener, raw_udp_listener
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.http.cache: envoy.extensions.http.cache.simple
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.quic_client_codec: quiche
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.dubbo_proxy.protocols: dubbo
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.dubbo_proxy.route_matchers: default
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.access_loggers: envoy.access_loggers.file, envoy.access_loggers.http_grpc, envoy.access_loggers.tcp_grpc, envoy.file_access_log, envoy.http_grpc_access_log, envoy.tcp_grpc_access_log
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.compression.decompressor: envoy.compression.gzip.decompressor
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.stats_sinks: envoy.dog_statsd, envoy.metrics_service, envoy.stat_sinks.dog_statsd, envoy.stat_sinks.hystrix, envoy.stat_sinks.metrics_service, envoy.stat_sinks.statsd, envoy.statsd
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.resource_monitors: envoy.resource_monitors.fixed_heap, envoy.resource_monitors.injected_resource
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.thrift_proxy.filters: envoy.filters.thrift.rate_limit, envoy.filters.thrift.router
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.quic_server_codec: quiche
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.dubbo_proxy.serializers: dubbo.hessian2
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.filters.udp_listener: envoy.filters.udp.dns_filter, envoy.filters.udp_listener.udp_proxy
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.bootstrap: envoy.extensions.network.socket_interface.default_socket_interface
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.clusters: envoy.cluster.eds, envoy.cluster.logical_dns, envoy.cluster.original_dst, envoy.cluster.static, envoy.cluster.strict_dns, envoy.clusters.aggregate, envoy.clusters.dynamic_forward_proxy, envoy.clusters.redis
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.grpc_credentials: envoy.grpc_credentials.aws_iam, envoy.grpc_credentials.default, envoy.grpc_credentials.file_based_metadata
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.internal_redirect_predicates: envoy.internal_redirect_predicates.allow_listed_routes, envoy.internal_redirect_predicates.previous_routes, envoy.internal_redirect_predicates.safe_cross_scheme
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.retry_host_predicates: envoy.retry_host_predicates.omit_canary_hosts, envoy.retry_host_predicates.omit_host_metadata, envoy.retry_host_predicates.previous_hosts
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.upstreams: envoy.filters.connection_pools.http.generic, envoy.filters.connection_pools.http.http, envoy.filters.connection_pools.http.tcp
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.compression.compressor: envoy.compression.gzip.compressor
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.filters.http: envoy.buffer, envoy.cors, envoy.csrf, envoy.ext_authz, envoy.fault, envoy.filters.http.adaptive_concurrency, envoy.filters.http.admission_control, envoy.filters.http.aws_lambda, envoy.filters.http.aws_request_signing, envoy.filters.http.buffer, envoy.filters.http.cache, envoy.filters.http.cdn_loop, envoy.filters.http.compressor, envoy.filters.http.cors, envoy.filters.http.csrf, envoy.filters.http.decompressor, envoy.filters.http.dynamic_forward_proxy, envoy.filters.http.dynamo, envoy.filters.http.ext_authz, envoy.filters.http.fault, envoy.filters.http.grpc_http1_bridge, envoy.filters.http.grpc_http1_reverse_bridge, envoy.filters.http.grpc_json_transcoder, envoy.filters.http.grpc_stats, envoy.filters.http.grpc_web, envoy.filters.http.gzip, envoy.filters.http.header_to_metadata, envoy.filters.http.health_check, envoy.filters.http.ip_tagging, envoy.filters.http.jwt_authn, envoy.filters.http.local_ratelimit, envoy.filters.http.lua, envoy.filters.http.oauth, envoy.filters.http.on_demand, envoy.filters.http.original_src, envoy.filters.http.ratelimit, envoy.filters.http.rbac, envoy.filters.http.router, envoy.filters.http.squash, envoy.filters.http.tap, envoy.grpc_http1_bridge, envoy.grpc_json_transcoder, envoy.grpc_web, envoy.gzip, envoy.health_check, envoy.http_dynamo_filter, envoy.ip_tagging, envoy.local_rate_limit, envoy.lua, envoy.rate_limit, envoy.router, envoy.squash
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.filters.network: envoy.client_ssl_auth, envoy.echo, envoy.ext_authz, envoy.filters.network.client_ssl_auth, envoy.filters.network.direct_response, envoy.filters.network.dubbo_proxy, envoy.filters.network.echo, envoy.filters.network.ext_authz, envoy.filters.network.http_connection_manager, envoy.filters.network.kafka_broker, envoy.filters.network.local_ratelimit, envoy.filters.network.mongo_proxy, envoy.filters.network.mysql_proxy, envoy.filters.network.postgres_proxy, envoy.filters.network.ratelimit, envoy.filters.network.rbac, envoy.filters.network.redis_proxy, envoy.filters.network.rocketmq_proxy, envoy.filters.network.sni_cluster, envoy.filters.network.sni_dynamic_forward_proxy, envoy.filters.network.tcp_proxy, envoy.filters.network.thrift_proxy, envoy.filters.network.zookeeper_proxy, envoy.http_connection_manager, envoy.mongo_proxy, envoy.ratelimit, envoy.redis_proxy, envoy.tcp_proxy
envoy_1  | [2020-10-26 16:50:12.839][7][info][main] [source/server/server.cc:309]   envoy.transport_sockets.downstream: envoy.transport_sockets.alts, envoy.transport_sockets.quic, envoy.transport_sockets.raw_buffer, envoy.transport_sockets.tap, envoy.transport_sockets.tls, raw_buffer, tls
envoy_1  | [2020-10-26 16:50:12.848][7][info][main] [source/server/server.cc:325] HTTP header map info:
envoy_1  | [2020-10-26 16:50:12.848][7][warning][runtime] [source/common/runtime/runtime_features.cc:31] Unable to use runtime singleton for feature envoy.http.headermap.lazy_map_min_size
envoy_1  | [2020-10-26 16:50:12.848][7][warning][runtime] [source/common/runtime/runtime_features.cc:31] Unable to use runtime singleton for feature envoy.http.headermap.lazy_map_min_size
envoy_1  | [2020-10-26 16:50:12.849][7][warning][runtime] [source/common/runtime/runtime_features.cc:31] Unable to use runtime singleton for feature envoy.http.headermap.lazy_map_min_size
envoy_1  | [2020-10-26 16:50:12.849][7][warning][runtime] [source/common/runtime/runtime_features.cc:31] Unable to use runtime singleton for feature envoy.http.headermap.lazy_map_min_size
envoy_1  | [2020-10-26 16:50:12.849][7][info][main] [source/server/server.cc:328]   request header map: 608 bytes: :authority,:method,:path,:protocol,:scheme,accept,accept-encoding,access-control-request-method,authorization,cache-control,cdn-loop,connection,content-encoding,content-length,content-type,expect,grpc-accept-encoding,grpc-timeout,if-match,if-modified-since,if-none-match,if-range,if-unmodified-since,keep-alive,origin,pragma,proxy-connection,referer,te,transfer-encoding,upgrade,user-agent,via,x-client-trace-id,x-envoy-attempt-count,x-envoy-decorator-operation,x-envoy-downstream-service-cluster,x-envoy-downstream-service-node,x-envoy-expected-rq-timeout-ms,x-envoy-external-address,x-envoy-force-trace,x-envoy-hedge-on-per-try-timeout,x-envoy-internal,x-envoy-ip-tags,x-envoy-max-retries,x-envoy-original-path,x-envoy-original-url,x-envoy-retriable-header-names,x-envoy-retriable-status-codes,x-envoy-retry-grpc-on,x-envoy-retry-on,x-envoy-upstream-alt-stat-name,x-envoy-upstream-rq-per-try-timeout-ms,x-envoy-upstream-rq-timeout-alt-response,x-envoy-upstream-rq-timeout-ms,x-forwarded-client-cert,x-forwarded-for,x-forwarded-proto,x-ot-span-context,x-request-id
envoy_1  | [2020-10-26 16:50:12.849][7][info][main] [source/server/server.cc:328]   request trailer map: 128 bytes: 
envoy_1  | [2020-10-26 16:50:12.849][7][info][main] [source/server/server.cc:328]   response header map: 424 bytes: :status,access-control-allow-credentials,access-control-allow-headers,access-control-allow-methods,access-control-allow-origin,access-control-expose-headers,access-control-max-age,age,cache-control,connection,content-encoding,content-length,content-type,date,etag,expires,grpc-message,grpc-status,keep-alive,last-modified,location,proxy-connection,server,transfer-encoding,upgrade,vary,via,x-envoy-attempt-count,x-envoy-decorator-operation,x-envoy-degraded,x-envoy-immediate-health-check-fail,x-envoy-ratelimited,x-envoy-upstream-canary,x-envoy-upstream-healthchecked-cluster,x-envoy-upstream-service-time,x-request-id
envoy_1  | [2020-10-26 16:50:12.849][7][info][main] [source/server/server.cc:328]   response trailer map: 152 bytes: grpc-message,grpc-status
envoy_1  | [2020-10-26 16:50:12.850][7][warning][main] [source/server/server.cc:454] No admin address given, so no admin HTTP server started.
envoy_1  | [2020-10-26 16:50:12.850][7][info][main] [source/server/server.cc:583] runtime: layers:
envoy_1  |   - name: base
envoy_1  |     static_layer:
envoy_1  |       {}
envoy_1  |   - name: admin
envoy_1  |     admin_layer:
envoy_1  |       {}
envoy_1  | [2020-10-26 16:50:12.850][7][info][config] [source/server/configuration_impl.cc:95] loading tracing configuration
envoy_1  | [2020-10-26 16:50:12.850][7][info][config] [source/server/configuration_impl.cc:70] loading 0 static secret(s)
envoy_1  | [2020-10-26 16:50:12.850][7][info][config] [source/server/configuration_impl.cc:76] loading 2 cluster(s)
envoy_1  | [2020-10-26 16:50:12.853][7][info][config] [source/server/configuration_impl.cc:80] loading 1 listener(s)
envoy_1  | [2020-10-26 16:50:12.855][7][critical][main] [source/server/server.cc:102] error initializing configuration '/etc/envoy/envoy.yaml': Didn't find a registered implementation for name: 'envoy.filters.http.local_ratelimit'
envoy_1  | [2020-10-26 16:50:12.855][7][info][main] [source/server/server.cc:731] exiting
envoy_1  | Didn't find a registered implementation for name: 'envoy.filters.http.local_ratelimit'
envoy_config_test_envoy_1 exited with code 1
yanavlasov commented 4 years ago

@rgs1 for any comments.

rgs1 commented 4 years ago

@leyvReyn the http local rate limiter is an HTTP filter, not a network filter (there an L4 filter too, but that's not what we are talking about here). So:

      filter_chains:
        - filters:
          - name: envoy.filters.http.local_ratelimit

is wrong. You want it within the http filters, e.g.:

...
              http_filters:
                - name: envoy.filters.http.local_ratelimit
                   typed_config:
                     "@type": type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
                     stat_prefix: http_local_rate_limiter
....
                - name: envoy.filters.http.router
...
leyvReyn commented 4 years ago

Awesome, thank you! The issue can be closed. This configuration worked well:

static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address:
          address: 0.0.0.0
          port_value: 8090
      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
                stat_prefix: ingress_http
                http_filters:
                  - name: envoy.filters.http.local_ratelimit
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
                      stat_prefix: http_local_rate_limiter
                      token_bucket:
                        max_tokens: 3
                        tokens_per_fill: 1
                        fill_interval: 1s
                      filter_enabled:
                        runtime_key: local_rate_limit_enabled
                        default_value:
                          numerator: 100
                          denominator: HUNDRED
                      filter_enforced:
                        runtime_key: local_rate_limit_enforced
                        default_value:
                          numerator: 100
                          denominator: HUNDRED
                      response_headers_to_add:
                        - append: false
                          header:
                            key: x-local-rate-limit
                            value: 'true'
                  - name: envoy.filters.http.router
                route_config:
                  name: local_route
                  virtual_hosts:
                    - name: local_service
                      domains: ["*"]
                      routes:
                        - match:
                            prefix: /stub1
                          route:
                            cluster: stub_cluster1
                            regex_rewrite:
                              pattern:
                                regex: ^/stub1[/]*(.*)$
                                google_re2: {}
                              substitution: /\1
                        - match:
                            prefix: /stub2
                          route:
                            cluster: stub_cluster2
                            regex_rewrite:
                              pattern:
                                regex: ^/stub2[/]*(.*)$
                                google_re2: {}
                              substitution: /\1
  clusters:
    - name: stub_cluster1
      connect_timeout: 0.25s
      type: STRICT_DNS
      load_assignment:
        cluster_name: stub_cluster1
        endpoints:
          - lb_endpoints:
              - endpoint: {address: {socket_address: {address: stub1 , port_value: 8080}}}
    - name: stub_cluster2
      connect_timeout: 0.25s
      type: STRICT_DNS
      load_assignment:
        cluster_name: stub_cluster2
        endpoints:
          - lb_endpoints:
              - endpoint: {address: {socket_address: {address: stub2 , port_value: 8081}}}
sunnoy commented 3 years ago

but i ger error log

[2021-04-06 08:46:40.764][1][warning][config] [source/common/config/filesystem_subscription_impl.cc:65] Filesystem config update failure: Unable to parse JSON as proto (INVALID_ARGUMENT:(http_filters[0].typed_config): invalid value Invalid type URL, unknown type: envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit for type Any): {"resources":[{"filter_chains":[{"filters":[{"typed_config":{"route_config":{"name":"nginx","virtual_hosts":[{"routes":[{"route":{"cluster":"nginx"},"match":{"prefix":"/"}}],"domains":["*"],"name":"nginx"}]},"codec_type":"AUTO","http_protocol_options":{"header_key_format":{"proper_case_words":{}}},"stat_prefix":"nginx","@type":"type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager","access_log":[{"typed_config":{"@type":"type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog","path":"/dev/stdout"},"name":"access-log"}],"http_filters":[{"typed_config":{"stat_prefix":"http_local_rate_limiter","token_bucket":{"max_tokens":3,"tokens_per_fill":1,"fill_interval":"1s"},"@type":"type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit"},"name":"envoy.filters.http.local_ratelimit"},{"name":"envoy.filters.http.router","typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"}}]},"name":"envoy.filters.network.http_connection_manager"}]}],"address":{"socket_address":{"address":"0.0.0.0","port_value":10000}},"@type":"type.googleapis.com/envoy.config.listener.v3.Listener","name":"listener_http_v4"}],"version_info":"1"}