添加对注释查询的支持
您可以为您的插件添加对注释查询的支持,这些查询会将信息插入到 Grafana 警报中。本指南解释了如何向数据源插件添加对注释查询的支持。
在数据源插件中支持注释查询
要启用注释,只需在插件中添加两行代码。Grafana 使用您的默认查询编辑器编辑注释查询。
-
在 plugin.json 文件中添加
"annotations": true
,让 Grafana 知道您的插件支持注释。src/plugin.json{
"annotations": true
} -
在
datasource.ts
中,覆盖DataSourceApi
(或后端数据源的DataSourceWithBackend
)中的annotations
属性。对于默认行为,将annotations
设置为空对象。src/datasource.tsannotations: {
}