Grafana学习(9)—— Alerting - Alerting on numeric data

发布时间 2023-11-22 15:54:53作者: 钱塘江畔
This topic describes how Grafana managed alerts are evaluated by the backend engine as well as how Grafana handles alerting on numeric rather than time series data.

本主题介绍Grafana管理的警报如何由后端引擎评估,以及Grafana如何处理数字而非时间序列数据的警报。

Alert evaluation
Grafana managed alerts query the following backend data sources that have alerting enabled:

built-in data sources or those developed and maintained by Grafana: Graphite, Prometheus, Loki, InfluxDB, Elasticsearch, Google Cloud Monitoring, Cloudwatch, Azure Monitor, MySQL, PostgreSQL, MSSQL, OpenTSDB, Oracle, and Azure Monitor
community developed backend data sources with alerting enabled (backend and alerting properties are set in the plugin.json

警报评估
Grafana管理的警报查询以下启用了警报的后端数据源:

  • 内置数据源或Grafana开发和维护的数据源:Graphite、Prometheus、Loki、InfluxDB、Elasticsearch、Google Cloud Monitoring、Cloudwatch、Azure Monitor、MySQL、PostgreSQL、MSSQL、OpenTSDB、Oracle和Azure Monitor
  • 社区开发的启用了警报的后端数据源(后端和警报属性在plugin.json中设置)
Metrics from the alerting engine
The alerting engine publishes some internal metrics about itself. You can read more about how Grafana publishes internal metrics.

警报引擎发布一些关于其自身的内部指标。您可以阅读更多关于Grafana如何发布内部指标的信息。

Metric Name Type Description
grafana_alerting_alerts gauge How many alerts by state
grafana_alerting_request_duration histogram Histogram of requests to the Alerting API
grafana_alerting_active_configurations gauge The number of active, non default Alertmanager configurations for grafana managed alerts
grafana_alerting_rule_evaluations_total counter The total number of rule evaluations
grafana_alerting_rule_evaluation_failures_total counter The total number of rule evaluation failures
grafana_alerting_rule_evaluation_duration summary The duration for a rule to execute
grafana_alerting_rule_group_rules gauge The number of rules
Alerting on numeric data
Among certain data sources numeric data that is not time series can be directly alerted on, or passed into Server Side Expressions (SSE). This allows for more processing and resulting efficiency within the data source, and it can also simplify alert rules. When alerting on numeric data instead of time series data, there is no need to reduce each labeled time series into a single number. Instead labeled numbers are returned to Grafana instead.

数字数据报警

  • 在某些数据源中,可以直接向非时间序列的数字数据发出警报,或将其传递到服务器端表达式(SSE)中。这允许在数据源中进行更高的处理效率,还可以简化警报规则。当对数字数据而不是时间序列数据发出警报时,无需将每个标记的时间序列reduce为单个数字。相反,labeled 的数字会返回给Grafana。
Tabular Data
This feature is supported with backend data sources that query tabular data:

SQL data sources such as MySQL, Postgres, MSSQL, and Oracle.
The Azure Kusto based services: Azure Monitor (Logs), Azure Monitor (Azure Resource Graph), and Azure Data Explorer.
A query with Grafana managed alerts or SSE is considered numeric with these data sources, if:

The “Format AS” option is set to “Table” in the data source query.
The table response returned to Grafana from the query includes only one numeric (e.g. int, double, float) column, and optionally additional string columns.
If there are string columns then those columns become labels. The name of column becomes the label name, and the value for each row becomes the value of the corresponding label. If multiple rows are returned, then each row should be uniquely identified their labels.

表格数据
查询表格数据的后端数据源支持此功能:

  • SQL数据源,如MySQL、Postgres、MSSQL和Oracle。
  • 基于Azure Kusto的服务:Azure Monitor(日志)、Azure Monitor(Azure资源图)和Azure Data Explorer。
    具有Grafana管理警报或SSE的查询在以下情况下被视为具有这些数据源的数字查询:
  • 在数据源查询中,“Format AS”选项设置为“Table”。
  • 从查询返回给Grafana的表响应只包括一个数字列(例如int、double、float),以及可选的其他字符串列。
    如果存在字符串列,则这些列将成为标签。列的名称变为标签名称,每行的值变为相应标签的值。如果返回了多行,则每一行都应唯一标识其标签。