@@ -251,21 +251,10 @@ func getMonitorSchema() map[string]*schema.Schema {
251251 Optional : true ,
252252 ValidateFunc : validation .StringInSlice ([]string {"Critical" , "Warning" , "MissingData" , "ResolvedCritical" , "ResolvedWarning" , "ResolvedMissingData" }, false ),
253253 },
254- "threshold" : {
255- Type : schema .TypeFloat ,
256- Optional : true ,
257- },
258- "threshold_type" : {
259- Type : schema .TypeString ,
260- Optional : true ,
261- ValidateFunc : validation .StringInSlice ([]string {"LessThan" , "LessThanOrEqual" , "GreaterThan" , "GreaterThanOrEqual" }, false ),
262- },
263- "time_range" : {
264- Type : schema .TypeString ,
265- Optional : true ,
266- ValidateFunc : validation .StringMatch (regexp .MustCompile (`^-?(\d)+[smhd]$` ), "Time range must be in the format '-?\\ d+[smhd]'. Examples: -15m, 1d, etc." ),
267- DiffSuppressFunc : SuppressEquivalentTimeDiff (false ),
268- },
254+ "threshold" : & thresholdSchema ,
255+ "threshold_type" : & thresholdTypeSchema ,
256+ "time_range" : & timeRangeWithFormatSchema ,
257+ "frequency" : & frequencySchema ,
269258 "trigger_source" : {
270259 Type : schema .TypeString ,
271260 Optional : true ,
@@ -490,6 +479,7 @@ var logsStaticTriggerConditionSchema = map[string]*schema.Schema{
490479 },
491480 "critical" : nestedWithAtleastOneOfKeys (true , schemaMap {
492481 "time_range" : & timeRangeWithAllowedValuesSchema ,
482+ "frequency" : & frequencySchema ,
493483 "alert" : nested (false , schemaMap {
494484 "threshold" : & thresholdSchema ,
495485 "threshold_type" : & thresholdTypeSchema ,
@@ -502,6 +492,7 @@ var logsStaticTriggerConditionSchema = map[string]*schema.Schema{
502492 }, logStaticConditionCriticalOrWarningAtleastOneKeys ),
503493 "warning" : nestedWithAtleastOneOfKeys (true , schemaMap {
504494 "time_range" : & timeRangeWithAllowedValuesSchema ,
495+ "frequency" : & frequencySchema ,
505496 "alert" : nested (false , schemaMap {
506497 "threshold" : & thresholdSchema ,
507498 "threshold_type" : & thresholdTypeSchema ,
@@ -587,6 +578,7 @@ var metricsOutlierTriggerConditionSchema = map[string]*schema.Schema{
587578
588579var logsMissingDataTriggerConditionSchema = map [string ]* schema.Schema {
589580 "time_range" : & timeRangeWithAllowedValuesSchema ,
581+ "frequency" : & frequencySchema ,
590582}
591583
592584var metricsMissingDataTriggerConditionSchema = map [string ]* schema.Schema {
@@ -813,6 +805,12 @@ var thresholdTypeSchema = schema.Schema{
813805 ValidateFunc : validation .StringInSlice ([]string {"LessThan" , "LessThanOrEqual" , "GreaterThan" , "GreaterThanOrEqual" }, false ),
814806}
815807
808+ var frequencySchema = schema.Schema {
809+ Type : schema .TypeString ,
810+ Optional : true ,
811+ ValidateFunc : validation .StringMatch (regexp .MustCompile (`^(\d)+[smhd]` ), "Frequency time must be in the format '\\ d+[smhd]'. Examples: 1m, 2m, 10m, 20m, 1h" ),
812+ }
813+
816814func resourceSumologicMonitorsLibraryMonitorCreate (d * schema.ResourceData , meta interface {}) error {
817815 c := meta .(* Client )
818816
@@ -975,6 +973,7 @@ func resourceSumologicMonitorsLibraryMonitorRead(d *schema.ResourceData, meta in
975973 for i , t := range monitor .Triggers {
976974 triggers [i ] = map [string ]interface {}{
977975 "time_range" : t .PositiveTimeRange (),
976+ "frequency" : t .Frequency ,
978977 "trigger_type" : t .TriggerType ,
979978 "threshold" : t .Threshold ,
980979 "threshold_type" : t .ThresholdType ,
@@ -1138,6 +1137,7 @@ func getTriggers(d *schema.ResourceData) []TriggerCondition {
11381137 Threshold : triggerDict ["threshold" ].(float64 ),
11391138 ThresholdType : triggerDict ["threshold_type" ].(string ),
11401139 TimeRange : triggerDict ["time_range" ].(string ),
1140+ Frequency : triggerDict ["frequency" ].(string ),
11411141 OccurrenceType : triggerDict ["occurrence_type" ].(string ),
11421142 TriggerSource : triggerDict ["trigger_source" ].(string ),
11431143 MinDataPoints : triggerDict ["min_data_points" ].(int ),
@@ -1244,11 +1244,13 @@ func metricsOutlierConditionBlockToJson(block map[string]interface{}) []TriggerC
12441244func logsMissingDataConditionBlockToJson (block map [string ]interface {}) []TriggerCondition {
12451245 alert := TriggerCondition {
12461246 TimeRange : block ["time_range" ].(string ),
1247+ Frequency : block ["frequency" ].(string ),
12471248 DetectionMethod : logsMissingDataConditionDetectionMethod ,
12481249 TriggerType : "MissingData" ,
12491250 }
12501251 resolution := TriggerCondition {
12511252 TimeRange : block ["time_range" ].(string ),
1253+ Frequency : block ["frequency" ].(string ),
12521254 DetectionMethod : logsMissingDataConditionDetectionMethod ,
12531255 TriggerType : "ResolvedMissingData" ,
12541256 }
@@ -1382,22 +1384,26 @@ func jsonToLogsStaticConditionBlock(conditions []TriggerCondition) map[string]in
13821384 case "Critical" :
13831385 hasCritical = true
13841386 criticalDict ["time_range" ] = condition .PositiveTimeRange ()
1387+ criticalDict ["frequency" ] = condition .Frequency
13851388 criticalAlrt ["threshold" ] = condition .Threshold
13861389 criticalAlrt ["threshold_type" ] = condition .ThresholdType
13871390 case "ResolvedCritical" :
13881391 hasCritical = true
13891392 criticalDict ["time_range" ] = condition .PositiveTimeRange ()
1393+ criticalDict ["frequency" ] = condition .Frequency
13901394 criticalRslv ["threshold" ] = condition .Threshold
13911395 criticalRslv ["threshold_type" ] = condition .ThresholdType
13921396 criticalRslv ["resolution_window" ] = condition .PositiveResolutionWindow ()
13931397 case "Warning" :
13941398 hasWarning = true
13951399 warningDict ["time_range" ] = condition .PositiveTimeRange ()
1400+ warningDict ["frequency" ] = condition .Frequency
13961401 warningAlrt ["threshold" ] = condition .Threshold
13971402 warningAlrt ["threshold_type" ] = condition .ThresholdType
13981403 case "ResolvedWarning" :
13991404 hasWarning = true
14001405 warningDict ["time_range" ] = condition .PositiveTimeRange ()
1406+ warningDict ["frequency" ] = condition .Frequency
14011407 warningRslv ["threshold" ] = condition .Threshold
14021408 warningRslv ["threshold_type" ] = condition .ThresholdType
14031409 warningRslv ["resolution_window" ] = condition .PositiveResolutionWindow ()
@@ -1690,6 +1696,7 @@ func jsonToLogsMissingDataConditionBlock(conditions []TriggerCondition) map[stri
16901696 block := map [string ]interface {}{}
16911697 firstCondition := conditions [0 ]
16921698 block ["time_range" ] = firstCondition .PositiveTimeRange ()
1699+ block ["frequency" ] = firstCondition .Frequency
16931700 return block
16941701}
16951702
@@ -1842,6 +1849,8 @@ func (condition *TriggerCondition) readFrom(block map[string]interface{}) {
18421849 switch k {
18431850 case "time_range" :
18441851 condition .TimeRange = v .(string )
1852+ case "frequency" :
1853+ condition .Frequency = v .(string )
18451854 case "trigger_type" :
18461855 condition .TriggerType = v .(string )
18471856 case "threshold" :
0 commit comments