Skip to content

Commit 21dff6d

Browse files
Merge branch 'master' into mzochowski-201717-add-supression-diff-rule-for-time-formats
2 parents d070aa0 + 8f8e145 commit 21dff6d

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 2.19.2 (Unreleased)
22
ENHANCEMENTS:
33
* Suppress diffs for equivalent values of some time attributes. This should reduce output of `terraform plan` that didn't disappear after running `terraform apply`. (GH-442)
4+
* Add better validation and documentation for some time attributes (GH-443)
45

56
## 2.19.1 (October 6, 2022)
67
FEATURES:

sumologic/resource_sumologic_monitors_library_monitor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func resourceSumologicMonitorsLibraryMonitor() *schema.Resource {
107107
"time_range": {
108108
Type: schema.TypeString,
109109
Optional: true,
110-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`-?(\d)+[smhd]`), "Time range must be in the format '-?\\d+[smhd]'. Examples: -15m, 1d, etc."),
110+
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^-?(\d)+[smhd]$`), "Time range must be in the format '-?\\d+[smhd]'. Examples: -15m, 1d, etc."),
111111
DiffSuppressFunc: SuppressEquivalentTimeDiff(false),
112112
},
113113
"trigger_source": {
@@ -296,7 +296,7 @@ func resourceSumologicMonitorsLibraryMonitor() *schema.Resource {
296296
Type: schema.TypeString,
297297
Optional: true,
298298
Computed: true,
299-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`((\d)+[smh])+`), "This value is not in correct format. Example: 1m30s"),
299+
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^((\d)+[smh])+$`), "This value is not in correct format. Example: 1m30s"),
300300
DiffSuppressFunc: SuppressEquivalentTimeDiff(false),
301301
},
302302

@@ -551,14 +551,14 @@ var consecutiveSchema = schema.Schema{
551551
var timeRangeSchema = schema.Schema{
552552
Type: schema.TypeString,
553553
Required: true,
554-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`-?(\d)+[smhd]`), "Time range must be in the format '-?\\d+[smhd]'. Examples: -15m, 1d, etc."),
554+
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^-?(\d)+[smhd]$`), "Time range must be in the format '-?\\d+[smhd]'. Examples: -15m, 1d, etc."),
555555
DiffSuppressFunc: SuppressEquivalentTimeDiff(false),
556556
}
557557

558558
var relativeTimeRangeSchema = schema.Schema{
559559
Type: schema.TypeString,
560560
Required: true,
561-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`-?(\d)+[smhd]`), "Time range must be in the format '-?\\d+[smhd]'. Examples: -15m, 1d, etc."),
561+
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^-?(\d)+[smhd]$`), "Time range must be in the format '-?\\d+[smhd]'. Examples: -15m, 1d, etc."),
562562
DiffSuppressFunc: SuppressEquivalentTimeDiff(true),
563563
}
564564

sumologic/util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ func GetTimeRangeBoundarySchema() map[string]*schema.Schema {
176176
"relative_time": {
177177
Type: schema.TypeString,
178178
Required: true,
179+
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^-?((\d)+[smhdw])+$`), "This value is not in correct format. Example: -2w5d3h"),
179180
DiffSuppressFunc: SuppressEquivalentTimeDiff(true),
180181
},
181182
},

website/docs/r/dashboard.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ schema for details.
322322
- `iso8601_time` - (Required) Time as a string in ISO 8601 format.
323323

324324
- `relative_time_range` - (Block List, Optional) Time in relative format.
325-
- `relative_time` - (Required) Relative time as a string consisting of following elements:
325+
- `relative_time` - (Required) Relative time as a string consists of following elements:
326326
1. `-` (optional): minus sign indicates time in the past,
327327
2. `<number>`: number of time units,
328328
3. `<time_unit>`: time unit; possible values are: `w` (week), `d` (day), `h` (hour), `m` (minute), `s` (second).

website/docs/r/monitor.html.markdown

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ The following arguments are supported:
315315
- `Logs`: A logs query monitor.
316316
- `Metrics`: A metrics query monitor.
317317
- `Slo`: A SLO based monitor (beta).
318+
- `evaluation_delay` - (Optional) Evaluation delay as a string consists of the following elements:
319+
1. `<number>`: number of time units,
320+
2. `<time_unit>`: time unit; possible values are: `h` (hour), `m` (minute), `s` (second).
321+
322+
Multiple pairs of `<number><time_unit>` may be provided. For example,
323+
`2m50s` means 2 minutes and 50 seconds.
318324
- `slo_id` - (Optional) Identifier of the SLO definition for the monitor. This is only applicable & required for Slo `monitor_type`.
319325
- `queries` - (Required) All queries from the monitor.
320326
- `trigger_conditions` - (Required if not using `triggers`) Defines the conditions of when to send notifications. NOTE: `trigger_conditions` supplants the `triggers` argument.
@@ -400,26 +406,26 @@ Here is a summary of arguments for each condition type (fields which are not mar
400406
#### logs_static_condition
401407
- `field`
402408
- `critical`
403-
- `time_range` (Required)
409+
- `time_range` (Required) : Accepted format: Optional `-` sign followed by `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `30m`, `-12h`.
404410
- `alert` (Required)
405411
- `threshold`
406412
- `threshold_type`
407413
- `resolution` (Required)
408414
- `threshold`
409415
- `threshold_type`
410-
- `resolution_window`
416+
- `resolution_window` Accepted format: `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `0s, 30m`.
411417
- `warning`
412-
- `time_range` (Required)
418+
- `time_range` (Required) : Accepted format: Optional `-` sign followed by `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `30m`, `-12h`.
413419
- `alert` (Required)
414420
- `threshold`
415421
- `threshold_type`
416422
- `resolution` (Required)
417423
- `threshold`
418424
- `threshold_type`
419-
- `resolution_window`
425+
- `resolution_window` Accepted format: `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `0s, 30m`.
420426
#### metrics_static_condition
421427
- `critical`
422-
- `time_range` (Required)
428+
- `time_range` (Required) : Accepted format: Optional `-` sign followed by `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `30m`, `-12h`.
423429
- `occurrence_type` (Required)
424430
- `alert` (Required)
425431
- `threshold`
@@ -428,7 +434,7 @@ Here is a summary of arguments for each condition type (fields which are not mar
428434
- `threshold`
429435
- `threshold_type`
430436
- `warning`
431-
- `time_range` (Required)
437+
- `time_range` (Required) : Accepted format: Optional `-` sign followed by `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `30m`, `-12h`.
432438
- `occurrence_type` (Required)
433439
- `alert` (Required)
434440
- `threshold`
@@ -456,10 +462,9 @@ Here is a summary of arguments for each condition type (fields which are not mar
456462
- `baseline_window`
457463
- `threshold`
458464
#### logs_missing_data_condition
459-
- `time_range` (Required)
465+
- `time_range` (Required) : Accepted format: Optional `-` sign followed by `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `30m`, `-12h`.
460466
#### metrics_missing_data_condition
461-
- `time_range` (Required)
462-
- `trigger_source` (Required)
467+
- `time_range` (Required) : Accepted format: Optional `-` sign followed by `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `30m`, `-12h`.
463468
#### slo_sli_condition
464469
- `critical`
465470
- `sli_threshold` (Required) : The remaining SLI error budget threshold percentage [0,100).
@@ -468,10 +473,10 @@ Here is a summary of arguments for each condition type (fields which are not mar
468473

469474
#### slo_burn_rate_condition
470475
- `critical`
471-
- `time_range` (Required) : The relative time range for the burn rate percentage evaluation.
476+
- `time_range` (Required) : The relative time range for the burn rate percentage evaluation. Accepted format: Optional `-` sign followed by `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `30m`, `-12h`.
472477
- `burn_rate_threshold` (Required) : The burn rate percentage threshold.
473478
- `warning`
474-
- `time_range` (Required)
479+
- `time_range` (Required) : Accepted format: Optional `-` sign followed by `<number>` followed by a `<time_unit>` character: `s` for seconds, `m` for minutes, `h` for hours, `d` for days. Examples: `30m`, `-12h`.
475480
- `burn_rate_threshold` (Required)
476481

477482
## The `triggers` block

0 commit comments

Comments
 (0)