terraform-provider-sumologic
terraform-provider-sumologic copied to clipboard
Better validation of `sumologic_monitor` in the provider code
There are numerous constraints on what is a valid sumologic_monitor
configuration. Some of these constraints seem to be enforced only by the Sumo Logic product (API backend) vs. Terraform provider. Thus they are not detected at terraform plan
stage, rather only they cause failure at terraform apply
.
Issue 1
Monitors Resolved and ResolvedCritical time ranges need to be equal, but there's no mention of that in the docs. Also - if they need to be equal, why do I need to specify this value twice?
triggers {
threshold_type = "GreaterThan"
threshold = 0
time_range = "-20m"
trigger_type = "Critical"
[...]
}
triggers {
threshold_type = "LessThanOrEqual"
threshold = 0
time_range = "-30m"
occurrence_type = "ResultCount"
detection_method = "StaticCondition"
[...]
}
yields:
13:25:22 Error: {"id":"QVP7L-50PLW-K7I5Y","errors":[{"code":"monitors:unsupported_trigger_time_range","message":"Unsupported trigger time range.","detail":"ResolvedCritical trigger must have the same time range as Critical trigger's time range."}]}
Issue 2
10:02:49 Error: {"id":"I2CPZ-S1U0I-AJAMO","errors":[{"code":"service.argument.invalid","message":"The request body you've provided is invalid. [Invalid field: triggers[1].thresholdType should be one of the following: 'LessThan', 'GreaterThan', 'LessThanOrEqual', or 'GreaterThanOrEqual'] "}]}
Issue 3
09:10:32 Error: {"id":"0SZKJ-UDKVX-IXKTC","errors":[{"code":"monitors:unsupported_trigger_source","message":"Unsupported triggerSource for the given monitorType.","detail":"Unsupported triggerSource for the given monitorType.'AllTimeSeries' and 'AnyTimeSeries' are the valid triggerSource for a metrics monitor."}]}
Issue 4
Error: {"id":"EIYJ9-UU73C-EIFAE","errors":[{"code":"monitors:invalid_detection_method","message":"Invalid detection method.","detail":" Critical and ResolvedCritical should have the same detection method."}]}
Issue 5
Error: {"id":"8YVLR-QMYTX-CTKXM","errors":[{"code":"monitors:missing_excepted_triggers","message":"Monitor needs both alert and resolution trigger.","detail":"Monitor needs both alert and resolution trigger. Warning trigger needs its corresponding ResolvedWarning trigger."}]}
Issue 6
17:22:16 │ Error: {"id":"B2YBE-C9VYY-HE85B","errors":[{"code":"monitors:unsupported_trigger_condition","message":"Unsupported trigger condition.","detail":"Unsupported trigger condition. MetricsStaticCondition feature is not available yet."}]}
Issue 7
{"id":"IVFRN-X4WH4-210EV","errors":[{"code":"monitors:invalid_notification_run_for_trigger_types","message":"Invalid RunForTriggerTypes for notification(s).","detail":"All notification types should have 'Trigger Type' configured. Missing ones: Warning."}]}
Issue 8
{"id":"3WM4Q-F2MFL-QI6Q3","errors":[{"code":"monitors:invalid_occurrence_type","message":"Invalid occurrenceType.","detail":"Invalid occurrenceType. Metrics Monitors only support Always as the occurrenceType for resolution triggers."}]}
Issue 9
Error: {"id":"RNTAM-1V9J4-VP438","errors":[{"code":"content:invalid_name","message":"Invalid name.","detail":"Name must not contain an invalid character. [Invalid characters=/]."}]}
Issue 10
{"id":"UGWGZ-L45JW-ILJ1U","errors":[{"code":"monitors:invalid_trigger_threshold","message":"Invalid threshold configuration.","detail":"Invalid threshold configuration. Critical trigger's threshold 2500.0 does not fall in between 0 and 1000."}]}
That's for:
threshold_type = "GreaterThan"
threshold = 2500
time_range = "1d"
occurrence_type = "ResultCount"
using Logs
Issue 11
Error: {"id":"05N4E-X22Q9-QLTFD","errors":[{"code":"monitors:invalid_group_notification_configuration","message":"Separate notifications are not supported for Log monitors","detail":"Separate notifications are not allowed for Log Monitors. Please use group notifications instead."}]}
for a log monitor - as mentioned in #391
Issue 12
Error: {"id":"R25ON-UE7DC-6KFYB","errors":[{"code":"content:invalid_description","message":"Description is invalid.","detail":"Description must not contain leading or trailing spaces."}]}
Issue 13
Error: {"id":"CME0X-ZHLL4-8PGIS","errors":[{"code":"monitors.invalid_detection_method_for_monitor_type","message":"Invalid detection method for monitor type.","detail":"Invalid detection method for monitor type. StaticCondition, MetricsStaticCondition, MetricsOutlierCondition and MetricsMissingDataConditions are allowed for metrics monitors."}]}
Issue 14
Error: {"id":"WRVVA-U63XU-XNSFT","errors":[{"code":"monitors:invalid_occurrence_type","message":"Invalid occurrenceType.","detail":"Invalid occurrenceType. Log Monitors only support ResultCount and MissingData as the occurrenceType."}]}
for a mix of log and metrics definition:
monitor_type = "Logs"
[...]
trigger_conditions {
metrics_static_condition {
Issue 15
Error: {"id":"AJMJV-O318Z-OT3NM","errors":[{"code":"monitors:unsupported_trigger_time_range","message":"Unsupported trigger time range.","detail":"Unsupported trigger timeRange. Allowed values are: 5 min, 10 min, 15 min, 30 min, 60 min, 180 min, 360 min, 720 min, 1440 min"}]}
Issue 16
Error: {"id":"DSCV1-7HYJX-0WX1K","errors":[{"code":"monitors:conflicting_triggers","message":"Resolution trigger conditions should not overlap with alert trigger conditions.","detail":"Critical trigger with threshold (GreaterThanOrEqual 1.0) is overlapping ResolvedCritical trigger with threshold (LessThanOrEqual 1.0). Resolution trigger conditions should not overlap with alert trigger conditions."}]}
with:
alert {
threshold = 1
threshold_type = "GreaterThanOrEqual"
}
resolution {
threshold = 1
threshold_type = "LessThanOrEqual"
}
Issue 17
{"id":"O5OBB-9AC89-7J5YZ","errors":[{"code":"monitors.invalid_resolution_window","message":"Invalid Resolution Window.","detail":"Invalid resolution window. Resolution window cannot be greater than your trigger timerange of 15 min."}]}
Also the documentation seems to be lacking. Other than examples given, at https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/monitor I don't see what are the options to be put under a triggers
entry. It only says:
triggers - (Required) Defines the conditions of when to send notifications.
#194 is one special case of it.
https://github.com/SumoLogic/terraform-provider-sumologic/pull/223 addresses issues 2 and 3 above.
This got closed automatically after the PR was merged. Reopening this since some of the issues mentioned here are not addressed by the PR.
Added Issue 11 as per #391
Added Issue 12
(Internal JIRA: SUMO-181080)
Added Issue 14
Added issue no. 16
Added Issue 17