Puppet Function: prometheus::proxy_pass

Defined in:
modules/prometheus/functions/proxy_pass.pp
Function type:
Puppet Language

Overview

prometheus::proxy_pass(Hash $config, Stdlib::Fqdn $localhost = $facts['networking']['fqdn']) ⇒ Any

Given a single Prometheus instance configuration, return either a URL or a list of URLs where the instance can be found.

Parameters:

  • config (Hash)
  • localhost (Stdlib::Fqdn) (defaults to: $facts['networking']['fqdn'])

Returns:

  • (Any)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'modules/prometheus/functions/proxy_pass.pp', line 5

function prometheus::proxy_pass (
  Hash $config,
  Stdlib::Fqdn $localhost = $facts['networking']['fqdn'],
) {
  if $localhost in $config['hosts'] {
    "http://localhost:${config['port']}/${config['instance']}"
  } else {
    $remote_hosts = $config['hosts'].filter |$h| { $h =~ "\\.${::site}" }.map |$h| { "https://${h}/${config['instance']}" }
    if empty($remote_hosts) {
      fail('No remote hosts found, aborting')
    }
    $remote_hosts
  }
}