Tyk-pump missing metrics/ wrong reporting

Hi there,

  1. Why am not getting the latency metrics in the /metrics.
  2. I did put in place a 500 endpoint in my api, the tyk-pump doesn’t look like it is reporting any errors ( the 500 error)
  3. how to get the 400 errors to show in the /metrics ?

I did add this to my tyk-pump configuration :

  "pumps": {
    "prometheus": {
      "type": "prometheus",
      "meta": {
        "path": "/metrics",
        "listen_address": ":9090",
        "custom_metrics": [
          {
            "name": "tyk_http_requests_total",
            "description": "Total of API requests",
            "metric_type": "counter",
            "labels": [
              "response_code",
              "api_name",
              "method",
              "api_key",
              "alias",
              "path"
            ]
          },
          {
            "name": "tyk_http_latency",
            "description": "Latency of API requests",
            "metric_type": "histogram",
            "labels": [
              "type",
              "response_code",
              "api_name",
              "method",
              "api_key",
              "alias",
              "path"
            ]
          }
        ]
      }
    }
  },

but in the /metrics endpoint I’m only getting the total metrics :

# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 241
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0

the version I’m using is 1.8.3 for tyk-pump ( sept 2023)

So when I remove the custom_metrics section I get the in_flight metric appearing …

# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1. <-------
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 29
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0

I don’t see anything wrong with your config.

Could you try exposing a different port for pump and using that as the listen address?

In my case, I used 8091

time="Feb 07 12:11:42" level=info msg="Starting prometheus listener on::8091" prefix=prometheus-pump

Then make your requests and check the metrics ...8091/metrics endpoint to confirm if you can see the missing metrics. If you can then configure your scrape settings on Prometheus. (this is how I have set mine)

Let us know how it goes.