knyar / nginx-lua-prometheus

Prometheus metric library for Nginx written in Lua
MIT License
1.46k stars 231 forks source link

Incompatibility with ubuntu 16.04/nginx-extras #104

Closed brandune closed 4 years ago

brandune commented 4 years ago

I think I've found an incompatibility using the nginx-extras package from ubuntu xenial/16.04 due to the version of the LUA module it was built with.

I do not expect a change from this project to fix the problem, but I'm inexperienced with LUA and C so I hope someone else can confirm what I found. If so, maybe it's worth a note in the README troubleshooting section.

Using the following versions:

Using the init_worker block from this project's README, this error is logged on nginx startup:

2020/08/12 17:49:12 [error] 23560#23560: init_worker_by_lua error: /opt/nginx_lua/prometheus_keys.lua:90: expecting 3 arguments, but only seen 4
stack traceback:
        [C]: in function 'incr'
        /opt/nginx_lua/prometheus_keys.lua:90: in function 'add'
        /opt/nginx_lua/prometheus.lua:528: in function 'init'
        init_worker_by_lua:2: in main chunk
/opt/nginx_lua/prometheus_keys.lua:90:         self.dict:incr(self.key_count, 1, 0)

That call to incr is using the optional init parameter which was only added to nginx-lua-module in v0.10.6 - https://github.com/openresty/lua-nginx-module#ngxshareddictincr, so the version embedded in the nginx-extras package is too old to support this call.

At the cost of downgrading, using this project's 0.20181120 release seems to work without error.

dolik-rce commented 4 years ago

Hi @brandune,

Your understanding of the problem is correct. I'm afraid you'll need to upgrade your nginx, if you need it to work with this module. You can try too look in PPAs or some other repositories...

Note that there is an open issue #98, which should help a bit by at least showing a clear error message.

brandune commented 4 years ago

Thanks for the quick confirmation @dolik-rce, I'll close this since there isn't much to do. Adding that error message is definitely better than enumerating incompatibilities in the README.