Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upExpose full support for file globs for rules #2487
Comments
This comment has been minimized.
This comment has been minimized.
|
I think this is a valid use case. I would be interested as well why this decision was made. But it was before my time, so I would ask @beorn7 @brian-brazil @fabxc @juliusv as to why this decision was made. What would be the problem with a standard file glob? |
This comment has been minimized.
This comment has been minimized.
|
Would that work with inotify? |
This comment has been minimized.
This comment has been minimized.
|
I wasn't aware that rule files are watched and reloaded. I think in that case a watch per subdirectory has to be instantiated, and gets more complicated when you want to dynamically add new directories to watch when they're added. |
This comment has been minimized.
This comment has been minimized.
|
Also the documentation makes it sound like file globs work:
|
This comment has been minimized.
This comment has been minimized.
|
I can see how adding watched rule support would be useful, and I think doing this with full glob support would be a world of pain. But you need to be more limiting in your allowed file globs. Someone could be using ? between separators now which means inotify won't work as is. So in any case the regex needs to be patched to either be more permissive or more restrictive. I'll stop doing my ? between separators hack and I will just prefix rules in one directory when I deploy them. This achieves the same purpose and is future proof for whatever you decide to do. |
gouthamve
referenced this issue
Dec 19, 2017
Closed
Prometheus fails to recursively load alert rules #3546
This comment has been minimized.
This comment has been minimized.
jwhitlark
commented
Mar 14, 2018
|
Can we please have updated documentation on what file path support is available? I'd do a PR myself, but as it isn't actually a glob, I don't know what it actually supports. |
This comment has been minimized.
This comment has been minimized.
|
A glob is supported in the filename, looks like both rule_files and file_sd_configs are missing that detail. |
This comment has been minimized.
This comment has been minimized.
|
I don't think it would make sense to have this in one place and not the other, as that'd just cause confusion. Let's stick with just a glob in the file name. |
brian-brazil
closed this
Mar 21, 2018
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 22, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
dacameron commentedMar 9, 2017
What did you do?
Tried putting a file glob for rule_files:
What did you expect to see?
Rules loaded like:
What did you see instead? Under which circumstances?
and prometheus doesn't load.
To work around this I padded the service names so they are always 16 chars and added a rule:
/etc/prometheus/rules/????????????????/*.rule
a total hack but it works for now.
I am happy to send a pull request to fix the regex in config.go. But I am not sure if this is by design? or can the rule file path regex in config.go be improved?
The main use case is to have rules for different services in different directories. When deploying those services we can blow away the old rules by blowing away the directory with the rules, adding the new rules and then reloading prometheus.