Joe Blog

在国内,大部分公司的员工目前在办公时用的沟通工具仍是邮件、QQ或者微信,文件会放到共享文件夹,或者用邮件、即时通讯工具来传输。而邮件使用起来比较费劲,没有即时性,而QQ和微信会让我们把生活与工作混在一起,降低做事效率,很多人在工作的时候还经常刷朋友圈、看QQ空间,这都是不好的现象。国外的现象跟国内也是大同小异。

Slack较早的发现了这个现象,瞄准了企业内部沟通协作这一空白点,做出了一款提高企业员工内部协作效率的软件。它将工作中所有信息的接口统统整合在一起,从而提高内部协作的效率,提高信息的利用率。

在Slack的界面上,我们可以看到它中间部分为谈话内容,和一般的通讯工具类似,而在右侧你可以随时查找在对话过程中涉及到的文件,目前Slack已经整合了包括Google Drive、Google+ Hangouts、Twitter、Dropbox、Asana、GitHub、RSS、Trello等各类通讯服务、团队协作服务、开发工具。

创建一个工作空间

新增频道

新增Incoming WebHooks

配置Incoming WebHooks

AlertManager Secret

alertmanager.yaml

global:
  resolve_timeout: 5m
  smtp_smarthost: "smtp.163.com:25"
  smtp_from: "xxx@163.com" #edit your own 163 smtp config
  smtp_auth_username: "xxx"
  smtp_auth_password: "xxx"
route:
  group_by: 
  - "alertname"
  - "cluster"
  - "service"
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 15m
  "receiver": "slack_webhook"
  routes:
  - match_re:
      "alertname": ^(host_cpu_usage|node_filesystem_free|host_down|TargetDown)$
    receiver: "slack_webhook"
  - match:
      severity: critical
    receiver: "slack_webhook"
  - match:
      severity: warning
    receiver: "slack_webhook"
  - match:
      "alertname": DeadMansSwitch
    receiver: "null"
receivers:
- name: "null"
- name: "team-X-mails"
  email_configs:
  - to: "needtochange@admin.com" 
- name: slack_webhook
  slack_configs:
  - send_resolved: false
    api_url: https://hooks.slack.com/services/NEEDTOCHANGE/xxxxxxxxxxxxx
    channel: prometheus
    username: ''
    color: 'dangergood'
    title: ''
    title_link: ''
    pretext: ''
    text: |-
      
         *Alert:*  - ``
        *Description:* 
        *Details:*
         • *:* ``
        
      
    fallback: ''
    icon_emoji: ''
    icon_url: ''
templates: 
- '/etc/alertmanager/config/*.tmpl'

default.tmpl

Cluster: CLUSTER_NAME
/#/alerts?receiver=

[:]  ()


Labels:
 -  = 
Annotations:
 -  = 
Source: 





 | 






alertmanager-secret-slack.yaml

apiVersion: v1
data:
  alertmanager.yaml: 
Z2xvYmFsOgogIHJlc29sdmVfdGltZW91dDogNW0KICBzbXRwX3NtYXJ0aG9zdDogInNtdHAuMTYzLmNvbToyNSIKICBzbXRwX2Zyb206ICJ4eHhAMTYzLmNvbSIgI2VkaXQgeW91ciBvd24gMTYzIHNtdHAgY29uZmlnCiAgc210cF9hdXRoX3VzZXJuYW1lOiAieHh4IgogIHNtdHBfYXV0aF9wYXNzd29yZDogInh4eCIKcm91dGU6CiAgZ3JvdXBfYnk6IAogIC0gImFsZXJ0bmFtZSIKICAtICJjbHVzdGVyIgogIC0gInNlcnZpY2UiCiAgZ3JvdXBfd2FpdDogMzBzCiAgZ3JvdXBfaW50ZXJ2YWw6IDVtCiAgcmVwZWF0X2ludGVydmFsOiAxNW0KICAicmVjZWl2ZXIiOiAic2xhY2tfd2ViaG9vayIKICByb3V0ZXM6CiAgLSBtYXRjaF9yZToKICAgICAgImFsZXJ0bmFtZSI6IF4oaG9zdF9jcHVfdXNhZ2V8bm9kZV9maWxlc3lzdGVtX2ZyZWV8aG9zdF9kb3dufFRhcmdldERvd24pJAogICAgcmVjZWl2ZXI6ICJzbGFja193ZWJob29rIgogIC0gbWF0Y2g6CiAgICAgIHNldmVyaXR5OiBjcml0aWNhbAogICAgcmVjZWl2ZXI6ICJzbGFja193ZWJob29rIgogIC0gbWF0Y2g6CiAgICAgIHNldmVyaXR5OiB3YXJuaW5nCiAgICByZWNlaXZlcjogInNsYWNrX3dlYmhvb2siCiAgLSBtYXRjaDoKICAgICAgImFsZXJ0bmFtZSI6IERlYWRNYW5zU3dpdGNoCiAgICByZWNlaXZlcjogIm51bGwiCnJlY2VpdmVyczoKLSBuYW1lOiAibnVsbCIKL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type: Opaque

结果

总结

如你所见,告警信息里包含很多详细信息,可以第一时间获取到,至于其及时性与是否具有滞后性得在实际使用过程中慢慢调整,你可以随意调整Prometheus的alert在注释块中包含标识符和描述标记以及自定义使用的格式default.tmpl