愚者求师之过,智者从师之长。

极限网关指定request_path_limiter后,不再返回信息

开源项目 | 作者 yeziblo | 发布于2021年10月26日 | 阅读数:1514

根据medcl大大的说明文档手动配置一个yml文件,如下所示:
path.data: data
path.logs: log

entry:
- name: test_entry
enabled: true
router: default
max_concurrency: 20000
network:
binding: 0.0.0.0:8000

router:
- name: default
tracing_flow: request_logging
default_flow: rate_limit_flow

flow:
- name: request_logging
filter:
- request_path_filter:
must_not: # any match will be filtered
prefix:
- /favicon.ico
- request_header_filter:
exclude:
- app: kibana
- logging:
queue_name: request_logging
- name: cache_first
filter:
- get_cache:
- elasticsearch:
elasticsearch: test_cluster
- set_cache:
- name: rate_limit_flow
filter:
- echo:
message: "hello gateway\n"
repeat: 3
- request_path_limiter:
message: "Hey, You just reached our request limit!"
rules:
- pattern: "/(?P<index_name>test202110)/_search"
max_qps: 1
group: index_name
- pattern: "/(?P<index_name>.*?)/_search"
max_qps: 100
group: index_name
- elasticsearch:
elasticsearch: test_cluster

pipeline:
- name: request_logging_index
processor:
- json_indexing:
index_name: "gateway_requests"
elasticsearch: "test_cluster"
input_queue: "request_logging"
idle_timeout_in_seconds: 1
worker_size: 1
bulk_size_in_mb: 10 #in MB

elasticsearch:
- name: test_cluster
enabled: true
endpoints: localhost:9200
discovery:
enabled: true
refresh:
enabled: true
之后启动gateway,这时候一切正常,但是一旦执行命令访问8000端口就什么都不会返回:
curl: (52) Empty reply from server
之后尝试更换default_flow为cache_first,一切正常。
所以是否是我的配置仍有问题,有没有兄弟们知道的,诚心求助。
已邀请:

medcl - 今晚打老虎。

赞同来自:

嗯,被你发现 bug 了,最近重构引起的一个空引用,已经 fix 了,下载最新的 1.5-418 快照就行了。
http://release.elasticsearch.cn/gateway/snapshot/
另外你上面的配置也有点小问题,endpoint 需要填完整的地址,host 则不需要,完整的配置如下:
 
path.data: data
path.logs: log

entry:
- name: test_entry
enabled: true
router: default
max_concurrency: 20000
network:
binding: 0.0.0.0:8000

router:
- name: default
tracing_flow: request_logging
default_flow: rate_limit_flow

flow:
- name: request_logging
filter:
- request_path_filter:
must_not: # any match will be filtered
prefix:
- /favicon.ico
- request_header_filter:
exclude:
- app: kibana
- logging:
queue_name: request_logging
- name: cache_first
filter:
- get_cache:
- elasticsearch:
elasticsearch: test_cluster
- set_cache:
- name: rate_limit_flow
filter:
- request_host_limiter:
action: drop
max_requests: 1
host:
- api.elasticsearch.cn:8000
- logging.elasticsearch.cn
- request_api_key_filter:
message: "API KEY filtered!"
exclude:
- VuaCfGcBCdbkQm-e5aOx
- request_path_limiter:
message: "Hey, You just reached our request limit!"
rules:
- pattern: "/(?P<index_name>medcl)/_search"
max_qps: 1
group: index_name
- pattern: "/(?P<index_name>.*?)/_search"
max_qps: 100
group: index_name
- elasticsearch:
elasticsearch: test_cluster

pipeline:
- name: request_logging_index
processor:
- json_indexing:
index_name: "gateway_requests"
elasticsearch: "test_cluster"
input_queue: "request_logging"
idle_timeout_in_seconds: 1
worker_size: 1
bulk_size_in_mb: 10 #in MB

elasticsearch:
- name: test_cluster
enabled: true
endpoints:
- http://localhost:9200
discovery:
enabled: true
refresh:
enabled: true

要回复问题请先登录注册