文档文档

无状态 ADTK 检测器插件

ADTK 异常检测器插件利用 ADTK (Anomaly Detection Toolkit) 库为 InfluxDB 3 提供高级时间序列异常检测。应用基于统计和机器学习的检测方法,以识别数据中的异常值、级别偏移、波动性变化和季节性异常。其特点是基于共识的检测,要求多个检测器在触发警报前达成一致,从而减少误报。

配置

必需参数

参数类型默认描述
measurementstring必需要分析异常的测量值
字段string必需要评估的数值字段
detectorsstring必需点分隔的 ADTK 检测器列表
detector_paramsstring必需每个检测器的 Base64 编码的 JSON 参数
windowstring必需数据分析窗口。格式:<number><unit>
sendersstring必需点分隔的通知通道

高级参数

参数类型默认描述
min_consensus数字1标记异常所需的最小达成一致的检测器数量
min_condition_durationstring“0s”异常持久性的最小持续时间

通知参数

参数类型默认描述
influxdb3_auth_tokenstringenv varInfluxDB 3 API 令牌
notification_textstringtemplate自定义通知消息模板
notification_pathstring“notify”通知终结点路径
port_override数字8181InfluxDB 端口覆盖
config_file_pathstringnone相对于 PLUGIN_DIR 的 TOML 配置文件路径

支持的 ADTK 检测器

检测器描述必需参数
InterQuartileRangeAD使用 IQR 方法检测异常值None
ThresholdAD检测高于/低于阈值的值high, low (可选)
QuantileAD基于分位数检测异常值low, high (可选)
LevelShiftAD检测突然的级别变化window (int)
VolatilityShiftAD检测波动性变化window (int)
PersistAD检测持续存在的异常值None
SeasonalAD检测季节性模式偏差None

TOML 配置

参数类型默认描述
config_file_pathstringnone相对于 PLUGIN_DIR 的 TOML 配置文件路径 (TOML 配置必需)

要使用 TOML 配置文件,请设置 PLUGIN_DIR 环境变量并在触发器参数中指定 config_file_path 这与启动 InfluxDB 3 时的 --plugin-dir 标志是附加的。

示例 TOML 配置

adtk_anomaly_config_scheduler.toml

有关使用 TOML 配置文件,请参阅 influxdb3_plugins /README.md 中的“使用 TOML 配置文件”部分。

安装

  1. 启用处理引擎来启动 InfluxDB 3 核心(--plugin-dir /path/to/plugins

  2. 安装必需的 Python 包

    • requests(用于 HTTP 请求)
    • adtk (用于异常检测)
    • pandas (用于数据操作)
    influxdb3 install package requests
    influxdb3 install package adtk
    influxdb3 install package pandas

创建触发器

创建用于异常检测的计划触发器

influxdb3 create trigger \
  --database mydb \
  --plugin-filename adtk_anomaly_detection_plugin.py \
  --trigger-spec "every:10m" \
  --trigger-arguments "measurement=cpu,field=usage,detectors=QuantileAD.LevelShiftAD,detector_params=eyJRdWFudGlsZUFKIjogeyJsb3ciOiAwLjA1LCAiaGlnaCI6IDAuOTV9LCAiTGV2ZWxTaGlmdEFKIjogeyJ3aW5kb3ciOiA1fX0=,window=10m,senders=slack,slack_webhook_url=https://hooks.slack.com/services/..." \
  anomaly_detector

启用触发器

influxdb3 enable trigger --database mydb anomaly_detector

示例

基本异常检测

使用基于分位数的方法检测异常值

# Base64 encode detector parameters: {"QuantileAD": {"low": 0.05, "high": 0.95}}
echo '{"QuantileAD": {"low": 0.05, "high": 0.95}}' | base64

influxdb3 create trigger \
  --database sensors \
  --plugin-filename adtk_anomaly_detection_plugin.py \
  --trigger-spec "every:5m" \
  --trigger-arguments "measurement=temperature,field=value,detectors=QuantileAD,detector_params=eyJRdWFudGlsZUFKIjogeyJsb3ciOiAwLjA1LCAiaGlnaCI6IDAuOTV9fQ==,window=1h,senders=slack,slack_webhook_url=https://hooks.slack.com/services/..." \
  temp_anomaly_detector

多检测器共识

使用具有共识要求的多个检测器

# Base64 encode: {"QuantileAD": {"low": 0.1, "high": 0.9}, "LevelShiftAD": {"window": 10}}
echo '{"QuantileAD": {"low": 0.1, "high": 0.9}, "LevelShiftAD": {"window": 10}}' | base64

influxdb3 create trigger \
  --database monitoring \
  --plugin-filename adtk_anomaly_detection_plugin.py \
  --trigger-spec "every:15m" \
  --trigger-arguments "measurement=cpu_metrics,field=utilization,detectors=QuantileAD.LevelShiftAD,detector_params=eyJRdWFudGlsZUFEIjogeyJsb3ciOiAwLjEsICJoaWdoIjogMC45fSwgIkxldmVsU2hpZnRBRCI6IHsid2luZG93IjogMTB9fQ==,min_consensus=2,window=30m,senders=discord,discord_webhook_url=https://discord.com/api/webhooks/..." \
  cpu_consensus_detector

波动性偏移检测

监控数据波动性的突然变化

# Base64 encode: {"VolatilityShiftAD": {"window": 20}}
echo '{"VolatilityShiftAD": {"window": 20}}' | base64

influxdb3 create trigger \
  --database trading \
  --plugin-filename adtk_anomaly_detection_plugin.py \
  --trigger-spec "every:1m" \
  --trigger-arguments "measurement=stock_prices,field=price,detectors=VolatilityShiftAD,detector_params=eyJWb2xhdGlsaXR5U2hpZnRBRCI6IHsid2luZG93IjogMjB9fQ==,window=1h,min_condition_duration=5m,senders=sms,twilio_from_number=+1234567890,twilio_to_number=+0987654321" \
  volatility_detector

新功能

  • 高级检测方法:多种 ADTK 检测器用于不同类型的异常
  • 基于共识的过滤:通过多检测器一致性减少误报
  • 可配置的持久性:要求异常在发出警报前持续存在
  • 多渠道通知:与各种通知渠道集成
  • 模板消息:带有动态变量的可自定义通知模板
  • 灵活调度:可配置的检测间隔和时间窗口

故障排除

常见问题

检测器参数编码

  • 确保 detector_params 是有效的 Base64 编码的 JSON
  • 使用命令行 Base64 编码:echo '{"QuantileAD": {"low": 0.05}}' | base64
  • 验证 JSON 结构是否符合检测器要求

误报通知

  • 增加 min_consensus 以要求更多检测器达成一致
  • 添加 min_condition_duration 以要求异常持续存在
  • detector_params 中调整特定于检测器的阈值

缺失的依赖项

  • 安装必需的包:adtk, pandas, requests
  • 确保已安装 Notifier 插件以进行通知

数据质量问题

  • 验证指定窗口内是否有足够的数据点
  • 检查会影响检测的空值或数据间隙
  • 确保字段包含适合分析的数值数据

Base64 参数编码

生成正确编码的检测器参数

# Single detector
echo '{"QuantileAD": {"low": 0.05, "high": 0.95}}' | base64 -w 0

# Multiple detectors
echo '{"QuantileAD": {"low": 0.1, "high": 0.9}, "LevelShiftAD": {"window": 15}}' | base64 -w 0

# Threshold detector
echo '{"ThresholdAD": {"high": 100, "low": 10}}' | base64 -w 0

消息模板变量

通知模板可用变量

  • $table:测量值名称
  • $field:出现异常的字段名
  • $value:异常值
  • $detectors:检测方法列表
  • $tags:标签值
  • $timestamp:异常时间戳

检测器配置参考

有关详细的检测器参数和选项,请参阅 ADTK 文档

报告问题

有关插件问题,请参阅插件存储库的 issues 页面

查找 InfluxDB 3 Core 的支持

InfluxDB Discord 服务器 InfluxDB Discord server 是获取 InfluxDB 3 Core 支持的最佳场所。对于其他 InfluxDB 版本,请参阅 支持和反馈 选项。


此页面是否有帮助?

感谢您的反馈!


InfluxDB 3.8 新特性

InfluxDB 3.8 和 InfluxDB 3 Explorer 1.6 的主要增强功能。

查看博客文章

InfluxDB 3.8 现已适用于 Core 和 Enterprise 版本,同时发布了 InfluxDB 3 Explorer UI 的 1.6 版本。本次发布着重于操作成熟度,以及如何更轻松地部署、管理和可靠地运行 InfluxDB。

更多信息,请查看

InfluxDB Docker 的 latest 标签将指向 InfluxDB 3 Core

在 **2026 年 2 月 3 日**,InfluxDB Docker 镜像的 latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。

如果使用 Docker 来安装和运行 InfluxDB,latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。例如,如果使用 Docker 运行 InfluxDB v2,请将 latest 版本标签替换为 Docker pull 命令中的特定版本标签 — 例如

docker pull influxdb:2