puppet-prometheus icon indicating copy to clipboard operation
puppet-prometheus copied to clipboard

Feature request for recording rule support

Open bcoleman532 opened this issue 8 years ago • 7 comments

While I can define where prometheus can find a recording rule file, this module gives me no means to specify the contents of that file.

Ideally I would like to be able to use the same module to handle both the prometheus configuration and recording rule definitions.

bcoleman532 avatar Oct 17 '17 17:10 bcoleman532

Hi @bcoleman532, thanks for this issue. Are you able to add a PR for this?

bastelfreak avatar Oct 17 '17 19:10 bastelfreak

At this time, no.

My workaround for this is a crude "just get it working" fix instead of doing it correctly.

I'd love to be able to eventually provide a PR but between my newness to puppet and my lack of time to work on creating one it isn't something that I could provide any time soon.

bcoleman532 avatar Oct 17 '17 20:10 bcoleman532

Are you able to share your hack as a PR? We can use that as a baseline to work together on the feature. Don't be scared about contribution, everybody started somewhere.

bastelfreak avatar Oct 17 '17 21:10 bastelfreak

Hi @bcoleman532

I'm facing the same problem as you, but I resolved using the "extra_alerts" parameter. IMHO, it works just fine and a new parameter will be overkill... Maybe just changing this parameter name for "extra_rules" makes more sense since this parameter can be used for any kind of rules, not only alerts.

How to use it:

extra_alerts => {
      'record_rules' => {
        'groups' => [
          {
            'name' => 'record.rules',
            'rules' => [
              {
                'record' => 'device:disk_free:avg',
                'expr' => 'avg(avg_over_time(disk_free{fstype=~"(ext[234]|btrfs)"}[1w])) by(host,device)',
              },
            ],
          },
        ],
      },
    },

allangood avatar May 30 '18 15:05 allangood

This workaround is great for Prom 2.0 , it doesn't work for versions <2.0 as the templating does not recognise an "alert" with fields record/expr

My $0.02 opinion is that $alerts, $extra_alerts are incorrectly named and really should be $rules and $extra_rules in line with $rule_files.

@bastelfreak , @bcoleman532 I've got a branch for making the workaround valid for prom <2.0 if that is helpful for anyone else.

bramblek1 avatar Jul 30 '18 23:07 bramblek1

It might work to use the rule_files param to support recording/alerting rules. You can specify a filepath glob, which allows you to break your rules up into multiple files.

hooten avatar Nov 08 '19 21:11 hooten

prometheus < 2 is not an issue anymore, IMHO.

TheMeier avatar May 05 '24 11:05 TheMeier

IMHO sufficient solutions are provided. Also there was no significant activity for a few years

TheMeier avatar Dec 30 '24 11:12 TheMeier