Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

2.5 KB
Raw Blame
# @summary Gathers Prometheus statistics from all nodes.
#
# Only one instance is necessary.
#
class kandra::profile::prometheus_server inherits kandra::profile::base {

  include kandra::prometheus::base

  # Service discovery via Teleport
  include kandra::teleport::tbot
  include kandra::teleport::sd

  # This blackbox monitoring of the backup system runs locally
  include kandra::prometheus::wal_g

  # Ditto the Akamai logs
  include kandra::prometheus::akamai

  # Ditto Weblate
  include kandra::prometheus::weblate

  # The SES log ETL (writing to S3) runs on vector
  include kandra::ses_logs

  # Export prometheus stats to status.zulip.com
  include kandra::statuspage

  $version = $zulip::common::versions['prometheus']['version']
  $dir = "/srv/zulip-prometheus-${version}"
  $bin = "${dir}/prometheus"
  $data_dir = '/var/lib/prometheus'

  zulip::external_dep { 'prometheus':
    version        => $version,
    url            => "https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-${version}.linux-${zulip::common::goarch}.tar.gz",
    tarball_prefix => "prometheus-${version}.linux-${zulip::common::goarch}",
    bin            => [$bin, "${dir}/promtool"],
    cleanup_after  => [Service[supervisor]],
  }
  file { '/usr/local/bin/promtool':
    ensure  => link,
    target  => "${dir}/promtool",
    require => File["${dir}/promtool"],
    before  => Exec['Cleanup prometheus'],
  }

  file { $data_dir:
    ensure  => directory,
    owner   => 'prometheus',
    group   => 'prometheus',
    require => [ User[prometheus], Group[prometheus] ],
  }
  file { '/etc/prometheus':
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0755',
  }

  $czo = zulipconf('prometheus', 'czo', '')
  $other_hosts = split(zulipconf('prometheus', 'other_hosts', ''), ',')
  $backup_buckets = split(zulipconf('prometheus', 'walg_buckets', ''), ',')
  file { '/etc/prometheus/prometheus.yaml':
    ensure  => file,
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => template('kandra/prometheus/prometheus.yaml.template.erb'),
    notify  => Service[supervisor],
  }

  file { "${zulip::common::supervisor_conf_dir}/prometheus.conf":
    ensure  => file,
    require => [
      Package[supervisor],
      File[$bin],
      File[$data_dir],
      File['/etc/prometheus/prometheus.yaml'],
      Service['tbot'],
    ],
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => template('kandra/supervisor/conf.d/prometheus.conf.template.erb'),
    notify  => Service[supervisor],
  }
}