@@ -18,28 +18,30 @@ class Metric:
1818 A Class for `Metric` object.
1919
2020 :param metric: (dict) A metric item from the list of metrics received from prometheus
21- :param oldest_data_datetime: (datetime|timedelta) Any metric values in the dataframe that are \
22- older than this value will be deleted when new data is added to the dataframe \
21+ :param oldest_data_datetime: (datetime|timedelta) Any metric values in the dataframe that are
22+ older than this value will be deleted when new data is added to the dataframe
2323 using the __add__("+") operator.
2424
25- * `oldest_data_datetime=datetime.timedelta(days=2)`, will delete the \
26- metric data that is 2 days older than the latest metric. \
27- The dataframe is pruned only when new data is added to it. \n
28- * `oldest_data_datetime=datetime.datetime(2019,5,23,12,0)`, will delete \
29- any data that is older than "23 May 2019 12:00:00" \n
30- * `oldest_data_datetime=datetime.datetime.fromtimestamp(1561475156)` \
31- can also be set using the unix timestamp
25+ * `oldest_data_datetime=datetime.timedelta(days=2)`, will delete the
26+ metric data that is 2 days older than the latest metric.
27+ The dataframe is pruned only when new data is added to it.
28+ * `oldest_data_datetime=datetime.datetime(2019,5,23,12,0)`, will delete
29+ any data that is older than "23 May 2019 12:00:00"
30+ * `oldest_data_datetime=datetime.datetime.fromtimestamp(1561475156)`
31+ can also be set using the unix timestamp
3232
3333 Example Usage:
34- ``prom = PrometheusConnect()``
34+ .. code-block:: python
3535
36- ``my_label_config = {'cluster': 'my_cluster_id', 'label_2': 'label_2_value'}``
36+ prom = PrometheusConnect()
3737
38- ``metric_data = prom.get_metric_range_data(metric_name='up', label_config=my_label_config)``
39- ``Here metric_data is a list of metrics received from prometheus``
38+ my_label_config = {'cluster': 'my_cluster_id', 'label_2': 'label_2_value'}
4039
41- ``# only for the first item in the list``
42- ``my_metric_object = Metric(metric_data[0], datetime.timedelta(days=10))``
40+ metric_data = prom.get_metric_range_data(metric_name='up', label_config=my_label_config)
41+ # Here metric_data is a list of metrics received from prometheus
42+
43+ # only for the first item in the list
44+ my_metric_object = Metric(metric_data[0], datetime.timedelta(days=10))
4345
4446 """
4547
@@ -85,11 +87,13 @@ def __eq__(self, other):
8587 Check whether two metrics are the same (are the same time-series regardless of their data)
8688
8789 Example Usage:
88- ``metric_1 = Metric(metric_data_1)``
90+ .. code-block:: python
91+
92+ metric_1 = Metric(metric_data_1)
8993
90- `` metric_2 = Metric(metric_data_2)``
94+ metric_2 = Metric(metric_data_2)
9195
92- `` print(metric_1 == metric_2) # will print True if they belong to the same time-series``
96+ print(metric_1 == metric_2) # will print True if they belong to the same time-series
9397
9498 :return: (bool) If two Metric objects belong to the same time-series,
9599 i.e. same name and label config, it will return True, else False
@@ -103,9 +107,11 @@ def __str__(self):
103107 Make it print in a cleaner way when print function is used on a Metric object.
104108
105109 Example Usage:
106- ``metric_1 = Metric(metric_data_1)``
110+ .. code-block:: python
111+
112+ metric_1 = Metric(metric_data_1)
107113
108- `` print(metric_1) # will print the name, labels and the head of the dataframe``
114+ print(metric_1) # will print the name, labels and the head of the dataframe
109115
110116 """
111117 name = "metric_name: " + repr (self .metric_name ) + "\n "
@@ -130,11 +136,11 @@ def __add__(self, other):
130136 # will also be set in ``metric_12``
131137 # (like ``oldest_data_datetime``)
132138
133- :return: (`Metric`) Returns a `Metric` object with the combined metric data \
134- of the two added metrics
139+ :return: (`Metric`) Returns a `Metric` object with the combined metric data
140+ of the two added metrics
135141
136- :raises: (TypeError) Raises an exception when two metrics being added are \
137- from different metric time-series
142+ :raises: (TypeError) Raises an exception when two metrics being added are
143+ from different metric time-series
138144 """
139145 if self == other :
140146 new_metric = deepcopy (self )
0 commit comments