mimir icon indicating copy to clipboard operation
mimir copied to clipboard

mimirtool load rules not working with api.prometheus_http_prefix different than /prometheus

Open Nachtfalkeaw opened this issue 9 months ago • 1 comments

Describe the bug

mimirtool 2.12 ./mimirtool rules load rules.yml will not work if the mimir "prometheus_http_prefix:" is changed from "/prometheus" to "/"

Working:

api:
    prometheus_http_prefix: /prometheus

Not working

api:
    prometheus_http_prefix: /

It looks like the "POST Request" is wrong if the "--use-legacy-routes" parameter is used compared to "--no-use-legacy-routes"

WRONG POST request:

root@ubiquiti:/opt/mimir# ./mimirtool rules load ./rules.yml --address="http://192.168.178.51:9009" --id=anonymous --tls-insecure-skip-verify --use-legacy-routes --log.level="debug"
INFO[0000] log level set to debug
group: 'mimir_api_1', ns: 'rules'
/api/v1/rules/rules/mimir_api_1
DEBU[0000] sending request to Grafana Mimir API          method=GET url="http://192.168.178.51:9009/api/v1/rules/rules/mimir_api_1"
DEBU[0000] checking response                             status="404 Not Found"
DEBU[0000] response                                      body="404 page not found\n" status="404 Not Found"
DEBU[0000] sending request to Grafana Mimir API          method=POST url="http://192.168.178.51:9009/api/v1/rules/rules"
DEBU[0000] checking response                             status="404 Not Found"
DEBU[0000] response                                      body="404 page not found\n" status="404 Not Found"
ERRO[0000] unable to load rule group                     error="POST request to http://192.168.178.51:9009/api/v1/rules/rules failed: requested resource not found" group=mimir_api_1 namespace=rules
mimirtool: error: load operation unsuccessful, try --help
root@ubiquiti:/opt/mimir#

error="POST request to http://192.168.178.51:9009**/api/v1/rules/rules** failed

CORRECT Post request:

root@ubiquiti:/opt/mimir# ./mimirtool rules load ./rules.yml --address="http://192.168.178.51:9009" --id=anonymous --tls-insecure-skip-verify --no-use-legacy-routes --log.level="debug"
INFO[0001] log level set to debug
group: 'mimir_api_1', ns: 'rules'
/prometheus/config/v1/rules/rules/mimir_api_1
DEBU[0001] sending request to Grafana Mimir API          method=GET url="http://192.168.178.51:9009/prometheus/config/v1/rules/rules/mimir_api_1"
DEBU[0001] checking response                             status="404 Not Found"
DEBU[0001] response                                      body="group does not exist\n" status="404 Not Found"
DEBU[0001] sending request to Grafana Mimir API          method=POST url="http://192.168.178.51:9009/prometheus/config/v1/rules/rules"
DEBU[0001] checking response                             status="202 Accepted"

method=POST url="http://192.168.178.51:9009/prometheus**/config/v1/rules/rules**" DEBU[0001] checking response status="202 Accepted"

To Reproduce

api:
    prometheus_http_prefix: /

./mimirtool rules load ./rules.yml --address="http://192.168.178.51:9009" --id=anonymous --tls-insecure-skip-verify --use-legacy-routes --log.level="debug"

Expected behavior

It should be possible to use mimirtool to load ules with differnet prometheus_http_prefixes.

Environment

  • Infrastructure: bare-metal
  • 2.12
  • mimirtool-amd64

Nachtfalkeaw avatar Apr 30 '24 19:04 Nachtfalkeaw

I'm not sure how legacy rules are related here. But I agree that mimirtool does not work with Mimir if Mimir is deployed with a non-default value for prometheus_http_prefix or alertmanager_http_prefix. Perhaps a command line flag next to --use-legacy-routes would help: --mimir-http-prefix defaulting to /prometheus. I believe it will be used here

dimitarvdimitrov avatar May 03 '24 17:05 dimitarvdimitrov