Skip to content

Error fetching monitor with mtd cummulative window starting on custom day #3592

Description

@wesleyjellis

Describe the bug

If I create a monitor with a custom starting day (eg: 17) for a month long cumulative window, trying to get the monitor, or list the monitor results in an exception being thrown.

ArgumentError: invalid value for "month_starts", must be smaller than or equal to 1.

To Reproduce

Create a metric monitor with a cummulative window, month to date, starting on any date but 1.

Example:

{
	"id": 306920871,
	"name": "wesley datadog api bug with custom start date for month to date",
	"type": "query alert",
	"query": "avg(current_1mo):avg:system.load.1{*} > 100",
	"message": "",
	"tags": [],
	"options": {
		"thresholds": {
			"critical": 100
		},
		"notify_audit": false,
		"on_missing_data": "default",
		"include_tags": false,
		"scheduling_options": {
			"evaluation_window": {
				"month_starts": 17,
				"day_starts": "00:00",
				"timezone": "UTC"
			}
		},
		"new_host_delay": 300
	},
	"priority": null,
	"draft_status": "draft",
	"assets": []
}

Attempt to fetch the monitor by id

client.get_monitor(306920871)

Expected behavior

No exception raised.

The generated code for month_starts= seems overly strict in this case

https://github.com/DataDog/datadog-api-client-ruby/blob/master/lib/datadog_api_client/v1/models/monitor_options_scheduling_options_evaluation_window.rb#L122

Environment and Versions:

Ruby: 3.3.11
Version: 2.32.0

Additional context
Add any other context about the problem here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions