简体   繁体   English

谷歌云监控 MQL:一天中的时间

[英]Google Cloud Monitoring MQL: Time of Day

Is it possible to use MQL to include time of day in the alert condition?是否可以使用 MQL 在警报条件中包含一天中的时间?

Basic example in their documentation includes:他们文档中的基本示例包括:

  fetch gce_instance :: compute.googleapis.com/instance/cpu/usage_time
  | rate (5m)
  | condition lt(val(), 0.5's{CPU}/min')

I essentially want to do this:我基本上想这样做:

  fetch gce_instance :: compute.googleapis.com/instance/cpu/usage_time
  | rate (5m)
  | condition lt(val(), 0.5's{CPU}/min') and ( gt(end.time, '06:00:00') and lt(end.time, '18:00:00') )

Obviously that isn't valid, but I'm struggling to put the syntax together for time related functions from their documentation - does anyone know if this is possible?显然这是无效的,但我正在努力从他们的文档中将语法与时间相关的功能放在一起——有人知道这是否可能吗?

I also want this so I can silence alerts during scheduled nightly upgrades.我也想要这个,这样我就可以在预定的夜间升级期间静音警报。 I could not find a way to do it with MQL, but here are some workarounds that might help:我找不到使用 MQL 的方法,但这里有一些可能有帮助的解决方法:

  1. Create a snooze .创建一个小睡 You can select a period of time over which the alert will be silenced.您可以 select 一段时间,在此期间警报将被静音。 Due to its limitations it only works if your quiet period is rare:由于其 局限性,它仅在您的安静期很少见时才有效:
    • You can only create them with the console您只能使用控制台创建它们
    • There is no "recurring snooze," so if you want a daily quiet period then you have to create a snooze every day using the console没有“重复小睡”,所以如果你想要每天安静一段时间,那么你必须每天使用控制台创建一个小睡
  2. Create a cloud scheduler job to enable and disable the alert using the alerting API .创建云调度程序作业以使用警报 API启用和禁用警报

I am trying the API approach.我正在尝试API方法。 The enable/disable calls can be made from my upgrade job, so I don't think I need the scheduler.启用/禁用调用可以从我的升级作业中进行,所以我认为我不需要调度程序。 Here are the steps I used to work this out:以下是我用来解决这个问题的步骤:

  1. List the monitoring policies to get the policy name.列出监控策略以获取策略名称。 Note conditions have names too.注意条件也有名称。 You want the policy name, not the condition name :您需要策略名称,而不是条件名称
     gcloud alpha monitoring policies list
  2. Disable/enable the policy:禁用/启用策略:
     gcloud alpha monitoring policies update projects/<project-name>/alertPolicies/<policy-id> --no-enabled # Do my upgrade... gcloud alpha monitoring policies update projects/<project-name>/alertPolicies/<policy-id> --enabled

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

相关问题 有谷歌云综合监控方案吗 - Is there a Google cloud synthetic monitoring solution 谷歌云监控未触发事件 - google cloud monitoring not triggerd incident 是否有谷歌云真实用户监控 (RUM) 解决方案? - Is there a Google cloud Real user monitoring (RUM) solution? 用于监控谷歌云发布/订阅的 Stackdriver 延迟 - Stackdriver latency for monitoring google cloud pub/sub 我如何通过 MQL 在累积持续时间指标上 plot 将 Opentelemetry 数据导出到 Google Monitoring - How do I plot the gPRC error ratio via MQL on a Cumulative duration metric with Opentelemetry data exported to Google Monitoring 如何通过 Google Cloud Monitoring Alerting 向 Discord 频道发送通知 - How to send notifications to Discord channel by Google Cloud Monitoring Alerting 有没有办法通过 API 获取 Google Cloud Monitoring 事件指标? - Is there a way to fetch Google Cloud Monitoring Incident metrics via the API? 如何使用 IAM 用户对 Google Cloud Storage Bucket 进行日志记录和监控 - how to do Logging & Monitoring on Google Cloud Storage Buckets with IAM user 在 GCP 的 MQL(监控查询语言)中将双精度格式格式化为字符串 - Format double to string in MQL (Monitoring Query Language) in GCP GCP | 云监控 | 如何对项目进行分组以在 Cloud Monitoring 信息中心上显示? - GCP | Cloud Monitoring | How to group projects for display on Cloud Monitoring Dashboard?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM