Commit 33a6ee04 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Pone al día el proyecto, añade salida Telegram

Actualiza versiones de configuración, simplifica CI, renombra variables
y revisa configs.

Migra hacia Traefik v2.

Integra nuevo receiver Telegram.
parent 4a2a89d9
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -9,5 +9,3 @@ stages:
.deploy:
  variables:
    STACK: metric
  environment:
    url: https://${CI_PROJECT_NAME}.${PUBLIC_HOSTNAME}
+13 −3
Original line number Diff line number Diff line
CONFIG_PATH=/etc/alertmanager
DATA_PATH=/alertmanager

SLACK_URL=https://hooks.slack.com/services/TOKEN
SLACK_CHANNEL=#general
SLACK_USER=alertmanager
CONFIG_PATH=/etc/alertmanager
DATA_PATH=/alertmanager
ALERTMANAGER_VOL_NAME=alertmanager-vol
SLACK_TEXT_TEMPLATE={{ .CommonAnnotations.description }}

TELEGRAM_BOT_TOKEN=changeme
TELEGRAM_CHAT_ID=123
TELEGRAM_MESSAGE_TEMPLATE={{ template "telegram.default.message" .}}
TELEGRAM_DISABLE_NOTIFICATIONS=false

TRAEFIK_SUBDOMAIN=alertmanager
PUBLIC_HOSTNAME=change.me
TRAEFIK_AUTH=user:$apr1$md5password

ALERTMANAGER_VOL_NAME=alertmanager-vol
+11 −2
Original line number Diff line number Diff line
route:
  receiver: 'slack'
  continue: true
  routes:
    - receiver: 'slack'
    - receiver: 'telegram'

receivers:
  - name: 'slack'
    slack_configs:
      - send_resolved: true
        text: "{{ .CommonAnnotations.description }}"
        text: '${SLACK_TEXT_TEMPLATE}'
        username: '${SLACK_USER}'
        channel: '${SLACK_CHANNEL}'
        api_url: '${SLACK_URL}'
  - name: 'telegram'
    telegram_configs:
      - bot_token: '${TELEGRAM_BOT_TOKEN}'
        chat_id: '${TELEGRAM_CHAT_ID}'
        message: '${TELEGRAM_MESSAGE_TEMPLATE}'
        disable_notifications: '${TELEGRAM_DISABLE_NOTIFICATIONS}'
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,11 @@ cat ${CONFIG_PATH}/alertmanager-tmpl.yml \
	| sed "s@\${SLACK_URL}@${SLACK_URL}@g" \
	| sed "s@\${SLACK_CHANNEL}@${SLACK_CHANNEL}@g" \
	| sed "s@\${SLACK_USER}@${SLACK_USER}@g" \
	| sed "s@\${SLACK_TEXT_TEMPLATE}@${SLACK_TEXT_TEMPLATE}@g" \
	| sed "s@\${TELEGRAM_CHAT_ID}@${TELEGRAM_CHAT_ID}@g" \
	| sed "s@\${TELEGRAM_BOT_TOKEN}@${TELEGRAM_BOT_TOKEN}@g" \
	| sed "s@\${TELEGRAM_MESSAGE_TEMPLATE}@${TELEGRAM_MESSAGE_TEMPLATE}@g" \
	| sed "s@\${TELEGRAM_DISABLE_NOTIFICATIONS}@${TELEGRAM_DISABLE_NOTIFICATIONS}@g" \
	> ${CONFIG_PATH}/alertmanager.yml

set -- /bin/alertmanager "${@}"
+2 −2
Original line number Diff line number Diff line
version: '3.5'
version: '3.9'

volumes:
  alertmanager-vol:
@@ -6,5 +6,5 @@ volumes:
    driver: local
    driver_opts:
      type: ${VOL_TYPE:-nfs4}
      o: addr=${VOL_ADDR:-127.0.0.1},${VOL_OPTIONS:-rw,nolock,noatime,tcp,rsize=8192,wsize=8192,timeo=14}
      o: addr=${VOL_ADDR:-127.0.0.1},${VOL_OPTS:-rw,nolock,noatime,tcp,rsize=8192,wsize=8192,timeo=14}
      device: ${ALERTMANAGER_VOL_DEVICE:-:/alertmanager-vol/}
Loading