Skip to content

monitoring: add logCheckFailures to uptime checks #9794

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/13661.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
monitoring: added `log_check_failures` to google_monitoring_uptime_check_config`
```
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource {
},
},
},
"log_check_failures": {
Type: schema.TypeBool,
Optional: true,
Description: `Specifies whether to log the results of failed probes to Cloud Logging.`,
},
"monitored_resource": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -498,6 +503,12 @@ func resourceMonitoringUptimeCheckConfigCreate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("selected_regions"); !tpgresource.IsEmptyValue(reflect.ValueOf(selectedRegionsProp)) && (ok || !reflect.DeepEqual(v, selectedRegionsProp)) {
obj["selectedRegions"] = selectedRegionsProp
}
logCheckFailuresProp, err := expandMonitoringUptimeCheckConfigLogCheckFailures(d.Get("log_check_failures"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("log_check_failures"); !tpgresource.IsEmptyValue(reflect.ValueOf(logCheckFailuresProp)) && (ok || !reflect.DeepEqual(v, logCheckFailuresProp)) {
obj["logCheckFailures"] = logCheckFailuresProp
}
checkerTypeProp, err := expandMonitoringUptimeCheckConfigCheckerType(d.Get("checker_type"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -669,6 +680,9 @@ func resourceMonitoringUptimeCheckConfigRead(d *schema.ResourceData, meta interf
if err := d.Set("selected_regions", flattenMonitoringUptimeCheckConfigSelectedRegions(res["selectedRegions"], d, config)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
if err := d.Set("log_check_failures", flattenMonitoringUptimeCheckConfigLogCheckFailures(res["logCheckFailures"], d, config)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
if err := d.Set("checker_type", flattenMonitoringUptimeCheckConfigCheckerType(res["checkerType"], d, config)); err != nil {
return fmt.Errorf("Error reading UptimeCheckConfig: %s", err)
}
Expand Down Expand Up @@ -740,6 +754,12 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("selected_regions"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, selectedRegionsProp)) {
obj["selectedRegions"] = selectedRegionsProp
}
logCheckFailuresProp, err := expandMonitoringUptimeCheckConfigLogCheckFailures(d.Get("log_check_failures"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("log_check_failures"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, logCheckFailuresProp)) {
obj["logCheckFailures"] = logCheckFailuresProp
}
userLabelsProp, err := expandMonitoringUptimeCheckConfigUserLabels(d.Get("user_labels"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -800,6 +820,10 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
updateMask = append(updateMask, "selectedRegions")
}

if d.HasChange("log_check_failures") {
updateMask = append(updateMask, "logCheckFailures")
}

if d.HasChange("user_labels") {
updateMask = append(updateMask, "userLabels")
}
Expand Down Expand Up @@ -994,6 +1018,10 @@ func flattenMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d *schema.
return v
}

func flattenMonitoringUptimeCheckConfigLogCheckFailures(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenMonitoringUptimeCheckConfigCheckerType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
Expand Down Expand Up @@ -1443,6 +1471,10 @@ func expandMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d tpgresour
return v, nil
}

func expandMonitoringUptimeCheckConfigLogCheckFailures(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandMonitoringUptimeCheckConfigCheckerType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fields:
- field: 'http_check.service_agent_authentication.type'
- field: 'http_check.use_ssl'
- field: 'http_check.validate_ssl'
- field: 'log_check_failures'
- field: 'monitored_resource.labels'
- field: 'monitored_resource.type'
- field: 'name'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ func TestAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpExample(t *testing.
func testAccMonitoringUptimeCheckConfig_uptimeCheckConfigHttpExample(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_monitoring_uptime_check_config" "http" {
display_name = "tf-test-http-uptime-check%{random_suffix}"
timeout = "60s"
display_name = "tf-test-http-uptime-check%{random_suffix}"
timeout = "60s"
log_check_failures = true
user_labels = {
example-key = "example-value"
}
Expand Down
9 changes: 7 additions & 2 deletions website/docs/r/monitoring_uptime_check_config.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ values will be stored in the raw state as plain text: `http_check.auth_info.pass

```hcl
resource "google_monitoring_uptime_check_config" "http" {
display_name = "http-uptime-check"
timeout = "60s"
display_name = "http-uptime-check"
timeout = "60s"
log_check_failures = true
user_labels = {
example-key = "example-value"
}
Expand Down Expand Up @@ -321,6 +322,10 @@ The following arguments are supported:
(Optional)
The list of regions from which the check will be run. Some regions contain one location, and others contain more than one. If this field is specified, enough regions to include a minimum of 3 locations must be provided, or an error message is returned. Not specifying this field will result in uptime checks running from all regions.

* `log_check_failures` -
(Optional)
Specifies whether to log the results of failed probes to Cloud Logging.

* `checker_type` -
(Optional)
The checker type to use for the check. If the monitored resource type is `servicedirectory_service`, `checker_type` must be set to `VPC_CHECKERS`.
Expand Down
Loading