Yeah it occurs when I access the metrics endpoint. (only at port 9542 not the admin port)
servers.conf:
# Prometheus metrics server
server {
server_name kong_prometheus_exporter;
listen 0.0.0.0:9542; # can be any other port as well
access_log off;
location /metrics {
default_type text/plain;
content_by_lua_block {
local prometheus = require "kong.plugins.prometheus.exporter"
prometheus:collect()
}
}
location /nginx_status {
internal;
access_log off;
stub_status;
}
}
# Health check server
# TODO how to health check kong in dbless?
server {
server_name kong_health_check;
listen 0.0.0.0:9001; # can be any other port as well
access_log off;
location /health {
return 200;
}
}
/plugins:
{
"next": null,
"data": [
{
"created_at": 1565895104,
"config": {},
"id": "86e6f637-64e2-5672-920c-32e17e76e0fe",
"service": null,
"enabled": true,
"tags": null,
"consumer": null,
"run_on": "first",
"name": "prometheus",
"route": null,
"protocols": [
"grpc",
"grpcs",
"http",
"https"
]
}
]
}
admin/metrics:
{
"message": "An unexpected error occurred"
}
server/metrics:
<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>openresty/1.15.8.1</center>
</body>
</html>
/etc/kong/kong.conf
nginx_http_include = /kong/servers.conf
kong/logs/error.log:
2019/08/15 21:12:12 [error] 33#0: *209376 [kong] exporter.lua:88 prometheus: plugin is not initialized, please make sure 'prometheus_metrics' shared dict is present in nginx template, client: 127.0.0.1, server: kong_prometheus_exporter, request: "GET /metrics HTTP/1.1", host: "localhost:9542"
2019/08/15 21:12:12 [error] 33#0: *209376 lua entry thread aborted: runtime error: /usr/local/share/lua/5.1/kong/pdk/private/phases.lua:66: no phase in kong.ctx.core.phase
stack traceback:
coroutine 0:
[C]: in function 'error'
/usr/local/share/lua/5.1/kong/pdk/private/phases.lua:66: in function 'check_phase'
/usr/local/share/lua/5.1/kong/pdk/response.lua:662: in function 'collect'
content_by_lua(servers.conf:12):3: in main chunk, client: 127.0.0.1, server: kong_prometheus_exporter, request: "GET /metrics HTTP/1.1", host: "localhost:9542"