Skip to content

bug: prometheus labels is inconsistent when using the same batch-processor in mutil logger plugins #6011

Description

@qizhendong1

Issue description

config: http-logger and error-log-logger at the same time will get a prometheus error.

2022/01/04 16:06:53 [error] 29080#29080: *11531 [lua] prometheus.lua:860: log_error(): inconsistent labels count, expected 3, got 1, context: ngx.timer
2022/01/04 16:06:53 [error] 29080#29080: *11531 [lua] prometheus.lua:860: log_error(): inconsistent labels count, expected 3, got 1, context: ngx.timer
2022/01/04 16:06:53 [error] 29080#29080: *11531 [lua] prometheus.lua:860: log_error(): inconsistent labels count, expected 3, got 1, context: ngx.timer
2022/01/04 16:06:53 [error] 29080#29080: *11531 [lua] prometheus.lua:860: log_error(): inconsistent labels count, expected 3, got 1, context: ngx.timer
2022/01/04 16:06:53 [error] 29080#29080: *11531 [lua] prometheus.lua:860: log_error(): inconsistent labels count, expected 3, got 1, context: ngx.timer

Environment

  • apisix version (cmd: apisix version): 2.10.1
  • OS (cmd: uname -a):
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V):
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API):
  • apisix-dashboard version, if have:
  • the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
  • luarocks version, if the issue is about installation (cmd: luarocks --version):

Steps to reproduce

curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/http-logger -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
      "log_format": {
        "request": "$request",
        "http_user_agent": "$http_user_agent",
        "upstream_header_time": "$upstream_header_time",
        "upstream_connect_time": "$upstream_connect_time",
        "content_length": "$content_length"
      }
}'
curl http://127.0.0.1:9080/apisix/admin/global_rules/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"plugins": {
            "http-logger": {
              "max_retry_count": 0,
              "timeout": 3,
              "retry_delay": 1,
              "batch_max_size": 2,
              "auth_header": "",
              "use_tcp_transmission": true,
              "inactive_timeout": 5,
              "uri": "http://100.76.0.76:15151",
              "include_req_body": false,
              "name": "http logger",
              "concat_method": "new_line",
              "send_prometheus_data": false,
              "buffer_duration": 60
            }
        }
}'
curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/error-log-logger -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
  "tcp": {
    "host": "100.76.0.76",
    "port": 15151
  },
  "inactive_timeout": 1,
  "batch_max_size": 10,
  "level": "WARN"
}'

Actual result

image

Error log

image

Expected result

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions