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

Kong prometheus plugin does not record 404 response codes from proxy #12976

Open
1 task done
surenraju-careem opened this issue May 2, 2024 · 2 comments
Open
1 task done
Labels
pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... plugins/prometheus stale

Comments

@surenraju-careem
Copy link

surenraju-careem commented May 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

3.6.1

Current Behavior

When we enable the Prometheus plugin globally, and the proxy returns 404 response codes, the Prometheus plugin does not log the 404 status codes.

This gives us no way to monitor for 404 errors that could be caused by scenarios such as invalid configurations pushed to Kong, resulting in the Kong proxy rejecting all requests.

Expected Behavior

Prometheus metric endpoint records 404 response codes

Steps To Reproduce

Declarative config(declarative/kong.yaml):

_transform: true

services:
  - host: httpbin.org
    name: test-service
    port: 443
    protocol: https
    routes:
      - name: get-route
        paths:
          - /get
        strip_path: false
      - name: post-route
        paths:
          - /post
        methods:
          - POST
        strip_path: false
  - host: api.chucknorris.io
    name: jokes-service
    port: 443
    protocol: https
    routes:
      - name: jokes
        paths:
          - /jokes/random
        strip_path: false
plugins:
  - name: prometheus
    config:
      status_code_metrics: true
      latency_metrics: true
      bandwidth_metrics: true
      upstream_health_metrics: true

Docker Compose:


networks:
  kong-net:
    external: false

services:
  kong:
    image: docker.io/library/kong:3.3.1-ubuntu
    environment:
      KONG_NGINX_WORKER_PROCESSES: 1
      KONG_LOG_LEVEL: "debug"
      KONG_DATABASE: "off"
      KONG_DECLARATIVE_CONFIG: /kong/declarative/kong.yml
      KONG_PROXY_ACCESS_LOG: /dev/stdout
      KONG_ADMIN_ACCESS_LOG: /dev/stdout
      KONG_PROXY_ERROR_LOG: /dev/stderr
      KONG_ADMIN_ERROR_LOG: /dev/stderr
      KONG_ADMIN_LISTEN: 0.0.0.0:8001
      KONG_ADMIN_GUI_URL: http://localhost:8002
      KONG_LICENSE_DATA: ""
      KONG_PLUGINS: bundled
    networks:
      - kong-net
    ports:
      - 8000:8000
      - 8443:8443
      - 8001:8001
      - 8444:8444
      - 8002:8002
      - 8445:8445
      - 8003:8003
      - 8004:8004
    volumes:
      - ./declarative:/kong/declarative/

Generate some random traffic http://localhost:8000/random that makes kong return 404, the hit http://localhost:8001/metrics, you will see no 404 reported by prometheus plugin.

@samugi
Copy link
Contributor

samugi commented May 7, 2024

hello @surenraju-careem , thank you for opening this issue.

I believe the behavior you describe is expected, some metrics are intentionally not incremented when no route/service is matched, including the http_requests_total, which are intended to count requests by status code "returned by upstream services" as documented.

Changing this behavior would be considered a feature, which we may consider for implementation based on demand and availability. If you would like to open a pull request to support this we would be more than happy to review it.

Let me know if you have any doubts, thank you!

@samugi samugi added the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label May 7, 2024
Copy link
Contributor

This issue is marked as stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... plugins/prometheus stale
Projects
None yet
Development

No branches or pull requests

3 participants