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.

puppet: Add grafana server.

Alex Vandiver100a899d5d04
diff --git a/puppet/zulip_ops/files/grafana/grafana.ini b/puppet/zulip_ops/files/grafana/grafana.ini
new file mode 100644
index 00000000000..303c364edea
--- /dev/null
+++ b/puppet/zulip_ops/files/grafana/grafana.ini
@@ -0,0 +1,42 @@
+#################################### Paths ####################################
+[paths]
+# Path to where grafana can store temp files, sessions, and the sqlite3 db
+data = /var/lib/grafana
+
+# Directory where grafana can store logs
+logs = /var/log/grafana
+
+# Directory where grafana will automatically scan and look for plugins
+plugins = /var/lib/grafana/plugins
+
+
+#################################### Server ####################################
+[server]
+# Protocol (http, https, h2, socket)
+protocol = http
+
+# The ip address to bind to, empty will bind to all interfaces
+http_addr = 127.0.0.1
+
+# The http port to use
+http_port = 3000
+
+# The public facing domain name used to access grafana from a browser
+domain = monitoring.teleport.zulipchat.net
+
+# The full public facing url you use in browser, used for redirects and emails
+# If you use reverse proxy and sub path specify full url (with sub path)
+root_url = https://monitoring.teleport.zulipchat.net/
+
+
+#################################### Auth JWT ####################################
+[auth.jwt]
+# Grafana should trust the JWT that is provided in a header from Teleport; see
+# https://goteleport.com/docs/application-access/guides/jwt/ and
+# https://grafana.com/docs/grafana/latest/auth/jwt/
+enabled = true
+header_name = Teleport-Jwt-Assertion
+username_claim = sub
+jwk_set_url = https://teleport.zulipchat.net/.well-known/jwks.json
+cache_ttl = 24h
+expect_claims = {"iss": "teleport.zulipchat.net"}
diff --git a/puppet/zulip_ops/files/prometheus/prometheus.yaml b/puppet/zulip_ops/files/prometheus/prometheus.yaml
index f3a24fb16b1..1c431ac470a 100644
--- a/puppet/zulip_ops/files/prometheus/prometheus.yaml
+++ b/puppet/zulip_ops/files/prometheus/prometheus.yaml
@@ -9,6 +9,9 @@ scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
+ - job_name: "grafana"
+ static_configs:
+ - targets: ["localhost:3000"]
# Fetch from node_exporter on all of the EC2 hosts
- job_name: "node"
diff --git a/puppet/zulip_ops/files/supervisor/conf.d/grafana.conf b/puppet/zulip_ops/files/supervisor/conf.d/grafana.conf
new file mode 100644
index 00000000000..5c104b6f63e
--- /dev/null
+++ b/puppet/zulip_ops/files/supervisor/conf.d/grafana.conf
@@ -0,0 +1,7 @@
+[program:grafana]
+command=/srv/grafana/bin/grafana-server -config /etc/grafana/grafana.ini
+directory=/srv/grafana
+priority=15
+autostart=true
+autorestart=true
+user=grafana
diff --git a/puppet/zulip_ops/manifests/profile/grafana.pp b/puppet/zulip_ops/manifests/profile/grafana.pp
new file mode 100644
index 00000000000..65fbfe967f4
--- /dev/null
+++ b/puppet/zulip_ops/manifests/profile/grafana.pp
@@ -0,0 +1,76 @@
+# @summary Observability using Grafana
+#
+class zulip_ops::profile::grafana {
+ include zulip_ops::profile::base
+ include zulip::supervisor
+
+ $version = '8.0.0'
+ zulip::sha256_tarball_to { 'grafana':
+ url => "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz",
+ sha256 => '6f006990fcb89307e7911b0b3a4b54810c7e4a6f16240d9deb979f3010a71a9e',
+ install => {
+ "grafana-${version}/" => "/srv/grafana-${version}/",
+ },
+ }
+ file { '/srv/grafana':
+ ensure => 'link',
+ target => "/srv/grafana-${version}/",
+ require => Zulip::Sha256_tarball_to['grafana'],
+ }
+
+ group { 'grafana':
+ ensure => present,
+ gid => '1070',
+ }
+ user { 'grafana':
+ ensure => present,
+ uid => '1070',
+ gid => '1070',
+ shell => '/bin/bash',
+ home => '/srv/grafana',
+ managehome => false,
+ }
+ file { '/var/lib/grafana':
+ ensure => directory,
+ owner => 'grafana',
+ group => 'grafana',
+ require => [ User[grafana], Group[grafana] ],
+ }
+ file { '/var/log/grafana':
+ ensure => directory,
+ owner => 'grafana',
+ group => 'grafana',
+ }
+
+ zulip_ops::teleport::application { 'monitoring': port => '3000' }
+ zulip_ops::firewall_allow { 'grafana': port => '3000' }
+ file { '/etc/supervisor/conf.d/grafana.conf':
+ ensure => file,
+ require => [
+ Package[supervisor],
+ File['/srv/grafana'],
+ File['/var/lib/grafana'],
+ File['/var/log/grafana'],
+ ],
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ source => 'puppet:///modules/zulip_ops/supervisor/conf.d/grafana.conf',
+ notify => Service[supervisor],
+ }
+
+ file { '/etc/grafana':
+ ensure => directory,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ }
+ file { '/etc/grafana/grafana.ini':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ source => 'puppet:///modules/zulip_ops/grafana/grafana.ini',
+ notify => Service[supervisor],
+ }
+}