Flashduty Docs
中文English
RoadmapAPI官网控制台
中文English
RoadmapAPI官网控制台
  1. Alert Rules
  • Introduction
  • On-call
    • Getting Started
      • Quick start
      • FAQ
      • Product Comparison
    • Incidents
      • What is an Incident
      • View Incidents
      • Handle Incidents
      • Escalations and Assignments
      • Custom Fields
      • Custom Actions
      • Alert Noise Reduction
      • Past Incidents
      • Outlier Incidents
      • Status Pages
    • Configure On-call
      • Channels
      • Integrate Alerts
      • Alert Noise Reduction
      • Escalation Rules
      • Label Enrichment
      • Schedules
      • Templates
      • Service Calendars
      • Preferences
      • Alert Routing
      • Silence and Inhibition
      • Filters
      • Notifications
      • Alert Pipeline
    • Advanced Features
      • Referencing Variables
      • Dynamic Assignment
      • Insights
      • War-room
    • Integrations
      • Alerts integration
        • Standard Alert Integration
        • Email Integration
        • Nightingale/FlashCat Integration
        • Prometheus Integration
        • Grafana Integration
        • Zabbix Integration
        • Uptime Kuma Integration
        • Alibaba Cloud ARMS Integration
        • Alibaba Cloud Monitor CM Event Integration
        • Alibaba Cloud Monitor CM Metrics Integration
        • Alibaba Cloud SLS Integration
        • AWS CloudWatch Integration
        • Azure Monitor Integration
        • Baidu Cloud BCM Integration
        • Huawei Cloud CES Integration
        • Influxdata Integration
        • Open Falcon Integration
        • PagerDuty Integration
        • Tencent BlueKing Integration
        • Tencent Cloud CLS Integration
        • Tencent Cloud Monitor CM Integration
        • Tencent Cloud EventBridge
        • OceanBase Integration
        • Graylog Integration
        • Skywalking Integration
        • Sentry Integration
        • Jiankongbao Integration
        • AWS EventBridge Integration
        • Dynatrace Integration
        • Huawei Cloud LTS Integration
        • GCP Integration
        • Splunk Alert Events Integration
        • AppDynamics Alert Integration
        • SolarWinds Alert Events Integration
        • Volcengine CM Alert Events Integration
        • Volcengine CM Event Center Integration
        • Volcengine TLS Integration
        • OpManager Integration
        • Meraki Integration
        • Keep Integration
        • ElastAlert2 Alert Integration
        • StateCloud Alert Events
        • Guance Alert Events
        • Zilliz Alert Events
        • Huawei Cloud APM Alerts
        • zstack integration
        • Monit Alert Integration
        • RUM Alert Integration
      • Change integration
        • Standard Change Event
        • Jira Issue Events
      • IM integration
        • Feishu (Lark) Integration Guide
        • Dingtalk Integration
        • WeCom Integration
        • Slack Integration
        • Microsoft Teams Integration
      • Single Sign-On
        • Authing Integration
        • Keycloak Guide
        • OpenLDAP Guide
      • Webhooks
        • Alert webhook
        • Incident webhook
        • Costom action
        • ServiceNow Sync
        • Jira Sync
      • Other
        • Link Integration
  • RUM
    • Getting Started
      • Introduction
      • Quick start
      • FAQ
    • Applications
      • Applications
      • SDK Integration
      • Advanced Configuration
      • Analysis Dashboard
    • Performance Monitoring
      • Overview
      • Metrics
      • Performance Analysis
      • Performance Optimize
    • Error Tracking
      • Overview
      • Error Reporting
      • Issues
      • Source Mapping
      • Error Grouping
      • Issue States
      • Issue Alerting
    • Session Explorer
      • Overview
      • Data Query
    • Session Replay
      • View Session Replay
      • Overview
      • SDK Configuration
      • Privacy Protection
    • Best Practice
      • Distributed Tracing
    • Others
      • Terminology
      • Data Collection
      • Data Security
  • Monitors
    • Getting Started
      • Introduction
      • Quick Start
    • FAQ
      • FAQ
    • Alert Rules
      • Prometheus
      • ElasticSearch
      • Loki
      • ClickHouse
      • MySQL
      • Oracle
      • PostgreSQL
      • Aliyun SLS
  • Platform
    • Teams and Members
    • Permissions
    • Single Sign-On
  • Terms
    • Terms of Service
    • User Agreement/Privary Policy
    • SLA
    • Data Security
中文English
RoadmapAPI官网控制台
中文English
RoadmapAPI官网控制台
  1. Alert Rules

MySQL

This document provides detailed instructions on configuring alert rules for MySQL data sources in Monitors. Monitors supports using standard SQL syntax to query MySQL and trigger alerts based on query results.

Core concepts#

Query language: Uses standard MySQL SQL syntax.
Field handling: The alert engine automatically converts all field names in query results to lowercase. When configuring value fields and label fields, always use lowercase letters.
Time handling: It's recommended to use functions like now(), unix_timestamp() in SQL for time range filtering to leverage indexes and improve query efficiency.

1. Threshold mode#

This mode is suitable for scenarios requiring threshold comparisons on aggregated values.

Configuration#

1.
Query: Write a SQL aggregation query that returns numeric columns and (optional) label columns.
Example: Count error logs per service in the last 5 minutes (assuming there's a log table).
2.
Field mapping:
Label fields: Fields used to distinguish different alert objects. In the example above, this is service_name. This field can be left empty, and Monitors will automatically treat all fields except value fields as label fields.
Value fields: Numeric fields used for threshold evaluation. In the example above, this is error_cnt.
3.
Threshold conditions:
Use $A.field_name to reference values.
Example: Critical: $A.error_cnt > 50, Warning: $A.error_cnt > 10.

How it works#

The engine executes the SQL query and retrieves the result set. It groups data by label fields, then extracts value field values for comparison against threshold expressions.

Recovery logic#

Auto recovery: When the latest SQL query result shows that a data group's value no longer meets any alert threshold, a recovery event is automatically generated.
Specific recovery conditions: Configure additional recovery expressions (e.g., $A.error_cnt < 5).
Recovery query:
Supports configuring an independent SQL statement for recovery evaluation.
Supports ${label_name} variable substitution.
Example:
The engine replaces ${network_host} and ${interface} with actual values before executing the query. If data is found, recovery is confirmed.

2. Data exists mode#

This mode is suitable for scenarios where filtering logic is written directly in SQL.

Configuration#

1.
Query: Use a HAVING clause in SQL to directly filter out anomalous data.
Example: Directly query services with more than 50 errors.
2.
Evaluation rule: An alert is triggered as soon as the SQL query returns data (Result Set is not empty).

Pros and cons#

Pros: Leverages MySQL database computing power for filtering, reducing network transmission.
Cons: Cannot distinguish between multiple severity levels.

Recovery logic#

Data disappearance means recovery: Recovery is confirmed when the SQL query result is empty.
Recovery query: Supports configuring additional query statements to assist in determining recovery status.

3. No data mode#

This mode monitors scenarios where data is expected but actually missing.

Configuration#

1.
Query: Write a SQL query that should continuously return data.
Example: Query heartbeat reports from all probes.
2.
Evaluation rule: If a probe_id appeared in previous cycles but cannot be found in the current and N consecutive cycles, a "no data" alert is triggered.

4. Best practices and considerations#

Index optimization#

Always include time range filtering in the WHERE clause and ensure there's an index on the time field. Otherwise, it may cause full table scans and affect database performance.
Recommended: log_time > now() - INTERVAL 5 MINUTE.

Field case sensitivity#

Monitors engine converts column names returned by MySQL to lowercase.
Configuration: Always use lowercase letters when filling in label fields and value fields.

添加官方技术支持微信

在这里,获得使用上的任何帮助,快速上手FlashDuty

微信扫码交流
修改于 2025-12-31 06:14:43
上一页
ClickHouse
下一页
Oracle
Built with