forked from DataDog/datadogpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetadata.py
More file actions
64 lines (47 loc) · 2.24 KB
/
metadata.py
File metadata and controls
64 lines (47 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2015-Present Datadog, Inc
# datadog
from datadog.api.resources import GetableAPIResource, UpdatableAPIResource
class Metadata(GetableAPIResource, UpdatableAPIResource):
"""
A wrapper around Metric Metadata HTTP API
"""
_resource_name = "metrics"
@classmethod
def get(cls, metric_name):
"""
Get metadata information on an existing Datadog metric
param metric_name: metric name (ex. system.cpu.idle)
:returns: Dictionary representing the API's JSON response
"""
if not metric_name:
raise KeyError("'metric_name' parameter is required")
return super(Metadata, cls).get(metric_name)
@classmethod
def update(cls, metric_name, **params):
"""
Update metadata fields for an existing Datadog metric.
If the metadata does not exist for the metric it is created by
the update.
:param type: type of metric (ex. "gauge", "rate", etc.)
see http://docs.datadoghq.com/metrictypes/
:type type: string
:param description: description of the metric
:type description: string
:param short_name: short name of the metric
:type short_name: string
:param unit: unit type associated with the metric (ex. "byte", "operation")
see http://docs.datadoghq.com/units/ for full list
:type unit: string
:param per_unit: per unit type (ex. "second" as in "queries per second")
see http://docs.datadoghq.com/units/ for full list
:type per_unit: string
:param statsd_interval: statsd flush interval for metric in seconds (if applicable)
:type statsd_interval: integer
:returns: Dictionary representing the API's JSON response
>>> api.Metadata.update(metric_name='api.requests.served', metric_type="counter")
"""
if not metric_name:
raise KeyError("'metric_name' parameter is required")
return super(Metadata, cls).update(id=metric_name, **params)