访问日志

配置项

  1. {
  2. "access_log": [
  3. {
  4. "path": "...",
  5. "format": "...",
  6. "filter": "{...}",
  7. },
  8. ]
  9. }
  • path
    (required, string) 写入访问日志的路径。

  • format
    (optional, string) 访问日志格式。Envoy支持自定义访问日志格式以及默认格式

  • filter
    (optional, object) 用于明确是否需要写入的访问日志过滤器。

过滤器

Envoy支持以下访问日志过滤器:

Status code

  1. {
  2. "filter": {
  3. "type": "status_code",
  4. "op": "...",
  5. "value": "...",
  6. "runtime_key": "..."
  7. }
  8. }

基于HTTP响应/状态代码的过滤器。

  • op
    (required, string) 比较运算符。目前仅支持>==运算符。

  • value
    (required, integer) 如果运行时值不可用,则使用默认值进行比较。

  • runtime_key
    (optional, string) 运行时的key,用于获取比较值。如果定义,则使用此值。

Duration

  1. {
  2. "filter": {
  3. "type": "duration",
  4. "op": "..",
  5. "value": "...",
  6. "runtime_key": "..."
  7. }
  8. }

请求持续的总时间过滤器,以毫秒为单位。

  • op
    (required, string) 比较运算符。目前仅支持>==运算符。

  • value
    (required, integer) 如果运行时值不可用,则使用默认值进行比较。

  • runtime_key
    (optional, string) 运行时的key,用于获取比较值。如果定义,则使用此值。

Not health check

  1. {
  2. "filter": {
  3. "type": "not_healthcheck"
  4. }
  5. }

筛选健康检查失败的请求。健康检查的请求由健康检查过滤器进行标记。

Traceable

  1. {
  2. "filter": {
  3. "type": "traceable_request"
  4. }
  5. }

筛选可跟踪的请求。请参阅跟踪概述,以获取有关请求如何使能跟踪的详细信息。

Runtime

  1. {
  2. "filter": {
  3. "type": "runtime",
  4. "key" : "..."
  5. }
  6. }

使用随机采样请求。在x-request-id头存在的情况下进行采样。如果存在x-request-id,则过滤器将根据运行时键值和从x-request-id提取的值在多个主机上持续采样。如果缺失,过滤器将根据运行时键值随机采样。

  • key
    (required, string) 通过运行时key获取要采样的请求的百分比。此运行时值控制在0-100范围内,默认为0。

And

  1. {
  2. "filter": {
  3. "type": "logical_and",
  4. "filters": []
  5. }
  6. }

对过滤器中每个过滤器的结果执行逻辑”和”运算。过滤器将按顺序进行评估,如果其中一个返回false,则过滤器立即返回false。

Or

  1. {
  2. "filter": {
  3. "type": "logical_or",
  4. "filters": []
  5. }
  6. }

对每个单独的过滤器的结果执行逻辑”或”操作。过滤器将按顺序进行评估,如果其中一个返回true,则过滤器会立即返回true。

返回