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.

kandra: Add a Teleport app for each Prometheus exporter.

Alex Vandiver4320986c742c
diff --git a/puppet/kandra/manifests/app_frontend_monitoring.pp b/puppet/kandra/manifests/app_frontend_monitoring.pp
index 2fd54851a16..760c756a1b0 100644
--- a/puppet/kandra/manifests/app_frontend_monitoring.pp
+++ b/puppet/kandra/manifests/app_frontend_monitoring.pp
@@ -7,6 +7,8 @@ class kandra::app_frontend_monitoring {
include kandra::prometheus::process
include kandra::prometheus::grok
kandra::firewall_allow { 'tusd': port => '9900' }
+ kandra::teleport::prometheus_app { 'tusd': port => '9900' }
+ kandra::teleport::prometheus_app { 'katex': port => '9700' }
file { '/etc/cron.d/rabbitmq-monitoring':
ensure => absent,
diff --git a/puppet/kandra/manifests/camo.pp b/puppet/kandra/manifests/camo.pp
index d738583d0e1..07fa4f547b0 100644
--- a/puppet/kandra/manifests/camo.pp
+++ b/puppet/kandra/manifests/camo.pp
@@ -4,4 +4,5 @@ class kandra::camo {
}
kandra::firewall_allow { 'camo': port => '9292' }
+ kandra::teleport::prometheus_app { 'camo': port => '9292' }
}
diff --git a/puppet/kandra/manifests/profile/chat_zulip_org.pp b/puppet/kandra/manifests/profile/chat_zulip_org.pp
index f6f031d5fa2..d8c861b1b6f 100644
--- a/puppet/kandra/manifests/profile/chat_zulip_org.pp
+++ b/puppet/kandra/manifests/profile/chat_zulip_org.pp
@@ -7,7 +7,10 @@ class kandra::profile::chat_zulip_org inherits kandra::profile::base {
include kandra::app_frontend_monitoring
include kandra::prometheus::redis
include kandra::prometheus::postgresql
+ kandra::teleport::prometheus_app { 'smokescreen': port => '4760' }
+ kandra::teleport::prometheus_app { 'camo': port => '9292' }
kandra::firewall_allow { 'smokescreen_metrics': port => '4760' }
+
kandra::firewall_allow { 'http': }
kandra::firewall_allow { 'https': }
kandra::firewall_allow { 'smtp': }
diff --git a/puppet/kandra/manifests/profile/smokescreen.pp b/puppet/kandra/manifests/profile/smokescreen.pp
index 21564cc73f9..bc099fdd245 100644
--- a/puppet/kandra/manifests/profile/smokescreen.pp
+++ b/puppet/kandra/manifests/profile/smokescreen.pp
@@ -4,6 +4,7 @@ class kandra::profile::smokescreen inherits kandra::profile::base {
include zulip::profile::smokescreen
kandra::firewall_allow { 'smokescreen': port => '4750' }
kandra::firewall_allow { 'smokescreen_metrics': port => '4760' }
+ kandra::teleport::prometheus_app { 'smokescreen': port => '4760' }
include kandra::camo
}
diff --git a/puppet/kandra/manifests/prometheus/grok.pp b/puppet/kandra/manifests/prometheus/grok.pp
index a9238227b45..ccf08ee096c 100644
--- a/puppet/kandra/manifests/prometheus/grok.pp
+++ b/puppet/kandra/manifests/prometheus/grok.pp
@@ -28,6 +28,7 @@ class kandra::prometheus::grok {
}
kandra::firewall_allow { 'grok_exporter': port => '9144' }
+ kandra::teleport::prometheus_app { 'grok_exporter': port => '9144' }
file { "${zulip::common::supervisor_conf_dir}/prometheus_grok_exporter.conf":
ensure => file,
require => [
diff --git a/puppet/kandra/manifests/prometheus/memcached.pp b/puppet/kandra/manifests/prometheus/memcached.pp
index daaad3888c8..f27697813b7 100644
--- a/puppet/kandra/manifests/prometheus/memcached.pp
+++ b/puppet/kandra/manifests/prometheus/memcached.pp
@@ -23,6 +23,7 @@ class kandra::prometheus::memcached {
}
kandra::firewall_allow { 'memcached_exporter': port => '11212' }
+ kandra::teleport::prometheus_app { 'memcached_exporter': port => '11212' }
file { "${zulip::common::supervisor_conf_dir}/memcached_exporter.conf":
ensure => file,
require => [
diff --git a/puppet/kandra/manifests/prometheus/node.pp b/puppet/kandra/manifests/prometheus/node.pp
index 29a9d4402d0..28989722ea4 100644
--- a/puppet/kandra/manifests/prometheus/node.pp
+++ b/puppet/kandra/manifests/prometheus/node.pp
@@ -17,6 +17,7 @@ class kandra::prometheus::node {
}
kandra::firewall_allow { 'node_exporter': port => '9100' }
+ kandra::teleport::prometheus_app { 'node_exporter': port => '9100' }
file { "${zulip::common::supervisor_conf_dir}/prometheus_node_exporter.conf":
ensure => file,
require => [
diff --git a/puppet/kandra/manifests/prometheus/postgresql.pp b/puppet/kandra/manifests/prometheus/postgresql.pp
index 64531cd86f0..16ce9cada95 100644
--- a/puppet/kandra/manifests/prometheus/postgresql.pp
+++ b/puppet/kandra/manifests/prometheus/postgresql.pp
@@ -67,6 +67,7 @@ class kandra::prometheus::postgresql {
}
kandra::firewall_allow { 'postgres_exporter': port => '9187' }
+ kandra::teleport::prometheus_app { 'postgres_exporter': port => '9187' }
file { "${zulip::common::supervisor_conf_dir}/prometheus_postgres_exporter.conf":
ensure => file,
require => [
diff --git a/puppet/kandra/manifests/prometheus/process.pp b/puppet/kandra/manifests/prometheus/process.pp
index 05fc93bd6bd..d47d79fb886 100644
--- a/puppet/kandra/manifests/prometheus/process.pp
+++ b/puppet/kandra/manifests/prometheus/process.pp
@@ -18,6 +18,7 @@ class kandra::prometheus::process {
}
kandra::firewall_allow { 'process_exporter': port => '9256' }
+ kandra::teleport::prometheus_app { 'process_exporter': port => '9256' }
file { $conf:
ensure => file,
require => User[zulip],
diff --git a/puppet/kandra/manifests/prometheus/rabbitmq.pp b/puppet/kandra/manifests/prometheus/rabbitmq.pp
index 4ac6378da5d..f224062daf9 100644
--- a/puppet/kandra/manifests/prometheus/rabbitmq.pp
+++ b/puppet/kandra/manifests/prometheus/rabbitmq.pp
@@ -11,4 +11,5 @@ class kandra::prometheus::rabbitmq {
require => Service['rabbitmq-server'],
}
kandra::firewall_allow { 'rabbitmq': port => '15692' }
+ kandra::teleport::prometheus_app { 'rabbitmq': port => '15692' }
}
diff --git a/puppet/kandra/manifests/prometheus/redis.pp b/puppet/kandra/manifests/prometheus/redis.pp
index 8a59722a0a6..bb502183790 100644
--- a/puppet/kandra/manifests/prometheus/redis.pp
+++ b/puppet/kandra/manifests/prometheus/redis.pp
@@ -17,6 +17,7 @@ class kandra::prometheus::redis {
}
kandra::firewall_allow { 'redis_exporter': port => '9121' }
+ kandra::teleport::prometheus_app { 'redis_exporter': port => '9121' }
file { "${zulip::common::supervisor_conf_dir}/prometheus_redis_exporter.conf":
ensure => file,
require => [
diff --git a/puppet/kandra/manifests/prometheus/uwsgi.pp b/puppet/kandra/manifests/prometheus/uwsgi.pp
index 28cab4f34bf..97c2baeb965 100644
--- a/puppet/kandra/manifests/prometheus/uwsgi.pp
+++ b/puppet/kandra/manifests/prometheus/uwsgi.pp
@@ -17,6 +17,7 @@ class kandra::prometheus::uwsgi {
}
kandra::firewall_allow { 'uwsgi_exporter': port => '9238' }
+ kandra::teleport::prometheus_app { 'uwsgi_exporter': port => '9238' }
file { "${zulip::common::supervisor_conf_dir}/prometheus_uwsgi_exporter.conf":
ensure => file,
require => [
diff --git a/puppet/kandra/manifests/teleport/application.pp b/puppet/kandra/manifests/teleport/application.pp
index 44de0bf6ca4..dab8e5641d7 100644
--- a/puppet/kandra/manifests/teleport/application.pp
+++ b/puppet/kandra/manifests/teleport/application.pp
@@ -5,6 +5,7 @@ define kandra::teleport::application (
$port,
$description = '',
$order = '50',
+ $labels = {},
) {
include kandra::teleport::application_top
$app_data = [
@@ -14,7 +15,7 @@ define kandra::teleport::application (
uri => "http://localhost:${port}",
labels => {
name => $name,
- },
+ } + $labels,
},
]
diff --git a/puppet/kandra/manifests/teleport/prometheus_app.pp b/puppet/kandra/manifests/teleport/prometheus_app.pp
new file mode 100644
index 00000000000..ef33c1e8280
--- /dev/null
+++ b/puppet/kandra/manifests/teleport/prometheus_app.pp
@@ -0,0 +1,24 @@
+define kandra::teleport::prometheus_app (
+ $port,
+ $description = '',
+ $order = '50',
+) {
+ $app_name = regsubst("${facts['networking']['hostname']}-${name}", '_', '-', 'G')
+ # Handle non-AWS hosts which don't have ec2 metadata
+ $fallback_role = $facts['networking']['hostname'] ? {
+ /^([^.-]+)/ => $1,
+ default => '',
+ }
+ $role = pick_default($facts.dig('ec2_metadata', 'tags', 'instance', 'role'), $fallback_role)
+ kandra::teleport::application { $app_name:
+ port => $port,
+ order => $order,
+ description => $description,
+ labels => {
+ type => 'prometheus',
+ instance => $facts['networking']['hostname'],
+ exporter => $name,
+ role => $role,
+ }
+ }
+}