Mehul Gupta
Mehul Gupta

Reputation: 15

What should be the format of interval in google cloud monitoring api

I want to fetch cpu usage time for an instance deployed in google cloud platform in python and I am unable to write the interval field properly to get values, here's the API call code, what should be the proper format of interval and if possible an example would help me a lot.

    results = client.list_time_series(
    request={
        "name": project_name,
        "filter": 'metric.type = "compute.googleapis.com/instance/cpu/usage_time"',
        "interval": interval,
        "view": monitoring_v3.ListTimeSeriesRequest.TimeSeriesView.FULL,
    }
)

Upvotes: 0

Views: 945

Answers (1)

DazWilkin
DazWilkin

Reputation: 40091

APIs Explorer is your friend.

Find Monitoring v3 then the projects.timeSeries.list method that corresponds to your Python method.

You can see that interval is defined to be a TimeInterval which has startTime and endTime properties in RFC3339 format.

APIs Explorer provides a way to invoke the method by completing the form on the right hand side. The form will also provide the curl equivalent which is helpful for testing.

Upvotes: 3

Related Questions