pyrra
pyrra copied to clipboard
Add generate command
Fixes #314
Just took a quick try into 314... Fixes the issue but I basically copied code from filesystem.go
, so I believe the code can still be improved to reduce duplicated codeπ
Opening the PR early just in case you were imagining something different here π
Alrighty, refactored a bit to avoid duplicated code. Should be ready for review π
It would appear to me that the change in its current form does not parse multiple objects per yaml (like the examples/nginx.yaml
has). Is that a bug?
Also, any chance for some forward movement on this PR?
It would appear to me that the change in its current form does not parse multiple objects per yaml (like the
examples/nginx.yaml
has). Is that a bug?Also, any chance for some forward movement on this PR?
ah, interesting, I didn't notice this multiple objects per yaml problem. I'll try to take a look at it this week! Tips on how to solve are appreciated π
That was definitely a bug in the examples/nginx.yaml
:sweat_smile:
It's fixed now, thanks to @mmazur :tada:
That was definitely a bug in the
examples/nginx.yaml
π It's fixed now, thanks to @mmazur π
Nice! Thanks for solving this one π₯³
I'm stuck at another problem now, but seems like this problem also exists on main
.
I'm trying to run those commands, and both fail with the same error:
gitpod /workspace/pyrra (main) $ ./pyrra filesystem --config-files examples/*.yaml
pyrra: error: unexpected argument examples/prometheus-http.yaml
gitpod /workspace/pyrra (main) $ ./pyrra generate --config-files examples/*.yaml
pyrra: error: unexpected argument examples/prometheus-http.yaml
But if I use a direct path to a single file, it works as expected (only permission issues with the output folder):
gitpod /workspace/pyrra (main) $ ./pyrra filesystem --config-files examples/nginx.yaml
level=info ts=2022-08-12T00:17:01.716103492Z caller=main.go:119 msg="using Prometheus" url=http://localhost:9090
level=info ts=2022-08-12T00:17:01.716181202Z caller=filesystem.go:128 msg="watching directory for changes" directory=examples
level=info ts=2022-08-12T00:17:01.716410362Z caller=filesystem.go:245 msg="starting up HTTP API" address=:9444
level=debug ts=2022-08-12T00:17:01.716517122Z caller=filesystem.go:170 msg=reading file=examples/nginx.yaml
level=error ts=2022-08-12T00:17:01.720097441Z caller=filesystem.go:253 msg="failed to run" err="failed to create rule file \"examples/nginx.yaml\": failed to write file \"/etc/prometheus/pyrra/nginx.yaml\": open /etc/prometheus/pyrra/nginx.yaml: permission denied"
gitpod /workspace/pyrra (main) $ ./pyrra generate --config-files examples/nginx.yaml
level=info ts=2022-08-12T00:17:17.616300781Z caller=main.go:119 msg="using Prometheus" url=http://localhost:9090
level=error ts=2022-08-12T00:17:17.618056421Z caller=generate.go:36 msg="generating rule files" err="failed to write file \"/etc/prometheus/pyrra/nginx.yaml\": open /etc/prometheus/pyrra/nginx.yaml: permission denied"
On main the same behavior is happening for the filesystem
command π€. Is that expected?
This should work since the code uses filepath.Glob
to discover files in a directory.
I'll check out this PR locally to take a look.
Sorry for taking so long, but PR rebased! I believe it should be ready for a review π