Last active
July 22, 2020 08:58
-
-
Save harryge00/c0d865daad650e771ddbab429aa7a11c to your computer and use it in GitHub Desktop.
Dingtalk Webhook Deployment for Prometheus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: prometheus-webhook-dingtalk-config | |
namespace: kubeaddons | |
data: | |
config.yml: | | |
targets: | |
webhook1: | |
url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxx | |
# secret for signature | |
secret: SEC09xxxxxxx | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
labels: | |
name: prometheus-webhook-dingtalk | |
name: prometheus-webhook-dingtalk | |
namespace: kubeaddons | |
spec: | |
ports: | |
- port: 8060 | |
protocol: TCP | |
selector: | |
app: prometheus-webhook-dingtalk | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
labels: | |
name: prometheus-webhook-dingtalk | |
name: prometheus-webhook-dingtalk | |
namespace: kubeaddons | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: prometheus-webhook-dingtalk | |
template: | |
metadata: | |
labels: | |
app: prometheus-webhook-dingtalk | |
spec: | |
containers: | |
- image: ccr.ccs.tencentyun.com/d2iq/prometheus-webhook-dingtalk:v1.4.0 | |
name: prometheus-webhook-dingtalk | |
args: | |
- "--config.file=/dingtalk-config/config.yml" | |
- "--web.listen-address=:8060" | |
ports: | |
- containerPort: 8060 | |
protocol: TCP | |
resources: | |
requests: | |
cpu: 100m | |
memory: 100Mi | |
limits: | |
cpu: 200m | |
memory: 256Mi | |
volumeMounts: | |
- name: conf | |
mountPath: /dingtalk-config | |
readOnly: true | |
volumes: | |
- name: conf | |
configMap: | |
name: prometheus-webhook-dingtalk-config | |
defaultMode: 0755 | |
imagePullSecrets: | |
- name: IfNotPresent |
在 receivers
中添加
webhook_configs:
- send_resolved: true
url: http://prometheus-webhook-dingtalk.kubeaddons.svc.cluster.local:8060/dingtalk/webhook1/send
完整的alertmanager.yaml
:
global:
resolve_timeout: 5m
slack_api_url: https://hooks.slack.com/services/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
route:
group_by: ['alertname']
group_wait: 2m
group_interval: 5m
repeat_interval: 1h
# If an alert isn't caught by a route, send it to slack.
receiver: slack_and_dingtalk
routes:
- match:
alertname: Watchdog
receiver: "null"
receivers:
- name: "null"
- name: slack_and_dingtalk
webhook_configs:
- send_resolved: true
url: http://prometheus-webhook-dingtalk.kubeaddons.svc.cluster.local:8060/dingtalk/webhook1/send
slack_configs:
- channel: '#k8s'
icon_url: https://avatars3.githubusercontent.com/u/3380462
send_resolved: true
color: '{{ if eq .Status "firing" }}danger{{ else }}good{{ end }}'
title: '{{ template "slack.default.title" . }}'
title_link: '{{ template "slack.default.titlelink" . }}'
pretext: '{{ template "slack.default.pretext" . }}'
text: '{{ template "slack.default.text" . }}'
fallback: '{{ template "slack.default.fallback" . }}'
icon_emoji: '{{ template "slack.default.iconemoji" . }}'
templates:
- '*.tmpl'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
prometheus-webhook-dingtalk:v1.4.0 is based on https://github.com/timonwong/prometheus-webhook-dingtalk