Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametrised rules #3804

Closed
jsuchenia opened this Issue Feb 6, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@jsuchenia
Copy link

jsuchenia commented Feb 6, 2018

Enhancement request

It could be nice that rule files can be loaded with some parameters attached. Those parameters could be useful as a context to 'for' or some default labels assignments
Currently all rules are loaded as they are so it's hard to maintain rules with different settings or threshold levels

How to implement that

We can evaluate rule file before YAML parser as a template. I know that inside Alert rules we use templating, so initial params can be included using other notation like [[ and ]] instead of typical mustaches (looks like in go templating you can define Delims)

Example usage:

rules:
 - file: /path/to/file.yml
   params:
      a: b
      c: d

Then we can skip groups, change thresholds, conditionally load/skip alerts based on cofiguration

  • Prometheus version:
    Currently in 2.1.0 there are no such solution
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Feb 6, 2018

This sort of thing is something that we expect users to handle using the templating feature of your configuration management system. In this case it sounds like you may be looking for the existing external_labels setting combined with alert notification templates in the Alertmanager.

@jsuchenia

This comment has been minimized.

Copy link
Author

jsuchenia commented Feb 6, 2018

@brian-brazil When you have a configuration management then you can use it - and that's fine. However often we have only scheduler (like kubernetes, or others) to run a container and pre-defined configuration that can use service discovery. Currently I'm using a bunch of sed/awk scripts to tune main config file + concatenate only needed alerts

Of course using scheduler we can deliver a whole configuration and all needed alerts. In our case we deliver an application with profiled prometheus to monitor it (rules, console templates) - in this case you have to adjust configuration in a scheduler (prometheus params, new rules) - we can't deliver a template of that.

As long as I'm thinking about that it could be useful to have an ability to override parameters from a command line or env variable - maybe we can template config and alerts based from env variables, cmd line or hardcoded as proposed above?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Feb 6, 2018

Prometheus intends to be a monitoring system, not to duplicate the functionality of configuration management. There's no plans to add any such features to Prometheus. You should look into something like ksonnet.

@lock

This comment has been minimized.

Copy link

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.

@lock lock bot locked and limited conversation to collaborators Mar 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.