git clone https://github.com/feiyu563/PrometheusAlert.git
cd PrometheusAlert/example/helm/prometheusalert
#Update config/app.conf to set login user information and configure database informationhelm install -n monitoring .
Create an enterprise WeChat group robot
After the enterprise WeChat group, click the enterprise WeChat group, right-click “Add group robot”, and create a group robot to get a robot webhook address, record the address for backup.
apiVersion:monitoring.coreos.com/v1kind:PrometheusRulemetadata:labels:prometheus:k8srole:alert-rulesname:external-node.rulesnamespace:monitoringspec:groups:-name:k8s-node.rulesrules:-alert:disk capacityexpr:100-(node_filesystem_avail_bytes{instance=~'39.100.*',fstype=~"ext4|xfs|fuse.glusterfs"}/node_filesystem_size_bytes {fstype=~"ext4|xfs|fuse.glusterfs"}*100) > 96for:1mlabels:severity:criticalapp:node-alertannotations:summary:"{{$labels.mountpoint}} Disk partition usage is too high! "description:"{{$labels.mountpoint }} Disk partition usage is greater than 90% (currently using: {{$value}}%)"
Custom message template
For the above alarm rules, by default, alertmanger has its own alarm message template which is not very useful. Here we use the alarm template of prometheusalert for configuration.
According to the official documentation, we create a new template and specify the template type as WeChat for Enterprise, the template uses Prometheus, and the template content is as follows:
After the disk space alarm, the actual effect is as follows:
So far, the configuration of using prometheusalert to receive Prometheus alarm messages and forward them to the enterprise WeChat group robot has been completed.
In addition, for multiple clusters and multiple message sources, the power of prometheusalert is reflected.