Hello Folks,
Is there anyone using Prometheus with Tyk Gateway?
I can’t make it work and I see differences when I use strip_list_path true or false, which are not clear is they are related or not.
when “strip_listen_path”: true, here’s the logs. I cannot find a way to match the proxy path because it understands “/prometheus” as the api endpoint, but not the path.
This part of the log that I’m talking about:
time=“Feb 24 16:43:54” level=debug msg=“Stripping: /prometheus/”
time=“Feb 24 16:43:54” level=debug msg="Upstream Path is: "
When the strip_listen_path is true, I cannot pick up what is after the host because it’s cleaned up by the logic. In that way, looks like API Endpoint and “path” are two different things.
I need to be access to access tyk_host/prometheus and make sure it will be forwarded to the target host:9090/ (which will then be redirected by prometheus to :9090/graph)
time="Feb 24 16:43:54" level=debug msg=Finished api_id=9 api_name=Prometheus code=200 key="****OCJ9" mw=URLRewriteMiddleware ns=15265 org_id=1 origin=11.240.20.15 path="/prometheus/"
time="Feb 24 16:43:54" level=debug msg="Started proxy"
time="Feb 24 16:43:54" level=debug msg="Stripping: /prometheus/"
time="Feb 24 16:43:54" level=debug msg="Upstream Path is: "
time="Feb 24 16:43:54" level=debug msg=Started api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1 ts=1677257034568844370
time="Feb 24 16:43:54" level=debug msg="Upstream request URL: " api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1
time="Feb 24 16:43:54" level=debug msg="Outbound request URL: http://monitoring-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090" api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1
time="Feb 24 16:43:54" level=debug msg="Creating new transport" api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1
time="Feb 24 16:43:54" level=debug msg="Out request url: http://monitoring-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090" api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1
time="Feb 24 16:43:54" level=debug msg=Finished api_id=9 api_name=Prometheus mw=ReverseProxy ns=54447322 org_id=1
time="Feb 24 16:43:54" level=debug msg="Upstream request took (ms): 54.487376"
time="Feb 24 16:43:54" level=debug msg="Done proxy"
When “strip_listen_path”: false, then I can match the regex and the subpath, but it always append the /prometheus in the target proxy server.
time="Feb 24 16:48:00" level=debug msg="Started proxy"
time="Feb 24 16:48:00" level=debug msg=Started api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1 ts=1677257280569841655
time="Feb 24 16:48:00" level=debug msg="Upstream request URL: /prometheus/" api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1
time="Feb 24 16:48:00" level=debug msg="Outbound request URL: http://monitoring-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090/prometheus/" api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1
time="Feb 24 16:48:00" level=debug msg="Creating new transport" api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1
time="Feb 24 16:48:00" level=debug msg="Out request url: http://monitoring-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090/prometheus/" api_id=9 api_name=Prometheus mw=ReverseProxy org_id=1
time="Feb 24 16:48:00" level=debug msg=Finished api_id=9 api_name=Prometheus mw=ReverseProxy ns=46466011 org_id=1
time="Feb 24 16:48:00" level=debug msg="Upstream request took (ms): 46.599425"
Prometheus API Definition:
{
"name": "Prometheus",
"slug": "prometheus",
"api_id": "9",
"org_id": "1",
"use_basic_auth": true,
"use_keyless": false,
"auth": {
"auth_header_name": "Authorization"
},
"definition": {
"location": "header",
"key": "x-api-version"
},
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "v1",
"use_extended_paths": true,
"extended_paths": {
"url_rewrites": [
{
"path": "/graph",
"method": "GET",
"match_pattern": "(.*)",
"rewrite_to": "/prometheus/graph"
}
]
},
"global_headers": {},
"global_headers_remove": [],
"global_size_limit": 0,
"override_target": ""
}
}
},
"proxy": {
"listen_path": "/prometheus/",
"target_url": "http://monitoring-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090/",
"strip_listen_path": true,
"disable_strip_slash": false
},
"active": true
}
Thanks for any help!!
-Daniel