@@ -354,6 +354,51 @@ def wake_up(self, version_id=None):
354354 "versionId" : version_id
355355 })
356356
357+ def get_metrics_series (self , from_timestamp_ms = None , to_timestamp_ms = None , aggregation = "MINUTE" , timezone = None ):
358+ """
359+ Get the operational metrics series for this agent.
360+
361+ The returned payload may include the ongoing interval for the requested granularity.
362+ As a consequence, the latest datapoint is temporarily inconsistent and may evolve
363+ as more raw events are flushed and aggregated at read time.
364+ The requested time window is aligned to the bucket boundaries of the selected
365+ aggregation before being read.
366+
367+ :param int from_timestamp_ms: Beginning of the requested window, inclusive, as an
368+ epoch timestamp in milliseconds. The effective lower bound is rounded down
369+ to the start of its bucket. Optional, defaults to the oldest retained
370+ timestamp available for the requested aggregation.
371+ :param int to_timestamp_ms: End of the requested window, exclusive, as an epoch
372+ timestamp in milliseconds. The effective upper bound is rounded up to the
373+ next bucket boundary when it falls inside a bucket.
374+ Optional, defaults to the current time when omitted.
375+ :param str aggregation: Aggregation granularity. Supported values are ``MINUTE``,
376+ ``FIVE_MINUTES``, ``HOUR``, ``DAY`` and ``MONTH``.
377+ :param str timezone: Timezone used to align bucket boundaries. Optional,
378+ defaults to ``UTC``. Can be a timezone name like ``Europe/Paris``.
379+ :return: The list of datapoints. Each datapoint contains a ``timestampMs``
380+ expressed as the start timestamp of its bucket in epoch
381+ milliseconds. For example, with ``HOUR`` aggregation, a datapoint
382+ at ``18:00`` represents the interval ``[18:00, 19:00)``.
383+ :rtype: list[dict]
384+ """
385+ if from_timestamp_ms is not None and not isinstance (from_timestamp_ms , int ):
386+ raise TypeError ("Expected int for from_timestamp_ms, got %s" % type (from_timestamp_ms ).__name__ )
387+ if to_timestamp_ms is not None and not isinstance (to_timestamp_ms , int ):
388+ raise TypeError ("Expected int for to_timestamp_ms, got %s" % type (to_timestamp_ms ).__name__ )
389+ if timezone is not None and not isinstance (timezone , str ):
390+ raise TypeError ("Expected str for timezone, got %s" % type (timezone ).__name__ )
391+
392+ return self .client ._perform_json (
393+ "GET" , "/projects/%s/agents/%s/operational-metrics/series" % (self .project_key , self .id ),
394+ params = {
395+ "fromTimestampMs" : from_timestamp_ms ,
396+ "toTimestampMs" : to_timestamp_ms ,
397+ "aggregation" : aggregation ,
398+ "timezone" : timezone
399+ }
400+ )
401+
357402
358403class DSSAgentSettings (DSSTaggableObjectSettings ):
359404 """
0 commit comments