Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions datadog/api/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

# datadog
from datadog.api.exceptions import ApiError
from datadog.api.resources import SearchableAPIResource, SendableAPIResource
from datadog.api.resources import SearchableAPIResource, SendableAPIResource, ListableAPIResource


class Metric(SearchableAPIResource, SendableAPIResource):
class Metric(SearchableAPIResource, SendableAPIResource, ListableAPIResource):
"""
A wrapper around Metric HTTP API
"""
Expand All @@ -16,6 +16,7 @@ class Metric(SearchableAPIResource, SendableAPIResource):

_METRIC_QUERY_ENDPOINT = '/query'
_METRIC_SUBMIT_ENDPOINT = '/series'
_METRIC_LIST_ENDPOINT = '/metrics'

@classmethod
def _process_points(cls, points):
Expand Down Expand Up @@ -64,6 +65,26 @@ def rec_parse(points_lst):

return rec_parse(points_lst)

@classmethod
def list(cls, from_epoch):
"""
Get a list of active metrics since a given time (Unix Epoc)

:param from_epoch: Start time in Unix Epoc (seconds)

:returns: Dictionary containing a list of active metrics
"""

cls._class_url = cls._METRIC_LIST_ENDPOINT

try:
seconds = int(from_epoch)
params = {'from': seconds}
except ValueError:
raise ApiError("Parameter 'from_epoch' must be an integer")

return super(Metric, cls).get_all(**params)

@classmethod
def send(cls, metrics=None, **single_metric):
"""
Expand Down