Hi Zuochen,

May I know if your issues are resolved after the last discussion?

Also, here is the update for the issues above. (For users who're interested
on this mail :))

1.
- Q: Why log_format is not working?
- A: According to the kafka-logger's plugin doc[1], we need to use
"/apisix/admin/plugin_metadata/kafka-logger" instead of
"/apisix/admin/routes" to configure that parameter.

2.
- Q: How to limit Consumers dynamically?
- A: Please have a check at the consumer-restriction plugin[2], it allows
which consumers are allowed or disallowed to access target routes.

By the way, welcome to share your best practices when using Apache APISIX!

[1] https://apisix.apache.org/docs/apisix/plugins/kafka-logger/#metadata
[2] https://apisix.apache.org/docs/apisix/plugins/consumer-restriction

Best Regards!
@ Zhiyuan Ju <https://github.com/juzhiyuan>


Zhiyuan Ju <juzhiy...@apache.org> 于2021年12月15日周三 22:26写道:

> Hi Zuochen,
>
> Glad to see that you're using the Apache Way to seek help from Apache
> APISIX Community :)
>
> Because of the limitations of the mailing list, we couldn't see your
> images (I mean the screenshot of the log in your mail). Could you please
> paste your logs in text here?
>
> Best Regards!
> @ Zhiyuan Ju <https://github.com/juzhiyuan>
>
>
> Li.Zuochen.MS <zuochen.li...@faw-vw.com> 于2021年12月15日周三 22:16写道:
>
>> APISIX 老师,你好
>>
>> APISIX真的是很出色的网关组件,我们正在尝试使用,感谢你们。
>>
>> 我遇到如下问题,使用kafka-logger插件,已经输出日志到kafka,但是想补获更多日志细节,包括网关的response、调用
>> upstream的请求和返回、时间的格式化。
>>
>> 我现在的配置如下:
>>
>> {
>>
>>   "uri": "/uploadVIPOrder",
>>
>>   "name": "EStore2Spres-VIPOrder",
>>
>>   "priority": 1,
>>
>>   "methods": [
>>
>>     "POST"
>>
>>   ],
>>
>>   "plugins": {
>>
>>     "kafka-logger": {
>>
>>       "batch_max_size": 1,
>>
>>       "broker_list": {
>>
>>         "10.92.0.43": 9092,
>>
>>         "10.92.0.47": 9092,
>>
>>         "10.92.0.48": 9092
>>
>>       },
>>
>>       "disable": false,
>>
>>       "inactive_timeout": 10,
>>
>>       "include_req_body": true,
>>
>>       "kafka_topic": "otd-apigateway",
>>
>>       *"log_format"**: {   //**格式化时间、实际客户端**ip**,但是时间一直都是时间戳*
>>
>>         *"client_ip"**: **"$realip_remote_addr"**,*
>>
>>         *"host"**: **"$host"**,*
>>
>>         *"timestamp"**: **"$time_iso8601"**,*
>>
>>         *"upstream_response_time"**: **"$upstream_response_time"*
>>
>> *      },*
>>
>>       "meta_format": "default",
>>
>>       "name": "EStore2Spres-VIPOrder",
>>
>>       "producer_type": "async",
>>
>>       "required_acks": 0
>>
>>     },
>>
>>     "key-auth": {
>>
>>       "disable": false
>>
>>     },
>>
>>     "proxy-rewrite": {
>>
>>       "headers": {
>>
>>         "proxy_pass": XXXX
>>
>>       },
>>
>>       "host": "XXX",
>>
>>       "uri": "/serviceProxy/spres/unauthorized/getCustomerDate"
>>
>>     }
>>
>>   },
>>
>>   "upstream_id": "384757350679970594",
>>
>>   "labels": {
>>
>>     "API_VERSION": "v1",
>>
>>     "desc": "XXX",
>>
>>     "env": "test"
>>
>>   },
>>
>>   "status": 1
>>
>> }
>>
>>
>>
>> 返回的日志如下:
>>
>>
>>
>> 详细的日志如下:
>>
>>
>>
>> {
>>
>>   "latency": 161.99994087219,
>>
>>   "server": {
>>
>>     "hostname": "otd-nomp-mvp-07",
>>
>>     "version": "2.10.1"
>>
>>   },
>>
>>   "response": {
>>
>>     "status": 200,
>>
>>     "size": 240,
>>
>>     "headers": {
>>
>>       "x-request-id": "399b8e6e-dad5-4dcf-8539-dacb844ce915",
>>
>>       "server": "APISIX/2.10.1",
>>
>>       "content-type": "text/plain;charset\u003dUTF-8",
>>
>>       "content-length": "27",
>>
>>       "date": "Wed, 15 Dec 2021 06:09:12 GMT",
>>
>>       "connection": "close"
>>
>>    }
>>
>>   },
>>
>>   "client_ip": "10.228.1.132",
>>
>>   "route_id": "384757896711242530",
>>
>>   "upstream": "XXX",
>>
>>   "start_time": 1639548552809,
>>
>>   "consumer": {
>>
>>     "update_time": 1639011748,
>>
>>     "username": "auth_key_consumer",
>>
>>     "id": "auth_key_consumer",
>>
>>     "create_time": 1638886374,
>>
>>     "auth_conf": {
>>
>>       "disable": false,
>>
>>       "key": "XX"
>>
>>     },
>>
>>     "consumer_name": "auth_key_consumer",
>>
>>     "plugins": {
>>
>>       "key-auth": {
>>
>>         "disable": false,
>>
>>         "key": "XXX"
>>
>>       }
>>
>>     }
>>
>>   },
>>
>>   "request": {
>>
>>     "uri": "/uploadVIPOrder",
>>
>>     "url": XXXX,
>>
>>     "body": "{\r\n    \"salesOrderType\": \"留学生\",\r\n    \"tradeCode\":
>> \"DLXS\",\r\n    \"createTime\": \"2021-10-22 13:54:40\"\r\n}",
>>
>>     "headers": {
>>
>>       "accept": "*/*",
>>
>>       "content-type": "application/json",
>>
>>       "cache-control": "no-cache",
>>
>>       "postman-token": "0eb02c62-3305-4d58-b4c8-a59ad2f2a891",
>>
>>       "host": "XXX",
>>
>>       "accept-encoding": "gzip, deflate, br",
>>
>>       "x-request-id": "399b8e6e-dad5-4dcf-8539-dacb844ce915",
>>
>>       "apikey": "XXX",
>>
>>       "connection": "keep-alive",
>>
>>       "proxy_pass":XXXX,
>>
>>       "content-length": "984",
>>
>>       "user-agent": "PostmanRuntime/7.28.4"
>>
>>     },
>>
>>     "size": 1328,
>>
>>     "querystring": {},
>>
>>     "method": "POST"
>>
>>   },
>>
>>   "service_id": ""
>>
>> }
>>
>> *感谢!*
>>
>> __________________________________________________________________
>>
>> [image: 2019版全称标识(80%)]
>>
>> *李佐臣 / Li ZuoChen*
>>
>> *管理服务部  Management Service Department*
>>
>> *互联应用开发科 数字化研发组(长春)/P-MS-4-/2*
>>
>> *电话:0431-85780470【678470】*
>>
>> *移动电话: 13804310607*
>>
>> *邮箱 E-mail: zuochen.li...@faw-vw.com <zuochen.li...@faw-vw.com>*
>>
>>
>>
>

Reply via email to