Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request help: logger plugins supports report custom labels of route #5998

Closed
jagerzhang opened this issue Jan 4, 2022 · 6 comments
Closed
Labels
good first issue Good for newcomers

Comments

@jagerzhang
Copy link
Contributor

jagerzhang commented Jan 4, 2022

Issue description

如图,为了方便管理,我们这边会给每个路由自定义系统和应用的标签。希望各日志插件能将这个标签也记录一下,方便在日志分析时和业务做快捷的对应。
image

目前在用 kafka-logger ,望优先支持~~感谢。

Environment

  • apisix version (cmd: apisix version): 2.11.0
  • OS (cmd: uname -a): docker-centos
@tzssangglass
Copy link
Member

useful

@tzssangglass tzssangglass added the good first issue Good for newcomers label Jan 4, 2022
@spacewander
Copy link
Member

Solved by #5941

@tzssangglass
Copy link
Member

#5941 just privode register_var function, not implemented in the logger plugin code?

@jagerzhang
Copy link
Contributor Author

jagerzhang commented Jan 20, 2022

#5941 just privode register_var function, not implemented in the logger plugin code?
@tzssangglass @spacewander
确实没有在日志插件中实现,我参考这个写法,在kafka-logger试了下,发现ctx.matched_route.value里面并没有labels相关内容,代码如下:

    local route = ctx.matched_route and ctx.matched_route.value
    core.log.info("route.value: ", core.json.delay_encode(route))  # 这里输出我看了下,里面是没有路由自定义标签。
    if route and route.labels then
        entry.route = {}
        entry.route.labels = route.labels
    end

输出内容:
image

@spacewander
Copy link
Member

I demonstrate how to use it in #6163

@jagerzhang
Copy link
Contributor Author

I demonstrate how to use it in #6163

嗯,当我改造kafka-logger的时候,发现了一个bug,已提issue: #6169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants