apisix icon indicating copy to clipboard operation
apisix copied to clipboard

feat: add additional handling of prometheus-cache in ngx_tpl.lua

Open qihaiyan opened this issue 3 months ago • 4 comments

Description

{% if enabled_plugins["prometheus"] and not enabled_stream_plugins["prometheus"] then %}
    lua_shared_dict prometheus-metrics {* http.lua_shared_dict["prometheus-metrics"] *};
    -- add prometheus-cache here
    lua_shared_dict prometheus-cache {* http.lua_shared_dict["prometheus-cache"] *};
{% end  #%}

Maybe it's better to set prometheus-cache together with prometheus-metrics in ngx_tpl.lua

qihaiyan avatar Oct 27 '25 08:10 qihaiyan

Do you think there are any problems with the current approach?

Baoyuantop avatar Oct 28 '25 02:10 Baoyuantop

Do you think there are any problems with the current approach?

Only when use_apisix_base is set to true, will the prometheus-cache take effect. But in order to integrate with QAT, i used a custom built openresty instead of apisix-runtime, so use_apisix_base is not true, and prometheus-cache is not setted in nginx.conf even if prometheus plugin is enabled. @Baoyuantop

qihaiyan avatar Oct 28 '25 02:10 qihaiyan

Got it, welcome to submit PR to optimize this part.

Baoyuantop avatar Oct 28 '25 03:10 Baoyuantop

Hi @SkyeYoung, could you help confirm this issue?

Baoyuantop avatar Oct 31 '25 02:10 Baoyuantop

Hi @qihaiyan, thanks for your contribution.

After review, we believe this change is primarily intended to support a specific custom OpenResty build environment (the QAT integration scenario you mentioned). To maintain the simplicity and generality of the core template, we prefer not to merge changes tailored for specific non-standard environments into the master branch.

We recommend applying this change as a patch during your custom build process, or trying to inject the configuration via nginx_config in config.yaml.

Looking forward to hearing more opinions.

Baoyuantop avatar Dec 19 '25 07:12 Baoyuantop

Hi @qihaiyan, thanks for your contribution.

After review, we believe this change is primarily intended to support a specific custom OpenResty build environment (the QAT integration scenario you mentioned). To maintain the simplicity and generality of the core template, we prefer not to merge changes tailored for specific non-standard environments into the master branch.

We recommend applying this change as a patch during your custom build process, or trying to inject the configuration via nginx_config in config.yaml.

Looking forward to hearing more opinions.

ok, agree with it.

qihaiyan avatar Dec 19 '25 08:12 qihaiyan