Skip to content

Commit 764ba66

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add support for formula and function in monitors (#719)
* Regenerate client from commit f7a8bd6 of spec repo * pre-commit fixes Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent bbce811 commit 764ba66

16 files changed

Lines changed: 1782 additions & 10 deletions

.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.2",
7-
"regenerated": "2022-02-02 15:54:29.881972",
8-
"spec_repo_commit": "3b52f9a"
7+
"regenerated": "2022-02-03 09:45:15.707262",
8+
"spec_repo_commit": "f7a8bd6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.2",
12-
"regenerated": "2022-02-02 15:54:29.901827",
13-
"spec_repo_commit": "3b52f9a"
12+
"regenerated": "2022-02-03 09:45:15.730129",
13+
"spec_repo_commit": "f7a8bd6"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5692,6 +5692,141 @@ components:
56925692
- FIREFOX_LAPTOP_LARGE
56935693
- FIREFOX_TABLET
56945694
- FIREFOX_MOBILE_SMALL
5695+
MonitorFormulaAndFunctionEventAggregation:
5696+
description: Aggregation methods for event platform queries.
5697+
enum:
5698+
- count
5699+
- cardinality
5700+
- median
5701+
- pc75
5702+
- pc90
5703+
- pc95
5704+
- pc98
5705+
- pc99
5706+
- sum
5707+
- min
5708+
- max
5709+
- avg
5710+
example: avg
5711+
type: string
5712+
x-enum-varnames:
5713+
- COUNT
5714+
- CARDINALITY
5715+
- MEDIAN
5716+
- PC75
5717+
- PC90
5718+
- PC95
5719+
- PC98
5720+
- PC99
5721+
- SUM
5722+
- MIN
5723+
- MAX
5724+
- AVG
5725+
MonitorFormulaAndFunctionEventQueryDefinition:
5726+
description: A formula and functions events query.
5727+
properties:
5728+
compute:
5729+
$ref: '#/components/schemas/MonitorFormulaAndFunctionEventQueryDefinitionCompute'
5730+
data_source:
5731+
$ref: '#/components/schemas/MonitorFormulaAndFunctionEventsDataSource'
5732+
group_by:
5733+
description: Group by options.
5734+
items:
5735+
$ref: '#/components/schemas/MonitorFormulaAndFunctionEventQueryGroupBy'
5736+
type: array
5737+
indexes:
5738+
description: An array of index names to query in the stream. Omit or use
5739+
`[]` to query all indexes at once.
5740+
example:
5741+
- days-3
5742+
- days-7
5743+
items:
5744+
description: A log index set up for your organization. For additional
5745+
indexes, see the [multiple indexes](https://docs.datadoghq.com/logs/indexes/#multiple-indexes)
5746+
documentation.
5747+
type: string
5748+
type: array
5749+
name:
5750+
description: Name of the query for use in formulas.
5751+
example: query_errors
5752+
type: string
5753+
search:
5754+
$ref: '#/components/schemas/MonitorFormulaAndFunctionEventQueryDefinitionSearch'
5755+
required:
5756+
- data_source
5757+
- compute
5758+
- name
5759+
type: object
5760+
MonitorFormulaAndFunctionEventQueryDefinitionCompute:
5761+
description: Compute options.
5762+
properties:
5763+
aggregation:
5764+
$ref: '#/components/schemas/MonitorFormulaAndFunctionEventAggregation'
5765+
interval:
5766+
description: A time interval in milliseconds.
5767+
example: 60000
5768+
format: int64
5769+
type: integer
5770+
metric:
5771+
description: Measurable attribute to compute.
5772+
example: '@duration'
5773+
type: string
5774+
required:
5775+
- aggregation
5776+
type: object
5777+
MonitorFormulaAndFunctionEventQueryDefinitionSearch:
5778+
description: Search options.
5779+
properties:
5780+
query:
5781+
description: Events search string.
5782+
example: service:query
5783+
type: string
5784+
required:
5785+
- query
5786+
type: object
5787+
MonitorFormulaAndFunctionEventQueryGroupBy:
5788+
description: List of objects used to group by.
5789+
properties:
5790+
facet:
5791+
description: Event facet.
5792+
example: status
5793+
type: string
5794+
limit:
5795+
description: Number of groups to return.
5796+
example: 10
5797+
format: int64
5798+
type: integer
5799+
sort:
5800+
$ref: '#/components/schemas/MonitorFormulaAndFunctionEventQueryGroupBySort'
5801+
required:
5802+
- facet
5803+
type: object
5804+
MonitorFormulaAndFunctionEventQueryGroupBySort:
5805+
description: Options for sorting group by results.
5806+
properties:
5807+
aggregation:
5808+
$ref: '#/components/schemas/MonitorFormulaAndFunctionEventAggregation'
5809+
metric:
5810+
description: Metric used for sorting group by results.
5811+
type: string
5812+
order:
5813+
$ref: '#/components/schemas/QuerySortOrder'
5814+
required:
5815+
- aggregation
5816+
type: object
5817+
MonitorFormulaAndFunctionEventsDataSource:
5818+
description: Data source for event platform-based queries.
5819+
enum:
5820+
- rum
5821+
example: rum
5822+
type: string
5823+
x-enum-varnames:
5824+
- RUM
5825+
MonitorFormulaAndFunctionQueryDefinition:
5826+
description: A formula and function query.
5827+
oneOf:
5828+
- $ref: '#/components/schemas/MonitorFormulaAndFunctionEventQueryDefinition'
5829+
type: object
56955830
MonitorGroupSearchResponse:
56965831
description: The response of a monitor group search.
56975832
example:
@@ -5976,6 +6111,12 @@ components:
59766111
format: int64
59776112
nullable: true
59786113
type: integer
6114+
variables:
6115+
description: List of requests that can be used in the monitor query. **This
6116+
feature is currently in beta.**
6117+
items:
6118+
$ref: '#/components/schemas/MonitorFormulaAndFunctionQueryDefinition'
6119+
type: array
59796120
type: object
59806121
MonitorOverallStates:
59816122
description: The different states your monitor can be in.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2022-02-02T21:04:10.597Z

cassettes/features/v1/monitors/Create-a-RUM-formula-and-functions-monitor-returns-OK-response.yml

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Create a RUM formula and functions monitor returns "OK" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::MonitorsAPI.new
5+
6+
body = DatadogAPIClient::V1::Monitor.new({
7+
name: "Example-Create_a_RUM_formula_and_functions_monitor_returns_OK_response",
8+
type: DatadogAPIClient::V1::MonitorType::RUM_ALERT,
9+
query: 'formula("query2 / query1 * 100").last("15m") >= 0.8',
10+
message: "some message Notify: @hipchat-channel",
11+
tags: [
12+
"test:examplecreatearumformulaandfunctionsmonitorreturnsokresponse",
13+
"env:ci",
14+
],
15+
priority: 3,
16+
options: DatadogAPIClient::V1::MonitorOptions.new({
17+
thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
18+
critical: 0.8,
19+
}),
20+
variables: [
21+
DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinition.new({
22+
data_source: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventsDataSource::RUM,
23+
name: "query2",
24+
search: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinitionSearch.new({
25+
query: "",
26+
}),
27+
indexes: [
28+
"*",
29+
],
30+
compute: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinitionCompute.new({
31+
aggregation: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventAggregation::COUNT,
32+
}),
33+
group_by: [],
34+
}),
35+
DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinition.new({
36+
data_source: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventsDataSource::RUM,
37+
name: "query1",
38+
search: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinitionSearch.new({
39+
query: "status:error",
40+
}),
41+
indexes: [
42+
"*",
43+
],
44+
compute: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventQueryDefinitionCompute.new({
45+
aggregation: DatadogAPIClient::V1::MonitorFormulaAndFunctionEventAggregation::COUNT,
46+
}),
47+
group_by: [],
48+
}),
49+
],
50+
}),
51+
})
52+
p api_instance.create_monitor(body)

features/v1/monitors.feature

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ Feature: Monitors
3030
When the request is sent
3131
Then the response status is 200 OK
3232

33+
@team:DataDog/monitor-app
34+
Scenario: Create a RUM formula and functions monitor returns "OK" response
35+
Given new "CreateMonitor" request
36+
And body with value {"name": "{{ unique }}","type": "rum alert","query": "formula(\"query2 / query1 * 100\").last(\"15m\") >= 0.8","message": "some message Notify: @hipchat-channel", "tags": ["test:{{ unique_lower_alnum }}", "env:ci"],"priority": 3,"options":{"thresholds":{"critical":0.8},"variables":[{"data_source": "rum","name": "query2","search": {"query": ""},"indexes": ["*"],"compute": {"aggregation": "count"},"group_by": []}, {"data_source": "rum","name": "query1","search": {"query": "status:error"},"indexes": ["*"],"compute": {"aggregation": "count"},"group_by": []}]}}
37+
When the request is sent
38+
Then the response status is 200 OK
39+
3340
@team:DataDog/monitor-app
3441
Scenario: Create a ci-pipelines monitor returns "OK" response
3542
Given new "CreateMonitor" request
@@ -78,7 +85,7 @@ Feature: Monitors
7885
Scenario: Edit a monitor returns "Bad Request" response
7986
Given new "UpdateMonitor" request
8087
And request contains "monitor_id" parameter from "REPLACE.ME"
81-
And body with value {"message": null, "name": null, "options": {"enable_logs_sample": null, "escalation_message": "none", "evaluation_delay": null, "groupby_simple_monitor": null, "include_tags": true, "locked": null, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notify_audit": false, "notify_no_data": false, "renotify_interval": "none", "renotify_occurrences": null, "renotify_statuses": ["alert"], "require_full_window": null, "silenced": null, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical": null, "critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": "none"}, "priority": null, "query": null, "restricted_roles": [null], "tags": [null], "type": "query alert"}
88+
And body with value {"message": null, "name": null, "options": {"enable_logs_sample": null, "escalation_message": "none", "evaluation_delay": null, "groupby_simple_monitor": null, "include_tags": true, "locked": null, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notify_audit": false, "notify_no_data": false, "renotify_interval": "none", "renotify_occurrences": null, "renotify_statuses": ["alert"], "require_full_window": null, "silenced": null, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical": null, "critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": "none", "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "metric": null, "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "query": null, "restricted_roles": [null], "tags": [null], "type": "query alert"}
8289
When the request is sent
8390
Then the response status is 400 Bad Request
8491

lib/datadog_api_client/v1.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@
262262
require 'datadog_api_client/v1/models/metrics_query_unit'
263263
require 'datadog_api_client/v1/models/monitor'
264264
require 'datadog_api_client/v1/models/monitor_device_id'
265+
require 'datadog_api_client/v1/models/monitor_formula_and_function_event_aggregation'
266+
require 'datadog_api_client/v1/models/monitor_formula_and_function_event_query_definition'
267+
require 'datadog_api_client/v1/models/monitor_formula_and_function_event_query_definition_compute'
268+
require 'datadog_api_client/v1/models/monitor_formula_and_function_event_query_definition_search'
269+
require 'datadog_api_client/v1/models/monitor_formula_and_function_event_query_group_by'
270+
require 'datadog_api_client/v1/models/monitor_formula_and_function_event_query_group_by_sort'
271+
require 'datadog_api_client/v1/models/monitor_formula_and_function_events_data_source'
272+
require 'datadog_api_client/v1/models/monitor_formula_and_function_query_definition'
265273
require 'datadog_api_client/v1/models/monitor_group_search_response'
266274
require 'datadog_api_client/v1/models/monitor_group_search_response_counts'
267275
require 'datadog_api_client/v1/models/monitor_group_search_result'
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
=begin
2+
#Datadog API V1 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
8+
Generated by: https://openapi-generator.tech
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V1
20+
class MonitorFormulaAndFunctionEventAggregation
21+
COUNT = "count".freeze
22+
CARDINALITY = "cardinality".freeze
23+
MEDIAN = "median".freeze
24+
PC75 = "pc75".freeze
25+
PC90 = "pc90".freeze
26+
PC95 = "pc95".freeze
27+
PC98 = "pc98".freeze
28+
PC99 = "pc99".freeze
29+
SUM = "sum".freeze
30+
MIN = "min".freeze
31+
MAX = "max".freeze
32+
AVG = "avg".freeze
33+
34+
# Builds the enum from string
35+
# @param [String] The enum value in the form of the string
36+
# @return [String] The enum value
37+
def self.build_from_hash(value)
38+
new.build_from_hash(value)
39+
end
40+
41+
# Builds the enum from string
42+
# @param [String] The enum value in the form of the string
43+
# @return [String] The enum value
44+
def build_from_hash(value)
45+
constantValues = MonitorFormulaAndFunctionEventAggregation.constants.select { |c| MonitorFormulaAndFunctionEventAggregation::const_get(c) == value }
46+
constantValues.empty? ? DatadogAPIClient::V1::UnparsedObject.new(value) : value
47+
end
48+
end
49+
end

0 commit comments

Comments
 (0)