Defined Type: prometheus::rule

Defined in:
modules/prometheus/manifests/rule.pp

Overview

Parameters:

  • instance (String)
  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • instance_path (Stdlib::Unixpath) (defaults to: "/srv/prometheus/${instance}")
  • source (Optional[String]) (defaults to: undef)
  • content (Optional[String]) (defaults to: undef)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'modules/prometheus/manifests/rule.pp', line 15

define prometheus::rule (
    String           $instance,
    Wmflib::Ensure   $ensure = 'present',
    Stdlib::Unixpath $instance_path = "/srv/prometheus/${instance}",
    Optional[String] $source = undef,
    Optional[String] $content = undef,
) {

    $service_name = "prometheus@${instance}"
    $file_path = "${instance_path}/rules/${title}"

    if $title !~ '.yml$' {
        fail("Title(${title}): must have a .yml extention")
    }
    $validate_cmd = '/usr/bin/promtool check rules %'

    file { $file_path:
        ensure       => file,
        mode         => '0444',
        owner        => 'root',
        source       => $source,
        content      => $content,
        notify       => Exec["${service_name}-reload"],
        validate_cmd => $validate_cmd,
    }
}