Grafana configures alarms

Rule configuration

  • Modify Grafana default configuration
/ root @ Prometheus ~ # vim/usr/local/Prometheus_grafana/conf/defaults. Ini # domain parameter Grafana host IP domain = instead [SMTP] enabled = true host = smtp.126.com:25 user = "[email protected]" # If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;" "" password = "XXXXXXXXXXXXXXXX" cert_file = key_file = skip_verify = true from_address = [email protected] from_name = Grafana ehlo_identity = startTLS_policy =Copy the code
  • Configure Alert in Dashboard
Rule Name "CPU usage alert" Evaluate every "30s" For "1m" - Name # Evaluate every # Conditions WHEN "AVg ()" OF "query(A,10s,now)" IS ABOVE "90" - WHEN # -is ABOVE # Trigger an alarm WHEN the value IS greater than 90. Notifications Send to "Notifications alarm group "Message"Copy the code

Configuring an Alarm Group

  • ‘Alerting’ –> ‘Notification channels’ –> ‘New channel’

Email alerts

NAME Notifications Alarm group NAME Type Email Address Email address to be sent Optional Email Settings []Single Email # Send an Email to all recipients Notification Settings []Default # Set this Notification as the Default []Include image # Capture the image and Include it in the Notification []Disable Resolve Message # Disable parsed messages sent when the alert status returns to false. [OK] []Send Reminders # Silent configuration to set how often alarms should be sentCopy the code

DINGDING alarm

  1. Create an alarm group in the alarm group
  2. “Group Settings” –> “Smart Group Assistant” –> “Add Robot” –> “Webhook Robot”
  3. Mandatory With security Settings, you can select the GRAFana IP address segment, the custom keyword selected in the example, and the Alarm in the alarm group name of the Notifications keyword.
  4. After adding a robot, it will give a Webhook address, do not disclose
NAME Notifications alarm group NAME Type DingDing Url Webhook address Optional Email Settings []Message Type # Currently only Link Notification is supported Settings []Default # Set this notification to Default []Include image # Capture the image and Include it in the notification []Disable Resolve Message # Disable the resolution Message sent when the alert status returns false [OK] []Send Reminders # Set reminders at intervalsCopy the code