Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't apply a monitor after setting a silence from the UI: is already unmuted #181

Closed
iksaif opened this issue Apr 24, 2019 · 2 comments · Fixed by zorkian/go-datadog-api#238
Assignees

Comments

@iksaif
Copy link

iksaif commented Apr 24, 2019

Terraform Version

$ terraform -v
Terraform v0.11.10

Affected Resource(s)

  • datadog_momnitor

Terraform Configuration Files

resource "datadog_monitor" "test" {
    name = "test"
    type = "metric alert"
    message = "test"

  query = "avg(last_5m):max:system.load.1{${var.common_filters},${var.datacenter_filters},node-role.kubernetes.io/logs-seed} by {host} > 100"

  thresholds {
      critical = 100
  }

  notify_no_data = false
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

When adding a manual downtime via the UI on one of the groups:

Screenshot (92)

This happens:

Acquiring state lock. This may take a few moments...
datadog_monitor.logs_test: Refreshing state... (ID: xxxxx)
datadog_monitor.logs_test: Modifying... (ID: xxxxx)
  silenced.%:                        "1" => "0"
  silenced.host:i-xxxxxxxxxxxx: "0" => ""
Releasing state lock. This may take a few moments...

Error: Error applying plan:

1 error(s) occurred:

* datadog_monitor.logs_test: 1 error(s) occurred:

* datadog_monitor.logs_test: API error 400 Bad Request: {"errors":["metric alert \"[Logs] [us1.staging.dog] Logs test\" is already unmuted"]}

Actual Behavior

  • My monitor gets updated
  • My manually set silence does not get removed

Steps to Reproduce

  1. terraform apply a grouped by monitor
  2. Mute one of the groups
  3. terraform apply again

Important Factoids

Reverting 17eea5f fixes the issue.

@bkabrda bkabrda self-assigned this May 10, 2019
@bkabrda
Copy link
Contributor

bkabrda commented May 10, 2019

So the referenced commit fixed an issue where removing the silenced block from the monitor config, which would then not be removed from the actual monitor. In order to do that, it calls the /api/v1/monitor/<id>/unmute endpoint (without JSON payload). When the referenced commit is reverted, doing the second terraform apply doesn't actually unmute it - the silenced attribute will stay the same - which is exactly the issue that the commit fixed.

The issue with calling the unmute endpoint without a payload is that it tries to unmute the * scope, which in the reproducer above is already unmuted, so the API returns a correct response.

The proper solution is calling the unmute endpoint with {"all_scopes": true} as JSON payload. This will ensure that all muted scopes are removed and works even if * is not among them.

Fixing this is not hard, but it will require a fix in the go-datadog-api library first, since that doesn't support attaching JSON payloads to calls to the unmute endpoint.

@bkabrda
Copy link
Contributor

bkabrda commented May 10, 2019

So in addition to the above, we should:

  • Document that the above solution would disable any created datadog_downtime that has monitor_id set [1].
  • Document usage of lifecycle, more specifically ignore_changes which would avoid touching any changes done by hand or by adding a downtime with monitor_id.

[1] https://www.terraform.io/docs/providers/datadog/r/downtime.html#monitor_id

@bkabrda bkabrda reopened this May 13, 2019
bkabrda pushed a commit that referenced this issue May 13, 2019
Fix and provide better docs for (un)muting monitors. Fixes #181
jbenais pushed a commit to jbenais/terraform-provider-datadog that referenced this issue Aug 20, 2019
jbenais pushed a commit to jbenais/terraform-provider-datadog that referenced this issue Aug 20, 2019
Fix and provide better docs for (un)muting monitors. Fixes DataDog#181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants