karma prometheus alertmanager dashboard简单试用

官方提供了一个简单的all-in-one 的dockerfile 我们可以学习下karma,了解下karma的处理机制,同时在这个all-in-one 中
也还包含了kthxbye一个方便的报警确认进程,整个项目基于supervisord运行(当然这个也是大家基于all-in-one容器的一个套路)

环境准备

  • Dockerfile
 
FROM node:12.16.3-alpine3.11 as nodejs-builder
RUN mkdir -p /src/ui
COPY ui/package.json ui/package-lock.json /src/ui/
RUN cd /src/ui && npm install
RUN apk add make git
COPY ui /src/ui
RUN make -C /src/ui build
FROM golang:1.14.2-alpine3.11 as go-builder
RUN apk add make git
COPY Makefile /src/Makefile
COPY make /src/make
COPY go.mod /src/go.mod
COPY go.sum /src/go.sum
RUN make -C /src download-deps-go
RUN make -C /src install-deps-build-go
COPY --from=nodejs-builder /src/ui/src /src/ui/src
COPY --from=nodejs-builder /src/ui/build /src/ui/build
COPY cmd /src/cmd
COPY internal /src/internal
ARG VERSION
RUN CGO_ENABLED=0 make -C /src VERSION="${VERSION:-dev}" karma
FROM alpine:3.11
COPY --from=lmierzwa/kthxbye:v0.7 /kthxbye /kthxbye
COPY --from=prom/alertmanager:v0.20.0 /bin/alertmanager /alertmanager
RUN apk add supervisor python && rm  -rf /tmp/* /var/cache/apk/*
COPY demo/supervisord.conf /etc/supervisord.conf
COPY demo/alertmanager.yaml /etc/alertmanager.yaml
COPY demo/generator.py /generator.py
COPY --from=go-builder /src/karma /karma
COPY demo/karma.yaml /etc/karma.yaml
COPY demo/acls.yaml /etc/acls.yaml
COPY demo/custom.js /custom.js
RUN adduser -D karma
USER karma
ENV GOGC=20
CMD supervisord --nodaemon --configuration /etc/supervisord.conf 
  • supervisord.conf
[supervisord]
nodaemon=true
pidfile=/tmp/supervisord.pid
logfile = /tmp/supervisord.log
logfile_maxbytes = 1MB
logfile_backups=0
loglevel = info
[program:alertmanager1]
command=/alertmanager --config.file=/etc/alertmanager.yaml --storage.path=/tmp/alertmanager1 --web.listen-address=:9093  --cluster.listen-address=127.0.0.1:8001 --cluster.peer=127.0.0.1:8002 --cluster.settle-timeout=1s
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:alertmanager2]
command=/alertmanager --config.file=/etc/alertmanager.yaml --storage.path=/tmp/alertmanager1 --web.listen-address=:9094  --cluster.listen-address=127.0.0.1:8002 --cluster.peer=127.0.0.1:8001 --cluster.settle-timeout=1s
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:generator]
command=/generator.py
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:karma]
command=/karma --config.file /etc/karma.yaml
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:kthxbye]
command=/kthxbye -listen :8081
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
 
 

运行

我已经构建好了一个all-in-one 的docker,可以直接运行

  • 命令
 
docker run -d -p 8080:8080 -p 9093:9093 -p 9094:9094 -p 8081:8081 dalongrong/karma-all-in-one 
  • 效果

说明

karma 是一个不错的prometheus alertmanager dashboard,而且和kthxbye集成起来会更好

参考资料

https://github.com/prymitive/karma
https://prometheus.io/docs/alerting/alertmanager/
https://hub.docker.com/repository/docker/dalongrong/karma-all-in-one
https://github.com/prymitive/kthxbye

原文地址:https://www.cnblogs.com/rongfengliang/p/12881387.html