3
votes

I created an uptime check for my website. Then, I found this documentation page that shows how to extract information regarding the uptime check with C#.

After running the code:

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;
}

I found that this method provides information only about the configuration of the check. I want to get information about its current status (working good \ broken). Seems like this information is missing.

I also tried this REST call helper - the requested information is missing there too.

Is this possible to extract the current health status of the resource? Or I need to choose a more complex way to extract the data (e.g. via Webhooks)?

1
When you run the uptimeCheckConfigs.get API, it will show you the period (How often, in seconds, the Uptime check is performed.) and the timeout (the maximum amount of time to wait for the request to complete) and etc. (cloud.google.com/monitoring/api/ref_v3/rest/v3/…) which details do you want from the API output? - Kamelia Y
Checking interval and request timeout is talking about the configuration of the test. I want to get the current status of the resource in order to determine whether I can continue to use it or not. - No1Lives4Ever
Since this feature is not available at this moment, I went ahead and forwarded the use case to the google product team and also created a Feature request (issuetracker.google.com/159223294) for you to track the issue. Feel free to post there should you have any additional comments or concerns regarding the issue. - Kamelia Y
Thanks for the help. It's a little bit funny that the resource status is not provided. After all, this is all about :) - No1Lives4Ever
@No1Lives4Ever had you tried using TimeSeries API to query your uptime check ? - c69

1 Answers

2
votes

From GCP metrics docs:

To monitor the availability of a service, create an uptime check. These checks monitor the monitoring.googleapis.com/uptime_check/check_passed metric type. Don't configure an alerting policy to track a metric type such as compute.googleapis.com/instance/uptime if your goal is to monitor the availability of a service.

And then at uptime check docs:

To determine the status of your uptime checks using the API, monitor the metric monitoring.googleapis.com/uptime_check/check_passed. See Google Cloud metrics list for details.


Original answer:

Instead of GetUptimeCheckConfig you want to use timeSeries API.

You can try it in API explorer at https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/query

Request args:

projects/YOUR_PROJECT_ID

Request body:

{
  "query": "fetch uptime_url::monitoring.googleapis.com/uptime_check/request_latency | filter check_id = 'YOUR_CHECK_ID' | group_by [checker_location]"
}
  • * just make sure you replace YOUR_PROJECT_ID and YOUR_CHECK_ID with actual ids