Question for "summary_table_fields" and "aggregation " #1695
Unanswered
dsj27zhangfuxin
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The recommended process for developers to perform testing like this is to have a separate WorkWeChat account dedicated to dev/test/staging. Trying to swap out the alerter type prior to production is inefficient and prone to failure. I don't think the For future posts please use backticks to enclose code like I have done in this response. See #11 for more information on forum guideliness. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Due to certain reasons, I can only develop on the internal network, so when testing, I used the local svc, which provides services through the Java-written post2 webapp alert receiving channel. However, when this rule is actually used, it will adopt the workwechat bot method. So my current dilemma is that the test cases I wrote are for post2, but post2 cannot support aggregated tables and unified sending of aggregated summaries. In the source code of the post2 alert system, I saw a comment stating that each match in matches will be sent individually via post. However, the post2 source code does not call the create_alert_body method, making it impossible to obtain the aggregated table from the payload (I am not sure if my understanding is correct; if not, I hope you can correct me). Therefore, the testing phase is like blind men touching an elephant, and I have written a version of the workwechat alert. If there are any errors, I hope you can point them out.
The display method I want to achieve now is: to show the summary table at the top of the alert information, and then separate it with "------", listing the detailed information of each alert.
However, since I have many log matching fields, I only want to display the queryHash, time, and durationMillis fields in each detail. I'm not sure if the "alert_text" I wrote can achieve this purpose.
Yeastday,I have read the code of workwechat.py and found that it aggregates the table and each specific piece of data in the create_alert_body() method to form a "body".
So I would like to ask if my way of writing alert_text can achieve the expected effect?
myRule
name: "mongo"
type: any
index: filebeat*
realert:
minutes: 5
aggregation:
minutes: 5
filter:
- query:
bool:
must:
- match_phrase:
message: "Slow query"
- term:
kubernetes.container.name: "mongod"
alert:
- "workwechat"
work_wechat_msgtype: "markdown"
work_wechat_bot_id: "******"
alert_text_type: alert_text_jinja
alert_text: |
mongodb_slow_query_alert!
queryHash: {{queryHash}}
time: {{'@timestamp'}}
durationMillis: {{durationMillis}}
summary_prefix: |
MongoDB-Slow-Query-summaryTable
summary-time: {{ aggregation.minutes }} min
alert-time: {{ '@timestamp' }}
num-events: {{ num_matches }}
summary_table_fields:
- kubernetes.container.name
- queryHash
- num_matches
- keysExamined
- docsExamined
- nMatched
- nModified
- keysDeleted
- ndeleted
- nreturned
- durationMillis
summary_table_max_rows: 30
summary_table_type: "markdown"
sorry for some "Space" display in the rule.yaml.
Beta Was this translation helpful? Give feedback.
All reactions