Skip to content

Instantly share code, notes, and snippets.

@thagomizer
Created May 11, 2017 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thagomizer/d34cc4d375578f4b8f2c8d8b4de7eb38 to your computer and use it in GitHub Desktop.
Save thagomizer/d34cc4d375578f4b8f2c8d8b4de7eb38 to your computer and use it in GitHub Desktop.
require "google/cloud/monitoring/v3/metric_service_client"
client = Google::Cloud::Monitoring::V3::MetricServiceClient.new
project = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path(PROJECT_ID)
metric = "appengine.googleapis.com/system/memory/usage"
end_time = Time.now.to_i
start_time = end_time - (60 * 10) # 10 minutes
filter = "metric.type = \"#{metric}\""
interval = Google::Monitoring::V3::TimeInterval.new
interval.start_time = Google::Protobuf::Timestamp.new(seconds: start_time)
interval.end_time = Google::Protobuf::Timestamp.new(seconds: end_time)
view = Google::Monitoring::V3::ListTimeSeriesRequest::TimeSeriesView::FULL
time_series = client.list_time_series(project, filter, interval, view)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment