简体   繁体   English

谷歌云平台——创建警报策略——如何在警报文档降价中指定消息变量?

[英]google cloud platform -- creating alert policy -- how to specify message variable in alerting documentation markdown?

So I've created a logging alert policy on google cloud that monitors the project's logs and sends an alert if it finds a log that matches a certain query.因此,我在 google cloud 上创建了一个日志警报策略,用于监控项目的日志并在发现与特定查询匹配的日志时发送警报。 This is all good and fine, but whenever it does send an email alert, it's barebones.这一切都很好,但只要它确实发送电子邮件警报,它就是准系统。 I am unable to include anything useful in the email alert such as the actual message, the user must instead click on "View incident" and go to the specified timeframe of when the alert happened.我无法在电子邮件警报中包含任何有用的信息,例如实际消息,用户必须改为单击“查看事件”并转到警报发生时的指定时间范围。

Is there no way to include the message?没有办法包含消息吗? As far as I can tell viewing the gcp Using Markdown and variables in documentation templates doc on this.据我所知查看 gcp Using Markdown and variables in documentation templates doc on this。

I'm only really able to use ${resource.label.x} which isn't really all that useful because it already includes most of that stuff by default in the alert.我只能真正使用${resource.label.x}这并不是那么有用,因为默认情况下它已经在警报中包含了大部分内容。

Could I have something like ${jsonPayload.message} ?我可以有类似${jsonPayload.message}的东西吗? It didn't work when I tried it.当我尝试时它没有用。

Probably (!) not.可能不是。

To be clear, the alerting policies track metrics (not logs) and you've created a log-based metric that you're using as the basis for an alert.需要明确的是,警报策略跟踪指标(而不是日志),并且您已经创建了一个基于日志的指标,您将其用作警报的基础。

There's information loss between the underlying log (that contains eg jsonPayload ) and the metric that's produced from it (which probably does not).底层日志(包含例如jsonPayload )和由此产生的指标(可能没有)之间存在信息丢失。 You can createLog-based metrics labels using expressions that include the underlying log entry fields.可以使用包含基础日志条目字段的表达式创建基于日志的指标标签

However, per the example in Google's docs, you'd want to consider a limited (enum) type for these values (eg HTTP status although that may be too broad too) rather than a potentially infinite jsonPayload .但是,根据 Google 文档中的示例,您需要考虑这些值的有限(枚举)类型(例如 HTTP 状态,尽管它也可能过于宽泛),而不是可能无限的jsonPayload

It is possible.有可能的。 Suppose you need to pass "jsonPayload.message" present in your GCP log to documentation section in your policy.假设您需要将 GCP 日志中存在的“jsonPayload.message”传递到策略中的文档部分。 You need to use "label_extractor" feature to extract your log message.您需要使用“label_extractor”功能来提取您的日志消息。

I will share a policy creation json file template wherein you can pass "jsonPayload.message" in the documentation section in your policy.我将分享一个策略创建 json 文件模板,您可以在其中在策略的文档部分传递“jsonPayload.message”。

policy_json = {
"display_name": "<policy_name>",
"documentation": {
"content": "I have the extracted the log message:${log.extracted_label.msg}",
"mime_type": "text/markdown"
},
"user_labels": {},
"conditions": [
{
"display_name": "<condition_name>",
"condition_matched_log": {
"filter": "<filter_condition>",
"label_extractors": {
"msg": "EXTRACT(jsonPayload.message)",
}
}
}
],
"alert_strategy": {
"notification_rate_limit": {
"period": "300s"
},
"auto_close": "604800s"
},
"combiner": "OR",
"enabled": True,
"notification_channels": [
"<notification_channel>"
]
}

Hope it helps..希望能帮助到你..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 云监控创建告警策略时阈值字段是什么意思? - What is the meaning of the Threshold value field when creating an Alerting policy in Cloud Monitoring? 如何通过 Google Cloud Monitoring Alerting 向 Discord 频道发送通知 - How to send notifications to Discord channel by Google Cloud Monitoring Alerting Google Cloud Platform:秘密作为构建环境变量 - Google Cloud Platform: secret as build env variable 如何为失败的 Dataproc Batch 配置警报策略? - How to configure an alerting policy for failed Dataproc Batch? 如何在Google Cloud Platform中安装Google AI Platform中的Spark依赖 - How to install Spark dependencies in Google AI Platform in Google Cloud Platform 在 Google Cloud Platform (GCP) 上创建 SLURM 集群未完成安装 - Creating a SLURM cluster on the Google Cloud Platform (GCP) does not complete installation 如何在 APIGee 的分配消息策略中读取变量 - how to read variable in assign message policy in APIGee 谷歌云 SDK 文档 - Google Cloud SDK documentation 谷歌云平台中的身份验证 - Authentication in Google Cloud Platform 如何禁用谷歌云平台集成? - How to disable Google Cloud Platform integration?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM