Defined Type: thanos::recording_rule

Defined in:
modules/thanos/manifests/recording_rule.pp

Overview

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • source (Optional[String]) (defaults to: undef)
  • content (Optional[String]) (defaults to: undef)
  • rules_dir (Stdlib::Unixpath) (defaults to: '/etc/thanos-rule/rules')


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'modules/thanos/manifests/recording_rule.pp', line 4

define thanos::recording_rule (
    Wmflib::Ensure   $ensure    = 'present',
    Optional[String] $source    = undef,
    Optional[String] $content   = undef,
    Stdlib::Unixpath $rules_dir = '/etc/thanos-rule/rules',
) {
    include thanos

    # The thanos config includes glob $rules_dir/*.yaml, so require a .yaml file extension
    if $title !~ '.yaml$' {
        fail("Title(${title}): thanos recording rules must have a .yaml file extention")
    }

    # Perform a rule validity check before deploying
    $validate_cmd = '/usr/bin/thanos tools rules-check --rules %'

    file { "${rules_dir}/${title}":
        ensure       => file,
        mode         => '0444',
        owner        => 'root',
        source       => $source,
        content      => $content,
        validate_cmd => $validate_cmd,
        notify       => Exec['reload thanos-rule'],
    }
}