如何从OPA服务器捕获所有请求日志
我正在使用开放策略代理( https://wwwww.openpolicyagent.org/docs.org/docs/latest/latest/ < /a>)。我正在Kubernetes中使用它。我正在进行各种用户流量。我有这样的容器日志:
{"client_addr":"[::1]:52362","level":"info","msg":"Received request.","req_body":"","req_id":21,"req_method":"GET","req_params":{},"req_path":"/v1/policies","time":"2022-04-26T15:39:57Z"}
{"client_addr":"[::1]:52362","level":"info","msg":"Sent response.","req_id":21,"req_method":"GET","req_path":"/v1/policies","resp_body":"","resp_bytes":28883,"resp_duration":4.901654,"resp_status":200,"time":"2022-04-26T15:39:57Z"}
我想使用这些日志进行监视,因为它们显示了响应状态请求详细信息,持续时间等。有人知道如何定期获取这些日志吗?我想将它们持续到我的数据库中。
我尝试了/指标端点: https://wwwwwww.openpolicyagent.org/docs/latest/latest/latest/监视/ 但这几乎没有细节,还不够富裕。
我还尝试了决策日志: https://www.openpolicyagent.org/docs/docs /最新/管理 - 决策/它们很好,但是它们没有涵盖对OPA的所有请求。
在我的用例中,我想填充Azure App Insights的请求数据库,
有没有办法捕获所有请求?
I'm using Open Policy Agent (https://www.openpolicyagent.org/docs/latest/). I'm using it in kubernetes. I have various user traffic going on. I have such container logs:
{"client_addr":"[::1]:52362","level":"info","msg":"Received request.","req_body":"","req_id":21,"req_method":"GET","req_params":{},"req_path":"/v1/policies","time":"2022-04-26T15:39:57Z"}
{"client_addr":"[::1]:52362","level":"info","msg":"Sent response.","req_id":21,"req_method":"GET","req_path":"/v1/policies","resp_body":"","resp_bytes":28883,"resp_duration":4.901654,"resp_status":200,"time":"2022-04-26T15:39:57Z"}
I would like to use these logs for monitoring, because they show response status request details, duration and so on. Does anyone has any idea how to get these logs on regular basis? I would like to persist them in my database.
I tried the /metrics endpoint: https://www.openpolicyagent.org/docs/latest/monitoring/
but it has little details, not rich enough for my need.
I also tried decision logs: https://www.openpolicyagent.org/docs/latest/management-decision-logs/ they are good, but they don't cover all the requests made to OPA.
In my use case, I would like to populate requests database of Azure App Insights
Is there a way to capture all the requests?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
决策记录与状态API 对于健康检查,人们通常是人们在生产系统中登录的内容。这应该涵盖您可能拥有的任何需求,因为OPA只要健康就可以做出决定,并且如果它不健康,则状态API将被用来报告。
您是否发现您缺少 /没有被决策记录仪记录的东西吗?
Decision logging for decisions together with the status API for health checks is generally what people log in production systems. This should cover pretty much any need you might have since OPA will produce decisions as long as its healthy, and if it isn't healthy the status API will be used to report that.
Was there anything in particular you found missing / not logged by the decision logger?
一种对我有用的方式:
A way that worked for me:
有效的方法:
由于OPA是一个Docker容器,它在Azure AKS资源中的Kubernetes中运行,这意味着将容器日志发送到containerLogs表,可以通过浏览来手动访问:Azure AKS Resources - &gt;日志
如何使用代码获取容器日志?请参阅下面的说明:
A way that worked:
Since OPA is a docker container, which runs in kubernetes in Azure AKS resource, this means, container logs are sent to ContainerLogs table, which could be accessed manually by going: Azure AKS resource -> Logs
How to get container logs with code? Please see explanation below: