Skip to content

Commit d0c67ad

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add include_percentiles field in Logs Custom Metrics (#896)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 12cc97a commit d0c67ad

File tree

17 files changed

+344
-30
lines changed

17 files changed

+344
-30
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:14.323887",
8-
"spec_repo_commit": "9015efdd"
7+
"regenerated": "2022-11-21 20:01:55.034154",
8+
"spec_repo_commit": "4ca2c235"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-11-21 18:48:14.335707",
13-
"spec_repo_commit": "9015efdd"
12+
"regenerated": "2022-11-21 20:01:55.048203",
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`.'
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"2022-05-12T09:52:22.599Z"
1+
"2022-11-21T15:36:05.545Z"

cassettes/v2/Logs-Metrics_3185148095/Create-a-log-based-metric-returns-OK-response_2853166544/recording.har

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
},
99
"entries": [
1010
{
11-
"_id": "7a67534694e94694283c0d44987ec332",
11+
"_id": "f98bd5930d6046a011a332616cfb250b",
1212
"_order": 0,
1313
"cache": {},
1414
"request": {
15-
"bodySize": 155,
15+
"bodySize": 208,
1616
"cookies": [],
1717
"headers": [
1818
{
@@ -32,17 +32,17 @@
3232
"postData": {
3333
"mimeType": "application/json",
3434
"params": [],
35-
"text": "{\"data\":{\"attributes\":{\"compute\":{\"aggregation_type\":\"count\"}},\"id\":\"Test-Create_a_log_based_metric_returns_OK_response-1652349142\",\"type\":\"logs_metrics\"}}"
35+
"text": "{\"data\":{\"attributes\":{\"compute\":{\"aggregation_type\":\"distribution\",\"include_percentiles\":true,\"path\":\"@duration\"}},\"id\":\"Test-Create_a_log_based_metric_returns_OK_response-1669044965\",\"type\":\"logs_metrics\"}}"
3636
},
3737
"queryString": [],
3838
"url": "https://api.datadoghq.com/api/v2/logs/config/metrics"
3939
},
4040
"response": {
41-
"bodySize": 192,
41+
"bodySize": 246,
4242
"content": {
4343
"mimeType": "application/json",
44-
"size": 192,
45-
"text": "{\"data\":{\"attributes\":{\"filter\":{\"query\":\"*\"},\"group_by\":[],\"compute\":{\"aggregation_type\":\"count\"}},\"type\":\"logs_metrics\",\"id\":\"Test_Create_a_log_based_metric_returns_OK_response_1652349142\"}}"
44+
"size": 246,
45+
"text": "{\"data\":{\"attributes\":{\"filter\":{\"query\":\"*\"},\"group_by\":[],\"compute\":{\"path\":\"@duration\",\"include_percentiles\":true,\"aggregation_type\":\"distribution\"}},\"type\":\"logs_metrics\",\"id\":\"Test_Create_a_log_based_metric_returns_OK_response_1669044965\"}}\n"
4646
},
4747
"cookies": [],
4848
"headers": [
@@ -51,17 +51,17 @@
5151
"value": "application/json"
5252
}
5353
],
54-
"headersSize": 692,
54+
"headersSize": 649,
5555
"httpVersion": "HTTP/1.1",
5656
"redirectURL": "",
5757
"status": 200,
5858
"statusText": "OK"
5959
},
60-
"startedDateTime": "2022-05-12T09:52:22.602Z",
61-
"time": 613
60+
"startedDateTime": "2022-11-21T15:36:05.555Z",
61+
"time": 272
6262
},
6363
{
64-
"_id": "bba84067fccc33a39ff75f3414ad5e36",
64+
"_id": "12c1ae70ac1d021e801d57f41265ad38",
6565
"_order": 0,
6666
"cache": {},
6767
"request": {
@@ -78,14 +78,14 @@
7878
"httpVersion": "HTTP/1.1",
7979
"method": "DELETE",
8080
"queryString": [],
81-
"url": "https://api.datadoghq.com/api/v2/logs/config/metrics/Test_Create_a_log_based_metric_returns_OK_response_1652349142"
81+
"url": "https://api.datadoghq.com/api/v2/logs/config/metrics/Test_Create_a_log_based_metric_returns_OK_response_1669044965"
8282
},
8383
"response": {
84-
"bodySize": 2,
84+
"bodySize": 3,
8585
"content": {
8686
"mimeType": "application/json",
87-
"size": 2,
88-
"text": "{}"
87+
"size": 3,
88+
"text": "{}\n"
8989
},
9090
"cookies": [],
9191
"headers": [
@@ -94,14 +94,14 @@
9494
"value": "application/json"
9595
}
9696
],
97-
"headersSize": 667,
97+
"headersSize": 624,
9898
"httpVersion": "HTTP/1.1",
9999
"redirectURL": "",
100100
"status": 200,
101101
"statusText": "OK"
102102
},
103-
"startedDateTime": "2022-05-12T09:52:23.218Z",
104-
"time": 538
103+
"startedDateTime": "2022-11-21T15:36:05.838Z",
104+
"time": 141
105105
}
106106
],
107107
"pages": [],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2022-11-21T19:49:25.214Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
{
2+
"log": {
3+
"_recordingName": "Logs Metrics/Update a log-based metric with include_percentiles field returns \"OK\" response",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "276c5d36e939a5e00e1d72bbff56f3c7",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 360,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 570,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"data\":{\"attributes\":{\"compute\":{\"aggregation_type\":\"distribution\",\"include_percentiles\":true,\"path\":\"@duration\"},\"filter\":{\"query\":\"source:Test-Update_a_log_based_metric_with_include_percentiles_field_returns_OK_response-1669060165\"}},\"id\":\"Test-Update_a_log_based_metric_with_include_percentiles_field_returns_OK_response-1669060165\",\"type\":\"logs_metrics\"}}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v2/logs/config/metrics"
39+
},
40+
"response": {
41+
"bodySize": 375,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 375,
45+
"text": "{\"data\":{\"attributes\":{\"filter\":{\"query\":\"source:Test-Update_a_log_based_metric_with_include_percentiles_field_returns_OK_response-1669060165\"},\"group_by\":[],\"compute\":{\"path\":\"@duration\",\"include_percentiles\":true,\"aggregation_type\":\"distribution\"}},\"type\":\"logs_metrics\",\"id\":\"Test_Update_a_log_based_metric_with_include_percentiles_field_returns_OK_response_1669060165\"}}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 649,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2022-11-21T19:49:25.243Z",
61+
"time": 953
62+
},
63+
{
64+
"_id": "b1578c2e26b42d91c00e94bd635ca96d",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 87,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
},
76+
{
77+
"_fromType": "array",
78+
"name": "content-type",
79+
"value": "application/json"
80+
}
81+
],
82+
"headersSize": 663,
83+
"httpVersion": "HTTP/1.1",
84+
"method": "PATCH",
85+
"postData": {
86+
"mimeType": "application/json",
87+
"params": [],
88+
"text": "{\"data\":{\"attributes\":{\"compute\":{\"include_percentiles\":false}},\"type\":\"logs_metrics\"}}"
89+
},
90+
"queryString": [],
91+
"url": "https://api.datadoghq.com/api/v2/logs/config/metrics/Test_Update_a_log_based_metric_with_include_percentiles_field_returns_OK_response_1669060165"
92+
},
93+
"response": {
94+
"bodySize": 376,
95+
"content": {
96+
"mimeType": "application/json",
97+
"size": 376,
98+
"text": "{\"data\":{\"attributes\":{\"filter\":{\"query\":\"source:Test-Update_a_log_based_metric_with_include_percentiles_field_returns_OK_response-1669060165\"},\"group_by\":[],\"compute\":{\"path\":\"@duration\",\"include_percentiles\":false,\"aggregation_type\":\"distribution\"}},\"type\":\"logs_metrics\",\"id\":\"Test_Update_a_log_based_metric_with_include_percentiles_field_returns_OK_response_1669060165\"}}\n"
99+
},
100+
"cookies": [],
101+
"headers": [
102+
{
103+
"name": "content-type",
104+
"value": "application/json"
105+
}
106+
],
107+
"headersSize": 649,
108+
"httpVersion": "HTTP/1.1",
109+
"redirectURL": "",
110+
"status": 200,
111+
"statusText": "OK"
112+
},
113+
"startedDateTime": "2022-11-21T19:49:26.229Z",
114+
"time": 585
115+
},
116+
{
117+
"_id": "0f43954d7cc4f040ab134d08b2fbfb74",
118+
"_order": 0,
119+
"cache": {},
120+
"request": {
121+
"bodySize": 0,
122+
"cookies": [],
123+
"headers": [
124+
{
125+
"_fromType": "array",
126+
"name": "accept",
127+
"value": "*/*"
128+
}
129+
],
130+
"headersSize": 599,
131+
"httpVersion": "HTTP/1.1",
132+
"method": "DELETE",
133+
"queryString": [],
134+
"url": "https://api.datadoghq.com/api/v2/logs/config/metrics/Test_Update_a_log_based_metric_with_include_percentiles_field_returns_OK_response_1669060165"
135+
},
136+
"response": {
137+
"bodySize": 3,
138+
"content": {
139+
"mimeType": "application/json",
140+
"size": 3,
141+
"text": "{}\n"
142+
},
143+
"cookies": [],
144+
"headers": [
145+
{
146+
"name": "content-type",
147+
"value": "application/json"
148+
}
149+
],
150+
"headersSize": 624,
151+
"httpVersion": "HTTP/1.1",
152+
"redirectURL": "",
153+
"status": 200,
154+
"statusText": "OK"
155+
},
156+
"startedDateTime": "2022-11-21T19:49:26.822Z",
157+
"time": 380
158+
}
159+
],
160+
"pages": [],
161+
"version": "1.2"
162+
}
163+
}

examples/v2/logs-metrics/CreateLogsMetric.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const params: v2.LogsMetricsApiCreateLogsMetricRequest = {
1414
type: "logs_metrics",
1515
attributes: {
1616
compute: {
17-
aggregationType: "count",
17+
aggregationType: "distribution",
18+
includePercentiles: true,
19+
path: "@duration",
1820
},
1921
},
2022
},
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Update a log-based metric with include_percentiles field returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.LogsMetricsApi(configuration);
9+
10+
// there is a valid "logs_metric_percentile" in the system
11+
const LOGS_METRIC_PERCENTILE_DATA_ID = process.env
12+
.LOGS_METRIC_PERCENTILE_DATA_ID as string;
13+
14+
const params: v2.LogsMetricsApiUpdateLogsMetricRequest = {
15+
body: {
16+
data: {
17+
type: "logs_metrics",
18+
attributes: {
19+
compute: {
20+
includePercentiles: false,
21+
},
22+
},
23+
},
24+
},
25+
metricId: LOGS_METRIC_PERCENTILE_DATA_ID,
26+
};
27+
28+
apiInstance
29+
.updateLogsMetric(params)
30+
.then((data: v2.LogsMetricResponse) => {
31+
console.log(
32+
"API called successfully. Returned data: " + JSON.stringify(data)
33+
);
34+
})
35+
.catch((error: any) => console.error(error));

0 commit comments

Comments
 (0)