【问题标题】:Google Cloud Monitoring - Get uptime check current status谷歌云监控 - 获取正常运行时间检查当前状态
【发布时间】:2020-10-05 15:45:26
【问题描述】:

我为我的网站创建了正常运行时间检查。然后,我发现了这个documentation page,它展示了如何使用 C# 提取有关正常运行时间检查的信息。

运行代码后:

public static object GetUptimeCheckConfig(string configName)
{
    var client = UptimeCheckServiceClient.Create();
    UptimeCheckConfig config = client.GetUptimeCheckConfig(configName);
    if (config == null)
    {
        Console.Error.WriteLine(
            "No configuration found with the name {0}", configName);
        return -1;
    }
    Console.WriteLine("Name: {0}", config.Name);
    Console.WriteLine("Display Name: {0}", config.DisplayName);
    Console.WriteLine("Http Path: {0}", config.HttpCheck.Path);
    return 0;
}

我发现此方法仅提供有关检查配置的信息。我想获取有关其当前状态的信息(工作良好\损坏)。似乎缺少此信息。

我也试过this REST call helper - 那里也缺少所请求的信息。

这是否可以提取资源的当前健康状态? 或者我需要选择更复杂的方式来提取数据(例如通过 Webhooks)?

【问题讨论】:

  • 当您运行 uptimeCheckConfigs.get API 时,它会显示时间段(执行 Uptime 检查的频率,以秒为单位。)和超时(等待请求完成)等(cloud.google.com/monitoring/api/ref_v3/rest/v3/…)您希望从 API 输出中获得哪些详细信息?
  • 检查间隔和请求超时是在谈论测试的配置。我想获取资源的当前状态,以确定是否可以继续使用。
  • 由于此功能目前不可用,我继续将用例转发给 google 产品团队,并创建了一个功能请求 (issuetracker.google.com/159223294) 供您跟踪问题。如果您对此问题有任何其他 cmet 或疑虑,请随时在此处发布。
  • 感谢您的帮助。没有提供资源状态有点好笑。毕竟,这都是关于:)
  • @No1Lives4您是否尝试过使用 TimeSeries API 来查询您的正常运行时间检查?

标签: google-cloud-platform google-cloud-stackdriver google-cloud-monitoring


【解决方案1】:

来自GCP metrics docs

要监控服务的可用性,请创建正常运行时间检查。这些检查监控 monitoring.googleapis.com/uptime_check/check_passed 指标类型。 如果您的目标是监控服务的可用性,请不要配置提醒政策来跟踪指标类型,例如 compute.googleapis.com/instance/uptime。

然后在uptime check docs:

要使用 API 确定正常运行时间检查的状态,监控指标monitoring.googleapis.com/uptime_check/check_passed。有关详细信息,请参阅 Google Cloud 指标列表。


原答案:

您想使用timeSeries API 而不是GetUptimeCheckConfig

你可以在https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/queryhttps://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/queryAPI explorer 中试用

请求参数:

projects/YOUR_PROJECT_ID

请求正文:

{
  "query": "fetch uptime_url::monitoring.googleapis.com/uptime_check/request_latency | filter check_id = 'YOUR_CHECK_ID' | group_by [checker_location]"
}
  • * 只需确保将 YOUR_PROJECT_ID 和 YOUR_CHECK_ID 替换为实际 ID

【讨论】:

  • 您至少可以使用两个指标:request_latencycheck_passed,选择一个适合您的指标
猜你喜欢
  • 1970-01-01
  • 2019-10-24
  • 1970-01-01
  • 1970-01-01
  • 2019-07-30
  • 1970-01-01
  • 2015-06-01
  • 1970-01-01
  • 2021-05-24
相关资源
最近更新 更多