datadog-api-client-ruby icon indicating copy to clipboard operation
datadog-api-client-ruby copied to clipboard

Monitor list filtering by tags is not returning data

Open martinezcoder opened this issue 1 year ago • 3 comments

Describe the bug

Calling the list monitors method with options to filter by tags is not working. It returns an empty list. I have a couple of monitors with the "my-tag" tag, and I have already checked that these monitors are returned if I don't use filters, including the one with the tag.

To Reproduce Steps to reproduce the behavior:

  1. Add the tag "my-tag" to a couple of monitors
  2. Call the API to list these monitors
DatadogAPIClient::V1::MonitorsAPI.new(@client).list_monitors({ tags: "my-tag"})
  1. Debug the DatadogAPIClient::V1::MonitorsAPI request.

Debugging the code at datadog_api_client-2.27.1/lib/datadog_api_client/v1/api/monitors_api.rb:557 shows that the information sent to the API is correct:

{
  :tags=>"my-tag",
  :operation=>:list_monitors, 
  :header_params=>{"Accept"=>"application/json"}, 
  :query_params=> {
    :tags=>"my-tag"
  }, 
  :form_params=>{}, 
  :body=>nil, 
  :auth_names=>[:apiKeyAuth, :appKeyAuth, :AuthZ], 
  :return_type=>"Array<Monitor>", 
  :api_version=>"V1"
}

However, it returns an empty list:

[7] pry(#<DatadogAPIClient::V1::MonitorsAPI>)> @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
=> [[],
 200,
 {"date"=>["Thu, 17 Oct 2024 09:02:16 GMT"],
  "content-type"=>["application/json"],
  "content-length"=>["3"],
  "etag"=>["..."],
  "x-frame-options"=>["SAMEORIGIN"],
  "content-security-policy"=>["..."],
  "x-ratelimit-limit"=>["1000"],
  "x-ratelimit-period"=>["10"],
  "x-ratelimit-remaining"=>["999"],
  "x-ratelimit-reset"=>["4"],
  "x-ratelimit-name"=>["get_all_monitors"],
  "x-content-type-options"=>["nosniff"],
  "strict-transport-security"=>["max-age=31536000; includeSubDomains; preload"],
  "via"=>["1.1 google"],
  "alt-svc"=>["h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"],
  "connection"=>["close"]}]

Expected behavior It returns the list of monitors with the mentioned tag.

Screenshots n/a

Environment and Versions (please complete the following information):

  • ruby version 3.3.5
  • gem version datadog_api_client-2.27.1
  • gem service DatadogAPIClient::V1::MonitorsAPI

Additional context

The seems to be in the API itself https://api.datadoghq.eu/api/v1/monitor or maybe the query parameter to filter tags has a different name.

martinezcoder avatar Oct 17 '24 09:10 martinezcoder

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.

github-actions[bot] avatar Nov 17 '24 00:11 github-actions[bot]

It is still not working

martinezcoder avatar Nov 18 '24 12:11 martinezcoder

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.

github-actions[bot] avatar Dec 19 '24 00:12 github-actions[bot]