Skip to content

Commit

Permalink
doc e refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mamari90 committed Nov 3, 2023
1 parent eb2a36b commit 956bc09
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 180 deletions.
2 changes: 1 addition & 1 deletion kubernetes_cluster_udr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ No modules.
| <a name="input_automatic_channel_upgrade"></a> [automatic\_channel\_upgrade](#input\_automatic\_channel\_upgrade) | (Optional) The upgrade channel for this Kubernetes Cluster. Possible values are patch, rapid, node-image and stable. Omitting this field sets this value to none. | `string` | `null` | no |
| <a name="input_custom_metric_alerts"></a> [custom\_metric\_alerts](#input\_custom\_metric\_alerts) | Map of name = criteria objects | <pre>map(object({<br> # criteria.*.aggregation to be one of [Average Count Minimum Maximum Total]<br> aggregation = string<br> # "Insights.Container/pods" "Insights.Container/nodes"<br> metric_namespace = string<br> metric_name = string<br> # criteria.0.operator to be one of [Equals NotEquals GreaterThan GreaterThanOrEqual LessThan LessThanOrEqual]<br> operator = string<br> threshold = number<br> # Possible values are PT1M, PT5M, PT15M, PT30M and PT1H<br> frequency = string<br> # Possible values are PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H and P1D.<br> window_size = string<br><br> dimension = list(object(<br> {<br> name = string<br> operator = string<br> values = list(string)<br> }<br> ))<br> }))</pre> | `{}` | no |
| <a name="input_default_metric_alerts"></a> [default\_metric\_alerts](#input\_default\_metric\_alerts) | Map of name = criteria objects | <pre>map(object({<br> # criteria.*.aggregation to be one of [Average Count Minimum Maximum Total]<br> aggregation = string<br> # "Insights.Container/pods" "Insights.Container/nodes"<br> metric_namespace = string<br> metric_name = string<br> # criteria.0.operator to be one of [Equals NotEquals GreaterThan GreaterThanOrEqual LessThan LessThanOrEqual]<br> operator = string<br> threshold = number<br> # Possible values are PT1M, PT5M, PT15M, PT30M and PT1H<br> frequency = string<br> # Possible values are PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H and P1D.<br> window_size = string<br><br> dimension = list(object(<br> {<br> name = string<br> operator = string<br> values = list(string)<br> }<br> ))<br> }))</pre> | <pre>{<br> "container_cpu": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "kubernetes namespace",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> },<br> {<br> "name": "controllerName",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "cpuExceededPercentage",<br> "metric_namespace": "Insights.Container/containers",<br> "operator": "GreaterThan",<br> "threshold": 95,<br> "window_size": "PT30M"<br> },<br> "container_memory": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "kubernetes namespace",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> },<br> {<br> "name": "controllerName",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "memoryWorkingSetExceededPercentage",<br> "metric_namespace": "Insights.Container/containers",<br> "operator": "GreaterThan",<br> "threshold": 95,<br> "window_size": "PT30M"<br> },<br> "container_oom": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "kubernetes namespace",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> },<br> {<br> "name": "controllerName",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "oomKilledContainerCount",<br> "metric_namespace": "Insights.Container/pods",<br> "operator": "GreaterThan",<br> "threshold": 0,<br> "window_size": "PT30M"<br> },<br> "container_restart": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "kubernetes namespace",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> },<br> {<br> "name": "controllerName",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "restartingContainerCount",<br> "metric_namespace": "Insights.Container/pods",<br> "operator": "GreaterThan",<br> "threshold": 0,<br> "window_size": "PT30M"<br> },<br> "node_cpu": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "host",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "cpuUsagePercentage",<br> "metric_namespace": "Insights.Container/nodes",<br> "operator": "GreaterThan",<br> "threshold": 80,<br> "window_size": "PT30M"<br> },<br> "node_disk": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "host",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> },<br> {<br> "name": "device",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "DiskUsedPercentage",<br> "metric_namespace": "Insights.Container/nodes",<br> "operator": "GreaterThan",<br> "threshold": 80,<br> "window_size": "PT30M"<br> },<br> "node_memory": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "host",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "memoryWorkingSetPercentage",<br> "metric_namespace": "Insights.Container/nodes",<br> "operator": "GreaterThan",<br> "threshold": 80,<br> "window_size": "PT30M"<br> },<br> "node_not_ready": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "status",<br> "operator": "Include",<br> "values": [<br> "NotReady"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "nodesCount",<br> "metric_namespace": "Insights.Container/nodes",<br> "operator": "GreaterThan",<br> "threshold": 0,<br> "window_size": "PT30M"<br> },<br> "pods_failed": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "phase",<br> "operator": "Include",<br> "values": [<br> "Failed"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "podCount",<br> "metric_namespace": "Insights.Container/pods",<br> "operator": "GreaterThan",<br> "threshold": 0,<br> "window_size": "PT30M"<br> },<br> "pods_ready": {<br> "aggregation": "Average",<br> "dimension": [<br> {<br> "name": "kubernetes namespace",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> },<br> {<br> "name": "controllerName",<br> "operator": "Include",<br> "values": [<br> "*"<br> ]<br> }<br> ],<br> "frequency": "PT5M",<br> "metric_name": "PodReadyPercentage",<br> "metric_namespace": "Insights.Container/pods",<br> "operator": "LessThan",<br> "threshold": 80,<br> "window_size": "PT30M"<br> }<br>}</pre> | no |
| <a name="input_disk_encryption_set_id"></a> [disk\_encryption\_set\_id](#input\_disk\_encryption\_set\_id) | ID of the disk EncryptionSet . | `string` | `null` | no |
| <a name="input_dns_prefix"></a> [dns\_prefix](#input\_dns\_prefix) | (Required) DNS prefix specified when creating the managed cluster. Changing this forces a new resource to be created. | `string` | n/a | yes |
| <a name="input_dns_prefix_private_cluster"></a> [dns\_prefix\_private\_cluster](#input\_dns\_prefix\_private\_cluster) | Specifies the DNS prefix to use with private clusters. Changing this forces a new resource to be created. | `string` | `null` | no |
| <a name="input_kubernetes_version"></a> [kubernetes\_version](#input\_kubernetes\_version) | (Required) Version of Kubernetes specified when creating the AKS managed cluster. | `string` | n/a | yes |
Expand Down Expand Up @@ -750,7 +751,6 @@ No modules.
| <a name="output_id"></a> [id](#output\_id) | n/a |
| <a name="output_identity_principal_id"></a> [identity\_principal\_id](#output\_identity\_principal\_id) | The Principal ID associated with this Managed Service Identity. |
| <a name="output_kubelet_identity_id"></a> [kubelet\_identity\_id](#output\_kubelet\_identity\_id) | The Object ID of the user-defined Managed Identity assigned to the Kubelets.If not specified a Managed Identity is created automatically. Changing this forces a new resource to be created. |
| <a name="output_managed_resource_group_id"></a> [managed\_resource\_group\_id](#output\_managed\_resource\_group\_id) | The ID of the Resource Group containing the resources for this Managed Kubernetes Cluster. |
| <a name="output_managed_resource_group_name"></a> [managed\_resource\_group\_name](#output\_managed\_resource\_group\_name) | The auto-generated Resource Group which contains the resources for this Managed Kubernetes Cluster. |
| <a name="output_name"></a> [name](#output\_name) | n/a |
| <a name="output_private_fqdn"></a> [private\_fqdn](#output\_private\_fqdn) | The FQDN for the Kubernetes Cluster when private link has been enabled, which is only resolvable inside the Virtual Network used by the Kubernetes Cluster. |
Expand Down
6 changes: 3 additions & 3 deletions postgres_flexible_server_replica/01_main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ resource "azurerm_postgresql_flexible_server" "this" {
location = var.location
resource_group_name = var.resource_group_name

create_mode = "Replica"
zone = var.zone
create_mode = "Replica"
zone = var.zone

# The provided subnet should not have any other resource deployed in it and this subnet will be delegated to the PostgreSQL Flexible Server, if not already delegated.
delegated_subnet_id = var.private_endpoint_enabled ? var.delegated_subnet_id : null
# private_dns_zobe_id will be required when setting a delegated_subnet_id
private_dns_zone_id = var.private_endpoint_enabled ? var.private_dns_zone_id : null

sku_name = var.sku_name
sku_name = var.sku_name

source_server_id = var.source_server_id

Expand Down
9 changes: 7 additions & 2 deletions postgres_flexible_server_replica/02_monitor_flexible.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#
# Monitor Metrics
#
locals {
replica_metrics = merge(local.default_replica_server_metrics, var.replica_server_metric_alerts)
main_metrics = merge(local.default_main_server_metrics, var.main_server_additional_alerts)
}

resource "azurerm_monitor_metric_alert" "replica_alerts" {
for_each = var.replica_server_metric_alerts
for_each = var.replica_metrics

enabled = var.alerts_enabled
name = "${var.name}-${upper(each.key)}"
Expand Down Expand Up @@ -32,7 +37,7 @@ resource "azurerm_monitor_metric_alert" "replica_alerts" {
}

resource "azurerm_monitor_metric_alert" "main_server_alerts" {
for_each = var.main_server_additional_alerts
for_each = var.main_metrics

enabled = var.alerts_enabled
name = "${var.name}-${upper(each.key)}"
Expand Down
32 changes: 18 additions & 14 deletions postgres_flexible_server_replica/04_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,8 @@ variable "replica_server_metric_alerts" {
# severity: The severity of this Metric Alert. Possible values are 0, 1, 2, 3 and 4. Defaults to 3.
severity = number
}))
default = {}

default = {
replica_lag = {
frequency = "PT5M"
window_size = "PT30M"
metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers"
aggregation = "Average"
metric_name = "physical_replication_delay_in_seconds"
operator = "GreaterThanOrEqual"
threshold = 240
severity = 2
}
}
}


Expand All @@ -157,8 +146,11 @@ variable "main_server_additional_alerts" {
# severity: The severity of this Metric Alert. Possible values are 0, 1, 2, 3 and 4. Defaults to 3.
severity = number
}))
default = {}
}

default = {
locals {
default_main_server_metrics = {
replication_delay_bytes = {
frequency = "PT5M"
window_size = "PT30M"
Expand All @@ -170,6 +162,18 @@ variable "main_server_additional_alerts" {
severity = 2
}
}
default_replica_server_metrics = {
replica_lag = {
frequency = "PT5M"
window_size = "PT30M"
metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers"
aggregation = "Average"
metric_name = "physical_replication_delay_in_seconds"
operator = "GreaterThanOrEqual"
threshold = 240
severity = 2
}
}
}

variable "alerts_enabled" {
Expand Down Expand Up @@ -208,7 +212,7 @@ variable "diagnostic_setting_destination_storage_id" {
}

variable "source_server_id" {
type = string
type = string
description = "(Required) Id of the source server to be replicated"
}

Expand Down
Loading

0 comments on commit 956bc09

Please sign in to comment.