Add some minitor checks

This commit is contained in:
IamTheFij 2022-11-15 09:02:57 -08:00
parent 17ab7f637f
commit 4a68894238
2 changed files with 156 additions and 182 deletions

View File

@ -49,190 +49,34 @@ resource "consul_config_entry" "nzbget_intents" {
})
}
# module "nzbget" {
# source "./levant"
#
# template_path = "service.nomad"
# variables = {
# name = "nzbget"
# image = "linuxserver/nzbget"
# service_port = 6789
# ingress = true
# env = jsonencode({
# PGID = 100
# PUID = 1001
# TZ = "America/Los_Angeles"
# })
# host_volumes = jsonencode([
# {
# name = "download"
# dest = "/srv/volumes/download"
# read_only = false
# },
# ])
# }
# }
#
# module "sonarr" {
# source = "./levant"
#
# template_path = "service.nomad"
# variables = {
# name = "sonarr"
# image = "linuxserver/sonarr"
# service_port = 8989
# ingress = true
# env = jsonencode({
# PGID = 100
# PUID = 1001
# TZ = "America/Los_Angeles"
#
# })
# host_volumes = jsonencode([
# {
# name = "sonarr-data"
# dest = "/config"
# read_only = false
# },
# {
# name = "tv-sonarr"
# dest = "/srv/volumes/media-write/TV Shows"
# read_only = false
# },
# {
# name = "download"
# dest = "/srv/volumes/download"
# read_only = false
# },
# ])
# }
# }
module "minitor" {
source = "./service"
# resource "nomad_job" "photoprism" {
# jobspec = templatefile("services_tf.nomad", {
# vars = {
# name = "photoprism"
# image = "photoprism/photoprism:latest"
# ingress = true
# service_port = 2342
# sticky_disk = true
# healthcheck = "/library/login"
# env = {
# PHOTOPRISM_SITE_CAPTION = "AI-Powered Photos App"
# PHOTOPRISM_SITE_DESCRIPTION = "Fijolek home photos"
# PHOTOPRISM_SITE_TITLE = "PhotoPrism"
# PHOTOPRISM_SITE_URL = "https://photoprism.thefij.rocks:2342/" # server URL in the format "http(s)://domain.name(:port)/(path)"
# PHOTOPRISM_SPONSOR = "true"
# # Paths
# PHOTOPRISM_ORIGINALS_PATH = "/photoprism-media/Library"
# PHOTOPRISM_IMPORT_PATH = "/photoprism-media/Import"
# PHOTOPRISM_STORAGE_PATH = "$${NOMAD_TASK_DIR}/storage" # Storage PATH for generated files like cache and index
# # Unix permissions
# PHOTOPRISM_UID = 500
# PHOTOPRISM_GID = 100
# PHOTOPRISM_UMASK = 0000
# }
# mysql = true
# vault = true
# resources = {
# cpu = 100
# memory = 500
# memory_max = 1000
# }
# host_volumes = [
# {
# name = "photoprism-media"
# dest = "/photoprism-media"
# read_only = false
# },
# ]
# mysql_bootstrap = {
# vault_key = "kv/data/photoprism"
# }
# templates = [
# {
# data = <<EOF
# {{ with secret "kv/data/photoprism" -}}
# PHOTOPRISM_ADMIN_USER={{ .Data.data.admin_user }}
# PHOTOPRISM_ADMIN_PASSWORD={{ .Data.data.admin_password }}
# PHOTOPRISM_DATABASE_DRIVER=mysql
# PHOTOPRISM_DATABASE_NAME={{ .Data.data.db_name }}
# PHOTOPRISM_DATABASE_USER={{ .Data.data.db_user }}
# PHOTOPRISM_DATABASE_PASSWORD={{ .Data.data.db_pass }}
# PHOTOPRISM_DATABASE_SERVER="{{ env "NOMAD_UPSTREAM_ADDR_mysql_server" }}"
# {{ end -}}
# EOF
# dest_prefix = "$${NOMAD_SECRETS_DIR}/"
# dest = "env"
# env = true
# mount = false
# },
# ]
# }
# })
# }
# module "photoprism" {
# source = "IamTheFij/levant/nomad"
# version = "0.1.0"
#
# template_path = "service.nomad"
# variables = {
# name = "photoprism"
# image = "photoprism/photoprism:latest"
# ingress = true
# service_port = 2342
# sticky_disk = true
# healthcheck = "/library/login"
# env = jsonencode({
# PHOTOPRISM_SITE_CAPTION = "AI-Powered Photos App"
# PHOTOPRISM_SITE_DESCRIPTION = "Fijolek home photos"
# PHOTOPRISM_SITE_TITLE = "PhotoPrism"
# PHOTOPRISM_SITE_URL = "https://photoprism.thefij.rocks:2342/" # server URL in the format "http(s)://domain.name(:port)/(path)"
# PHOTOPRISM_SPONSOR = "true"
# # Paths
# PHOTOPRISM_ORIGINALS_PATH = "/photoprism-media/Library"
# PHOTOPRISM_IMPORT_PATH = "/photoprism-media/Import"
# PHOTOPRISM_STORAGE_PATH = "$${NOMAD_TASK_DIR}/storage" # Storage PATH for generated files like cache and index
# # Unix permissions
# PHOTOPRISM_UID = 500
# PHOTOPRISM_GID = 100
# PHOTOPRISM_UMASK = 0000
# })
# mysql = true
# vault = true
# host_volumes = jsonencode([
# {
# name = "photoprism-media"
# dest = "/photoprism-media"
# read_only = false
# },
# ])
# mysql_bootstrap = jsonencode({
# vault_key = "kv/data/photoprism"
# })
# templates = jsonencode([
# {
# data = <<EOF
# {{ with secret "kv/data/photoprism" -}}
# PHOTOPRISM_ADMIN_USER={{ .Data.data.admin_user }}
# PHOTOPRISM_ADMIN_PASSWORD={{ .Data.data.admin_password }}
# PHOTOPRISM_DATABASE_DRIVER=mysql
# PHOTOPRISM_DATABASE_NAME={{ .Data.data.db_name }}
# PHOTOPRISM_DATABASE_USER={{ .Data.data.db_user }}
# PHOTOPRISM_DATABASE_PASSWORD={{ .Data.data.db_pass }}
# PHOTOPRISM_DATABASE_SERVER="{{ env "NOMAD_UPSTREAM_ADDR_mysql_server" }}"
# {{ end -}}
# EOF
# dest_prefix = "$${NOMAD_SECRETS_DIR}/"
# dest = "env"
# env = true
# mount = false
# },
# ])
# }
# }
name = "minitor"
args = ["-metrics", "-config=$${NOMAD_TASK_DIR}/config.yml"]
image = "iamthefij/minitor-go:1.1"
service_port = 8080
metrics_port_name = "main"
use_vault = true
templates = [
{
data = <<EOF
{{ with secret "kv/data/mailgun_api" -}}
MAILGUN_API_KEY={{ .Data.data.key }}
{{ end -}}
EOF
dest = "env"
dest_prefix = "$${NOMAD_SECRETS_DIR}/"
env = true
},
{
data = file("${path.module}/minitor-config.yml")
dest = "config.yml"
mount = false
},
]
}
module "photoprism_module" {
source = "./service"

130
services/minitor-config.yml Normal file
View File

@ -0,0 +1,130 @@
---
check_interval: 30s
monitors:
- name: Cloudron
command:
- 'curl'
- '--silent'
- '--show-error'
- '--fail'
- '-o'
- '/dev/null'
- 'https://my.iamthefij.com'
alert_down: [log, mailgun]
alert_up: [log, mailgun_up]
check_interval: 30s
alert_after: 20 # 20 * 30s = 10 min
alert_every: 1440 # 12hrs / 30s = 1440 checks
- name: Grafana (public)
command:
- 'curl'
- '--silent'
- '--show-error'
- '--fail'
- '-o'
- '/dev/null'
- 'https://grafana.iamthefij.com'
alert_down: [log, mailgun]
alert_up: [log, mailgun_up]
check_interval: 30s
alert_after: 20 # 20 * 30s = 10 min
alert_every: 1440 # 12hrs / 30s = 1440 checks
- name: Grafana (internal)
command:
- 'curl'
- '--silent'
- '--show-error'
- '--fail'
- '-o'
- '/dev/null'
- 'https://grafana.thefij.rocks'
alert_down: [log, mailgun]
alert_up: [log, mailgun_up]
check_interval: 30s
alert_after: 20 # 20 * 30s = 10 min
alert_every: 1440 # 12hrs / 30s = 1440 checks
- name: Plex
command:
- 'curl'
- '--silent'
- '--show-error'
- '-o'
- '/dev/null'
- 'http://home-nas.thefij:32400'
alert_down: [log, mailgun]
alert_up: [log, mailgun_up]
check_interval: 30s
alert_after: 20 # 20 * 30s = 10 min
alert_every: 1440 # 12hrs / 30s = 1440 checks
- name: NZBget
command:
- 'curl'
- '--silent'
- '--show-error'
- '--fail'
- '-o'
- '/dev/null'
- 'https://nzbget.thefij.rocks'
alert_down: [log, mailgun]
alert_up: [log, mailgun_up]
check_interval: 30s
alert_after: 20 # 20 * 30s = 10 min
alert_every: 1440 # 12hrs / 30s = 1440 checks
- name: Sonarr
command:
- 'curl'
- '--silent'
- '--show-error'
- '--fail'
- '-o'
- '/dev/null'
- 'https://sonarr.thefij.rocks'
alert_down: [log, mailgun]
alert_up: [log, mailgun_up]
check_interval: 30s
alert_after: 20 # 20 * 30s = 10 min
alert_every: 1440 # 12hrs / 30s = 1440 checks
- name: Photoprism
command:
- 'curl'
- '--silent'
- '--show-error'
- '--fail'
- '-o'
- '/dev/null'
- 'https://photoprism.thefij.rocks'
alert_down: [log, mailgun]
alert_up: [log, mailgun_up]
check_interval: 30s
alert_after: 20 # 20 * 30s = 10 min
alert_every: 1440 # 12hrs / 30s = 1440 checks
alerts:
log:
command: 'echo {{.MonitorName}}'
mailgun:
command: >
curl -sS -X POST
-F subject="ALERT! {{.MonitorName}} is Down"
-F from="Minitor <minitor@iamthefij.com>"
-F to=ian@iamthefij.com
-F text=$'{{.MonitorName}} has failed {{.FailureCount}} checks. Alert count: {{.AlertCount}}. Last success was {{.LastSuccess}}.\n\n-Nomad Minitor'
https://api.mailgun.net/v3/mg.iamthefij.com/messages
-u "api:$MAILGUN_API_KEY"
mailgun_up:
command: >
curl -sS -X POST
-F subject="RECOVERED! {{.MonitorName}} is back Up"
-F from="Minitor <minitor@iamthefij.com>"
-F to=ian@iamthefij.com
-F text=$'{{.MonitorName}} has recovered.\n\n-Nomad Minitor'
https://api.mailgun.net/v3/mg.iamthefij.com/messages
-u "api:$MAILGUN_API_KEY"