当前位置: 首页 > 面试题库 >

自定义elastalert插件收到的用于Elasticsearch的警报中的信息

华献
2023-03-14
问题内容

我已经用我的elasticsearch主机配置了elastalert实例。我还创建了一个示例规则,该规则将检查日志级别并在日志中匹配该模式时发出警报。

一切正常,我可以在我的闲置频道上正确收到警报。

唯一关心的是我收到的警报中的信息/数据
。elastalert插件正在发送与我正在寻找的模式相关的所有属性;但我对所有信息都不感兴趣。我只关心某些特定属性。

这是我的规则的一个示例:

# Alert when the rate of events exceeds a threshold

# (Optional)
# Elasticsearch host
 es_host:

# (Optional)
# Elasticsearch port
 es_port:

# (OptionaL) Connect with SSL to elasticsearch
#use_ssl: True

# (Optional) basic-auth username and password for elasticsearch
#es_username: someusername
#es_password: somepassword

# (Required)
# Rule name, must be unique
 name: DB2 test Rule

# (Required)
# Type of alert.
# the frequency rule type alerts when num_events events occur with timeframe time
 type: frequency

# (Required)
# Index to search, wildcard supported
 index: logstash-* # logstash-2016.04.05 #logstash-YYYY.MM.DD # logstash-*

# (Required, frequency specific)
# Alert when this many documents matching the query occur within a timeframe
 num_events: 1

# (Required, frequency specific)
# num_events must occur within this amount of time to trigger an alert
 timeframe:
  hours: 12

# (Required)
# A list of elasticsearch filters used for find events
# These filters are joined with AND and nested in a filtered query
# For more info: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html
 filter:
 - query:
    query_string:
      query: "type: db2 AND logLevel: Warning"

# (Required)
# The alert is use when a match is found
 alert:
 - "slack"
 slack:
 slack_webhook_url: "XYZ"

我在闲置频道上收到的警报如下所示:

DB2 test Rule
DB2 test Rule

At least 1 events occurred between 2016-04-29 07:51 UTC and 2016-04-29 19:51 UTC

@timestamp: 2016-04-29T19:51:45.940Z
@version: 1
_id: 
_index: logstash-2016.04.29
_type: db2
apphdl: 
appid: 
authid: 
day: 29
db: NEO
eduid: 
eduname: 
function: 
host: 
hostname: 
hour: 14
id: 
instance: 
logLevel: Warning
logMessage: 
LOADID: 
DATA #2 : 
Completed 
message:       LEVEL: Warning

和ETC ETC …

我想自定义此警报消息,以便它仅用我关心的那些属性来警报我。 (有关前时间表,日志级别和更多其他信息。)

有没有办法做到这一点?非常感谢您的帮助或指导。


问题答案:

根据ElastAlert文档,您可以使用将警报限制为仅包含文档中的某些字段include

您的情况是:

include: ["@timestamp", "logLevel", "message"]


 类似资料:
  • 问题内容: 我使用了一个警告框,以在某些验证后警告某些消息。现在,我要在控件存在验证错误的控件上方放置警报框。 默认情况下,警报框会在页面中心弹出,现在我希望它在某个自定义位置,例如,我有4个要验证的文本框,文本框3有一些不正确的数据,我希望警报显示在上方textbox-3,而不是页面的中心。 是否可以更改警报框的显示行为?如果没有其他选择,则进入jquery对话框。 问题答案: 由于这是默认对话

  • 问题内容: 我正在编写Java客户端(在weblogic 10.3上)以调用安全的Web服务。我已获得安装在cacerts,DemoIdentity.jks和DemoTrust,jks中的客户端证书。在我的Weblogic中,我已将密钥库设置为DemoIdentity和DemoTrust。在weblogic控制台中,我已将“双向客户端证书行为:”设置为“已请求但未强制执行的客户端证书”。对于“启用

  • 我正在尝试创建一个自定义任务/插件(两者都拒绝工作),用于我的gradle构建脚本。 我正在使用groovy插件,希望在单独的文件中声明任务/插件,而不是在我的构建中。格拉德尔。 我的项目树如下所示: 我试图做的是在中创建我的任务/插件类,然后在。 让我举一个小例子。 TestTask。groovy: build.gradle 当我尝试使用我的gradle.build(清洁,构建等)做任何事情时,

  • 我在Project中创建了一个简单的gradle插件。根据文档,它应该是好的,但当我尝试使用它时,我发现id为'show-date-plugin'的文档我指的是:https://docs.gradle.org/current/userguide/custom_plugins.html 您可以将插件的源代码放在rootprojectdir/buildsrc/src/main/groovy目录中。Gr

  • 我正在制作一个应用程序,可以发送特定的短信到用户选择的所有联系人,只需点击按钮。 接收器还将在手机上安装该应用程序。当安装了该应用程序的手机收到该特定短信时,他们会收到报警对话框,并从资产文件夹播放音频。(即使手机已锁定或处于睡眠状态,或应用程序未运行[即使最近的应用程序已清除]) 我已经成功地通过点击向所有choosen联系人发送短信。还可以通过阅读短信来报警。我的问题是,。。。。。只有在应用程

  • 我在使用Gradle api的Gradle自定义插件中工作,需要设置一个始终执行的操作,比如配置任务。 我以这种方式创建了一些任务: 然后添加到项目中: ...这些工作原理是:当我显式调用myWork目标时,它会被执行,但是我需要一个每次都被执行的任务,即使没有显式调用。