Telegrammy bits - Requires a patch to vigil itself.
Some checks failed
Trunk Check / Trunk Check Runner (push) Failing after 2s

This commit is contained in:
Greyscale 2024-07-09 11:58:20 +02:00
parent 4482dbb3c6
commit 793568095e
5 changed files with 51 additions and 21 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@
/terraform.tfstate*
/.terraform.tfstate*
/.github/cache
/terraform.tfvars

View file

@ -7,19 +7,22 @@ locals {
})
]
vigil_toml = templatefile("${path.module}/vigil.toml.tpl", {
manager_token = random_password.token["manager"].result
reporter_token = random_password.token["worker"].result
page_title = var.page_title
page_url = var.page_url
company_name = var.company_name
icon_color = var.icon_color
icon_url = var.icon_url
logo_color = var.logo_color
logo_url = var.logo_url
website_url = var.website_url
support_url = var.support_url
custom_html = var.custom_html
services = local.services_toml
manager_token = random_password.token["manager"].result
reporter_token = random_password.token["worker"].result
page_title = var.page_title
page_url = var.page_url
company_name = var.company_name
icon_color = var.icon_color
icon_url = var.icon_url
logo_color = var.logo_color
logo_url = var.logo_url
website_url = var.website_url
support_url = var.support_url
custom_html = var.custom_html
services = local.services_toml
startup_notification = var.notify_on_startup
telegram_bot_token = var.notify_telegram.token
telegram_chat_id = var.notify_telegram.channel
})
vigil_toml_checksum = md5(local.vigil_toml)
}

View file

@ -16,7 +16,20 @@ variable "docker_networks" {
description = "Docker networks to connect the vigil service to"
default = null
}
variable "notify_on_startup" {
type = bool
description = "Whether to send a startup notifications"
default = false
}
variable "notify_telegram" {
type = object({
token = string
channel = string
topic = optional(string, null)
})
description = "Telegram configuration"
default = null
}
variable "monitored_services" {
type = map(list(object({
id = string
@ -26,7 +39,6 @@ variable "monitored_services" {
http_status_healthy_below = optional(number, 400)
http_status_healthy_above = optional(number, 200)
})))
}
variable "page_title" {
type = string

View file

@ -54,14 +54,14 @@ queue_nack_dead_above = 5000
queue_loaded_retry_delay = 500
[notify]
startup_notification = false
startup_notification = ${startup_notification}
reminder_interval = 600
reminder_backoff_function = "linear"
reminder_backoff_limit = 3
#[notify.telegram]
#bot_token = "xxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#chat_id = "xxxxxxxxx"
[notify.telegram]
bot_token = "${telegram_bot_token}"
chat_id = "${telegram_chat_id}"
[probe]

View file

@ -9,7 +9,15 @@ module "vigil_nginx_config" {
allow_non_ssl = true
allow_ssl = false
}
variable "telegram_token" {
type = string
}
variable "telegram_channel" {
type = string
}
variable "telegram_topic" {
type = string
}
module "vigil" {
source = "./modules/vigil"
monitored_services = {
@ -53,7 +61,7 @@ module "vigil" {
id = "backup"
label = "Backup Server"
endpoints = [
"icmp://backup.ti",
#"icmp://backup.ti", # ??? Doesn't work?
"tcp://backup.ti:22",
"http://backup.ti",
]
@ -205,4 +213,10 @@ module "vigil" {
docker_networks = [
docker_network.loadbalancer
]
notify_on_startup = true
notify_telegram = {
token = var.telegram_token
channel = var.telegram_channel
topic = var.telegram_topic
}
}