DataDog / datadog-cloudformation-resources

Apache License 2.0
51 stars 35 forks source link

Parameter 'query' is invalid #168

Open fredsig opened 3 years ago

fredsig commented 3 years ago

Using latest 4.0.0 with the following resource:

  PerfRunMonitorRate:
    Type: 'Datadog::Monitors::Monitor'
    Properties:
      Type: query alert
      Query: 'sum(last_1d):sum:scion.perf_run.rate{*} by {version,endpoint} < 5'
      Name: Hermes - Perf request/s
      Options:
        Thresholds:
          Critical: 1
          OK: 5
        NotifyNoData: false

Gives me a query error:

Exception when calling MonitorsApi->create_monitor: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Fri, 24 Sep 2021 15:50:09 GMT', 'Content-Type': 'application/json', 'Content-Length': '67', 'Connection': 'keep-alive', 'pragma': 'no-cache', 'cache-control': 'no-cache', 'x-ratelimit-limit': '500', 'x-ratelimit-period': '10', 'x-ratelimit-reset': '1', 'x-ratelimit-remaining': '499', 'x-content-type-options': 'nosniff', 'strict-transport-security': 'max-age=15724800;', 'content-security-policy': "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report", 'x-frame-options': 'SAMEORIGIN'})
HTTP response body: 
{
    "errors": [
        "The value provided for parameter 'query' is invalid"
    ]
}

Traceback (most recent call last):
  File "/var/task/datadog_monitors_monitor/handlers.py", line 256, in create_handler
    monitor_resp = api_instance.create_monitor(monitor)
  File "/var/task/datadog_api_client/v1/api/monitors_api.py", line 442, in create_monitor
    return self._create_monitor_endpoint.call_with_http_info(**kwargs)
  File "/var/task/datadog_api_client/v1/api_client.py", line 861, in call_with_http_info
    collection_formats=params["collection_format"],
  File "/var/task/datadog_api_client/v1/api_client.py", line 402, in call_api
    _check_type,
  File "/var/task/datadog_api_client/v1/api_client.py", line 193, in __call_api
    raise e
  File "/var/task/datadog_api_client/v1/api_client.py", line 189, in __call_api
    _request_timeout=_request_timeout,
  File "/var/task/datadog_api_client/v1/api_client.py", line 473, in request
    body=body,
  File "/var/task/datadog_api_client/v1/rest.py", line 308, in POST
    body=body,
  File "/var/task/datadog_api_client/v1/rest.py", line 234, in request
    raise ApiException(http_resp=r)
datadog_api_client.v1.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Fri, 24 Sep 2021 15:50:09 GMT', 'Content-Type': 'application/json', 'Content-Length': '67', 'Connection': 'keep-alive', 'pragma': 'no-cache', 'cache-control': 'no-cache', 'x-ratelimit-limit': '500', 'x-ratelimit-period': '10', 'x-ratelimit-reset': '1', 'x-ratelimit-remaining': '499', 'x-content-type-options': 'nosniff', 'strict-transport-security': 'max-age=15724800;', 'content-security-policy': "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report", 'x-frame-options': 'SAMEORIGIN'})
HTTP response body: 
{
    "errors": [
        "The value provided for parameter 'query' is invalid"
    ]
}

I've copied the query expression from a Datadog monitor which is working well, is it something I'm missing in the YAML?

github-actions[bot] commented 3 years ago

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

travishaby commented 1 year ago

I am also experiencing this issue! The query I've defined works fine when I take it from my cloudformation template and paste it into Metrics Explorer, but I am getting failures when I try to deploy my cloudformation template 😢