Skip to content

Commit

Permalink
support new property metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbai committed Jan 14, 2025
1 parent 42a5d7e commit b464c36
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func resourceApiManagementApiDiagnostic() *pluginsdk.Resource {
ValidateFunc: logger.ValidateLoggerID,
},

"metrics_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},

"sampling_percentage": {
Type: pluginsdk.TypeFloat,
Optional: true,
Expand Down Expand Up @@ -199,6 +205,7 @@ func resourceApiManagementApiDiagnosticCreateUpdate(d *pluginsdk.ResourceData, m
parameters := apidiagnostic.DiagnosticContract{
Properties: &apidiagnostic.DiagnosticContractProperties{
LoggerId: d.Get("api_management_logger_id").(string),
Metrics: pointer.To(d.Get("metrics_enabled").(bool)),
},
}

Expand Down Expand Up @@ -332,6 +339,7 @@ func resourceApiManagementApiDiagnosticRead(d *pluginsdk.ResourceData, meta inte
format = string(pointer.From(props.OperationNameFormat))
}
d.Set("operation_name_format", format)
d.Set("metrics_enabled", pointer.From(props.Metrics))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ resource "azurerm_api_management_api_diagnostic" "test" {
http_correlation_protocol = "W3C"
verbosity = "verbose"
operation_name_format = "Name"
metrics_enabled = true
backend_request {
body_bytes = 1
Expand Down Expand Up @@ -362,6 +363,7 @@ resource "azurerm_api_management_api_diagnostic" "test" {
http_correlation_protocol = "W3C"
verbosity = "verbose"
operation_name_format = "Url"
metrics_enabled = false
}
`, r.template(data))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ func resourceApiManagementDiagnostic() *pluginsdk.Resource {
ValidateFunc: logger.ValidateLoggerID,
},

"metrics_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},

"sampling_percentage": {
Type: pluginsdk.TypeFloat,
Optional: true,
Expand Down Expand Up @@ -158,6 +164,7 @@ func resourceApiManagementDiagnosticCreateUpdate(d *pluginsdk.ResourceData, meta
parameters := diagnostic.DiagnosticContract{
Properties: &diagnostic.DiagnosticContractProperties{
LoggerId: d.Get("api_management_logger_id").(string),
Metrics: pointer.To(d.Get("metrics_enabled").(bool)),
},
}

Expand Down Expand Up @@ -280,6 +287,7 @@ func resourceApiManagementDiagnosticRead(d *pluginsdk.ResourceData, meta interfa
format = string(pointer.From(props.OperationNameFormat))
}
d.Set("operation_name_format", format)
d.Set("metrics_enabled", pointer.From(props.Metrics))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ resource "azurerm_api_management_diagnostic" "test" {
log_client_ip = false
http_correlation_protocol = "Legacy"
verbosity = "error"
metrics_enabled = false
frontend_request {
body_bytes = 100
Expand Down Expand Up @@ -310,6 +311,7 @@ resource "azurerm_api_management_diagnostic" "test" {
http_correlation_protocol = "Legacy"
verbosity = "error"
operation_name_format = "Url"
metrics_enabled = true
}
`, r.template(data))
}
2 changes: 2 additions & 0 deletions website/docs/r/api_management_api_diagnostic.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ The following arguments are supported:

* `log_client_ip` - (Optional) Log client IP address.

* `metrics_enabled` - (Optional) Whether to enable emitting custom metrics by the emit-metric policy. Defaults to `false`.

* `sampling_percentage` - (Optional) Sampling (%). For high traffic APIs, please read this [documentation](https://docs.microsoft.com/azure/api-management/api-management-howto-app-insights#performance-implications-and-log-sampling) to understand performance implications and log sampling. Valid values are between `0.0` and `100.0`.

* `verbosity` - (Optional) Logging verbosity. Possible values are `verbose`, `information` or `error`.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/api_management_diagnostic.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ The following arguments are supported:

* `log_client_ip` - (Optional) Log client IP address.

* `metrics_enabled` - (Optional) Whether to enable emitting custom metrics by the emit-metric policy. Defaults to `false`.

* `sampling_percentage` - (Optional) Sampling (%). For high traffic APIs, please read this [documentation](https://docs.microsoft.com/azure/api-management/api-management-howto-app-insights#performance-implications-and-log-sampling) to understand performance implications and log sampling. Valid values are between `0.0` and `100.0`.

* `verbosity` - (Optional) Logging verbosity. Possible values are `verbose`, `information` or `error`.
Expand Down

0 comments on commit b464c36

Please sign in to comment.