Skip to content

Commit 607a713

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add include_percentiles field in Logs Custom Metrics (#1224)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 7d7b1e1 commit 607a713

17 files changed

+235
-18
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2022-11-21 18:48:28.015320",
8-
"spec_repo_commit": "9015efdd"
7+
"regenerated": "2022-11-21 20:01:47.849955",
8+
"spec_repo_commit": "4ca2c235"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-11-21 18:48:28.030582",
13-
"spec_repo_commit": "9015efdd"
12+
"regenerated": "2022-11-21 20:01:47.861729",
13+
"spec_repo_commit": "4ca2c235"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5012,6 +5012,8 @@ components:
50125012
properties:
50135013
aggregation_type:
50145014
$ref: '#/components/schemas/LogsMetricComputeAggregationType'
5015+
include_percentiles:
5016+
$ref: '#/components/schemas/LogsMetricComputeIncludePercentiles'
50155017
path:
50165018
description: The path to the value the log-based metric will aggregate on
50175019
(only used if the aggregation type is a "distribution").
@@ -5030,6 +5032,13 @@ components:
50305032
x-enum-varnames:
50315033
- COUNT
50325034
- DISTRIBUTION
5035+
LogsMetricComputeIncludePercentiles:
5036+
description: 'Toggle to include or exclude percentile aggregations for distribution
5037+
metrics.
5038+
5039+
Only present when the `aggregation_type` is `distribution`.'
5040+
example: true
5041+
type: boolean
50335042
LogsMetricCreateAttributes:
50345043
description: The object describing the Datadog log-based metric to create.
50355044
properties:
@@ -5121,6 +5130,8 @@ components:
51215130
properties:
51225131
aggregation_type:
51235132
$ref: '#/components/schemas/LogsMetricResponseComputeAggregationType'
5133+
include_percentiles:
5134+
$ref: '#/components/schemas/LogsMetricComputeIncludePercentiles'
51245135
path:
51255136
description: The path to the value the log-based metric will aggregate on
51265137
(only used if the aggregation type is a "distribution").
@@ -5182,6 +5193,8 @@ components:
51825193
LogsMetricUpdateAttributes:
51835194
description: The log-based metric properties that will be updated.
51845195
properties:
5196+
compute:
5197+
$ref: '#/components/schemas/LogsMetricUpdateCompute'
51855198
filter:
51865199
$ref: '#/components/schemas/LogsMetricFilter'
51875200
group_by:
@@ -5190,6 +5203,12 @@ components:
51905203
$ref: '#/components/schemas/LogsMetricGroupBy'
51915204
type: array
51925205
type: object
5206+
LogsMetricUpdateCompute:
5207+
description: The compute rule to compute the log-based metric.
5208+
properties:
5209+
include_percentiles:
5210+
$ref: '#/components/schemas/LogsMetricComputeIncludePercentiles'
5211+
type: object
51935212
LogsMetricUpdateData:
51945213
description: The new log-based metric properties.
51955214
properties:
@@ -5978,7 +5997,7 @@ components:
59785997
format: date-time
59795998
type: string
59805999
include_percentiles:
5981-
description: 'Toggle to turn on/off percentile aggregations for distribution
6000+
description: 'Toggle to include or exclude percentile aggregations for distribution
59826001
metrics.
59836002

59846003
Only present when the `metric_type` is `distribution`.'

docs/datadog_api_client.v2.model.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,13 @@ logs\_metric\_update\_attributes
22412241
:members:
22422242
:show-inheritance:
22432243

2244+
logs\_metric\_update\_compute
2245+
-----------------------------
2246+
2247+
.. automodule:: datadog_api_client.v2.model.logs_metric_update_compute
2248+
:members:
2249+
:show-inheritance:
2250+
22442251
logs\_metric\_update\_data
22452252
--------------------------
22462253

examples/v2/logs-metrics/CreateLogsMetric.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
type=LogsMetricType.LOGS_METRICS,
1818
attributes=LogsMetricCreateAttributes(
1919
compute=LogsMetricCompute(
20-
aggregation_type=LogsMetricComputeAggregationType.COUNT,
20+
aggregation_type=LogsMetricComputeAggregationType.DISTRIBUTION,
21+
include_percentiles=True,
22+
path="@duration",
2123
),
2224
),
2325
),
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Update a log-based metric with include_percentiles field returns "OK" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.logs_metrics_api import LogsMetricsApi
8+
from datadog_api_client.v2.model.logs_metric_type import LogsMetricType
9+
from datadog_api_client.v2.model.logs_metric_update_attributes import LogsMetricUpdateAttributes
10+
from datadog_api_client.v2.model.logs_metric_update_compute import LogsMetricUpdateCompute
11+
from datadog_api_client.v2.model.logs_metric_update_data import LogsMetricUpdateData
12+
from datadog_api_client.v2.model.logs_metric_update_request import LogsMetricUpdateRequest
13+
14+
# there is a valid "logs_metric_percentile" in the system
15+
LOGS_METRIC_PERCENTILE_DATA_ID = environ["LOGS_METRIC_PERCENTILE_DATA_ID"]
16+
17+
body = LogsMetricUpdateRequest(
18+
data=LogsMetricUpdateData(
19+
type=LogsMetricType.LOGS_METRICS,
20+
attributes=LogsMetricUpdateAttributes(
21+
compute=LogsMetricUpdateCompute(
22+
include_percentiles=False,
23+
),
24+
),
25+
),
26+
)
27+
28+
configuration = Configuration()
29+
with ApiClient(configuration) as api_client:
30+
api_instance = LogsMetricsApi(api_client)
31+
response = api_instance.update_logs_metric(metric_id=LOGS_METRIC_PERCENTILE_DATA_ID, body=body)
32+
33+
print(response)

src/datadog_api_client/v2/model/logs_metric_compute.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,38 @@ def openapi_types(_):
2424

2525
return {
2626
"aggregation_type": (LogsMetricComputeAggregationType,),
27+
"include_percentiles": (bool,),
2728
"path": (str,),
2829
}
2930

3031
attribute_map = {
3132
"aggregation_type": "aggregation_type",
33+
"include_percentiles": "include_percentiles",
3234
"path": "path",
3335
}
3436

3537
def __init__(
36-
self_, aggregation_type: LogsMetricComputeAggregationType, path: Union[str, UnsetType] = unset, **kwargs
38+
self_,
39+
aggregation_type: LogsMetricComputeAggregationType,
40+
include_percentiles: Union[bool, UnsetType] = unset,
41+
path: Union[str, UnsetType] = unset,
42+
**kwargs,
3743
):
3844
"""
3945
The compute rule to compute the log-based metric.
4046
4147
:param aggregation_type: The type of aggregation to use.
4248
:type aggregation_type: LogsMetricComputeAggregationType
4349
50+
:param include_percentiles: Toggle to include or exclude percentile aggregations for distribution metrics.
51+
Only present when the ``aggregation_type`` is ``distribution``.
52+
:type include_percentiles: bool, optional
53+
4454
:param path: The path to the value the log-based metric will aggregate on (only used if the aggregation type is a "distribution").
4555
:type path: str, optional
4656
"""
57+
if include_percentiles is not unset:
58+
kwargs["include_percentiles"] = include_percentiles
4759
if path is not unset:
4860
kwargs["path"] = path
4961
super().__init__(kwargs)

src/datadog_api_client/v2/model/logs_metric_response_compute.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@ def openapi_types(_):
2828

2929
return {
3030
"aggregation_type": (LogsMetricResponseComputeAggregationType,),
31+
"include_percentiles": (bool,),
3132
"path": (str,),
3233
}
3334

3435
attribute_map = {
3536
"aggregation_type": "aggregation_type",
37+
"include_percentiles": "include_percentiles",
3638
"path": "path",
3739
}
3840

3941
def __init__(
4042
self_,
4143
aggregation_type: Union[LogsMetricResponseComputeAggregationType, UnsetType] = unset,
44+
include_percentiles: Union[bool, UnsetType] = unset,
4245
path: Union[str, UnsetType] = unset,
4346
**kwargs,
4447
):
@@ -48,11 +51,17 @@ def __init__(
4851
:param aggregation_type: The type of aggregation to use.
4952
:type aggregation_type: LogsMetricResponseComputeAggregationType, optional
5053
54+
:param include_percentiles: Toggle to include or exclude percentile aggregations for distribution metrics.
55+
Only present when the ``aggregation_type`` is ``distribution``.
56+
:type include_percentiles: bool, optional
57+
5158
:param path: The path to the value the log-based metric will aggregate on (only used if the aggregation type is a "distribution").
5259
:type path: str, optional
5360
"""
5461
if aggregation_type is not unset:
5562
kwargs["aggregation_type"] = aggregation_type
63+
if include_percentiles is not unset:
64+
kwargs["include_percentiles"] = include_percentiles
5665
if path is not unset:
5766
kwargs["path"] = path
5867
super().__init__(kwargs)

src/datadog_api_client/v2/model/logs_metric_update_attributes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,51 @@
1414

1515

1616
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.logs_metric_update_compute import LogsMetricUpdateCompute
1718
from datadog_api_client.v2.model.logs_metric_filter import LogsMetricFilter
1819
from datadog_api_client.v2.model.logs_metric_group_by import LogsMetricGroupBy
1920

2021

2122
class LogsMetricUpdateAttributes(ModelNormal):
2223
@cached_property
2324
def openapi_types(_):
25+
from datadog_api_client.v2.model.logs_metric_update_compute import LogsMetricUpdateCompute
2426
from datadog_api_client.v2.model.logs_metric_filter import LogsMetricFilter
2527
from datadog_api_client.v2.model.logs_metric_group_by import LogsMetricGroupBy
2628

2729
return {
30+
"compute": (LogsMetricUpdateCompute,),
2831
"filter": (LogsMetricFilter,),
2932
"group_by": ([LogsMetricGroupBy],),
3033
}
3134

3235
attribute_map = {
36+
"compute": "compute",
3337
"filter": "filter",
3438
"group_by": "group_by",
3539
}
3640

3741
def __init__(
3842
self_,
43+
compute: Union[LogsMetricUpdateCompute, UnsetType] = unset,
3944
filter: Union[LogsMetricFilter, UnsetType] = unset,
4045
group_by: Union[List[LogsMetricGroupBy], UnsetType] = unset,
4146
**kwargs,
4247
):
4348
"""
4449
The log-based metric properties that will be updated.
4550
51+
:param compute: The compute rule to compute the log-based metric.
52+
:type compute: LogsMetricUpdateCompute, optional
53+
4654
:param filter: The log-based metric filter. Logs matching this filter will be aggregated in this metric.
4755
:type filter: LogsMetricFilter, optional
4856
4957
:param group_by: The rules for the group by.
5058
:type group_by: [LogsMetricGroupBy], optional
5159
"""
60+
if compute is not unset:
61+
kwargs["compute"] = compute
5262
if filter is not unset:
5363
kwargs["filter"] = filter
5464
if group_by is not unset:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
class LogsMetricUpdateCompute(ModelNormal):
17+
@cached_property
18+
def openapi_types(_):
19+
return {
20+
"include_percentiles": (bool,),
21+
}
22+
23+
attribute_map = {
24+
"include_percentiles": "include_percentiles",
25+
}
26+
27+
def __init__(self_, include_percentiles: Union[bool, UnsetType] = unset, **kwargs):
28+
"""
29+
The compute rule to compute the log-based metric.
30+
31+
:param include_percentiles: Toggle to include or exclude percentile aggregations for distribution metrics.
32+
Only present when the ``aggregation_type`` is ``distribution``.
33+
:type include_percentiles: bool, optional
34+
"""
35+
if include_percentiles is not unset:
36+
kwargs["include_percentiles"] = include_percentiles
37+
super().__init__(kwargs)

src/datadog_api_client/v2/model/metric_tag_configuration_attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(
7777
:param created_at: Timestamp when the tag configuration was created.
7878
:type created_at: datetime, optional
7979
80-
:param include_percentiles: Toggle to turn on/off percentile aggregations for distribution metrics.
80+
:param include_percentiles: Toggle to include or exclude percentile aggregations for distribution metrics.
8181
Only present when the ``metric_type`` is ``distribution``.
8282
:type include_percentiles: bool, optional
8383

0 commit comments

Comments
 (0)