diff --git a/src/domains/fdr-common/03_cosmos_mongodb_fdr.tf b/src/domains/fdr-common/03_cosmos_mongodb_fdr.tf index e125d38812..b04cc3d949 100644 --- a/src/domains/fdr-common/03_cosmos_mongodb_fdr.tf +++ b/src/domains/fdr-common/03_cosmos_mongodb_fdr.tf @@ -44,124 +44,50 @@ resource "azurerm_cosmosdb_mongo_database" "fdr" { } - -# fdr_history -# fdr_insert -# fdr_publish - -# fdr_payment_history -# fdr_payment_insert -# fdr_payment_publish - # Collections - -# https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/indexing#compound-indexes-mongodb-server-version-36 -# Compound indexes are required if your query needs the ability to sort on multiple fields at once. -# For queries with multiple filters that don't need to sort, create multiple single field indexes instead -# of a compound index to save on indexing costs. - locals { collections = [ { - name = "fdr_history" - indexes = [{ - keys = ["_id"] # reporting_flow_name + revision - unique = true - } - ] - shard_key = null - }, - { - name = "fdr_insert" + name = "fdr_flow" indexes = [ { - keys = ["_id"] # reporting_flow_name + keys = ["_id"] # document UID unique = true }, { - keys = ["fdr"] - unique = false - }, - { - keys = ["sender.psp_id"] - unique = false - }, - { - keys = ["fdr", "revision"] + keys = ["sender.psp_id", "name", "revision"] # flow_revision_idx unique = true - } - ] - shard_key = null - }, - { - name = "fdr_publish" - indexes = [{ - keys = ["_id"] # reporting_flow_name - unique = true }, { - keys = ["fdr"] + keys = ["sender.psp_id", "receiver.organization_id", "published"] # published_flow_by_psp_idx unique = false }, { - keys = ["sender.psp_id"] + keys = ["receiver.organization_id", "sender.psp_id", "published"] # published_flow_by_organization_idx unique = false - }, - { - keys = ["receiver.organization_id"] - unique = false - }, - { - keys = ["fdr", "revision"] - unique = true - } - ] - shard_key = null - }, - { - name = "fdr_payment_history" - indexes = [{ - keys = ["_id"] # index + ref_fdr_reporting_flow_name + ref_fdr_id - unique = true } ] - shard_key = null + shard_key = null, + ttl_seconds = var.cosmos_mongo_db_fdr_params.fdr_flow_container_ttl }, { - name = "fdr_payment_insert" + name = "fdr_payment" indexes = [ { - keys = ["_id"] # index + ref_fdr_reporting_flow_name + ref_fdr_id + keys = ["_id"] # document UID unique = true }, { - keys = ["ref_fdr"] - unique = false - }, - { - keys = ["ref_fdr_sender_psp_id"] - unique = false - }, - ] - shard_key = null - }, - { - name = "fdr_payment_publish" - indexes = [ - { - keys = ["_id"] # index + ref_fdr_reporting_flow_name + ref_fdr_id + keys = ["ref_fdr.id", "index"] # payment_by_fdr_idx unique = true }, - { - keys = ["ref_fdr"] - unique = false - }, - { - keys = ["ref_fdr_sender_psp_id"] - unique = false - } + #{ + # keys = ["ref_fdr.sender_psp_id", "iuv", "created"] # payment_by_iuv_idx + # unique = false + #} ] - shard_key = null + shard_key = null, + ttl_seconds = var.cosmos_mongo_db_fdr_params.fdr_payment_container_ttl }, ] } diff --git a/src/domains/fdr-common/99_variables.tf b/src/domains/fdr-common/99_variables.tf index 09a48b8d9b..7415b934db 100644 --- a/src/domains/fdr-common/99_variables.tf +++ b/src/domains/fdr-common/99_variables.tf @@ -289,6 +289,9 @@ variable "cosmos_mongo_db_fdr_params" { throughput = number max_throughput = number container_default_ttl = number + # single container variables + fdr_flow_container_ttl = string + fdr_payment_container_ttl = string }) } diff --git a/src/domains/fdr-common/README.md b/src/domains/fdr-common/README.md index a362e389fe..89cb7b20c1 100644 --- a/src/domains/fdr-common/README.md +++ b/src/domains/fdr-common/README.md @@ -143,7 +143,7 @@ | [cidr\_subnet\_cosmosdb\_fdr](#input\_cidr\_subnet\_cosmosdb\_fdr) | Cosmos DB address space for fdr. | `list(string)` | n/a | yes | | [cidr\_subnet\_flex\_dbms](#input\_cidr\_subnet\_flex\_dbms) | Postgresql network address space. | `list(string)` | n/a | yes | | [cidr\_subnet\_storage\_account](#input\_cidr\_subnet\_storage\_account) | Storage account network address space. | `list(string)` | n/a | yes | -| [cosmos\_mongo\_db\_fdr\_params](#input\_cosmos\_mongo\_db\_fdr\_params) | n/a |
object({
enabled = bool
capabilities = list(string)
offer_type = string
server_version = string
kind = string
consistency_policy = object({
consistency_level = string
max_interval_in_seconds = number
max_staleness_prefix = number
})
main_geo_location_zone_redundant = bool
enable_free_tier = bool
additional_geo_locations = list(object({
location = string
failover_priority = number
zone_redundant = bool
}))
private_endpoint_enabled = bool
public_network_access_enabled = bool
is_virtual_network_filter_enabled = bool
backup_continuous_enabled = bool
enable_serverless = bool
enable_autoscaling = bool
throughput = number
max_throughput = number
container_default_ttl = number
})
| n/a | yes | +| [cosmos\_mongo\_db\_fdr\_params](#input\_cosmos\_mongo\_db\_fdr\_params) | n/a |
object({
enabled = bool
capabilities = list(string)
offer_type = string
server_version = string
kind = string
consistency_policy = object({
consistency_level = string
max_interval_in_seconds = number
max_staleness_prefix = number
})
main_geo_location_zone_redundant = bool
enable_free_tier = bool
additional_geo_locations = list(object({
location = string
failover_priority = number
zone_redundant = bool
}))
private_endpoint_enabled = bool
public_network_access_enabled = bool
is_virtual_network_filter_enabled = bool
backup_continuous_enabled = bool
enable_serverless = bool
enable_autoscaling = bool
throughput = number
max_throughput = number
container_default_ttl = number
# single container variables
fdr_flow_container_ttl = string
fdr_payment_container_ttl = string
})
| n/a | yes | | [cosmos\_mongo\_db\_fdr\_re\_params](#input\_cosmos\_mongo\_db\_fdr\_re\_params) | n/a |
object({
capabilities = list(string)
offer_type = string
server_version = string
kind = string
consistency_policy = object({
consistency_level = string
max_interval_in_seconds = number
max_staleness_prefix = number
})
main_geo_location_zone_redundant = bool
enable_free_tier = bool
additional_geo_locations = list(object({
location = string
failover_priority = number
zone_redundant = bool
}))
private_endpoint_enabled = bool
public_network_access_enabled = bool
is_virtual_network_filter_enabled = bool
backup_continuous_enabled = bool
enable_serverless = bool
enable_autoscaling = bool
throughput = number
max_throughput = number
container_default_ttl = number
})
| n/a | yes | | [custom\_metric\_alerts](#input\_custom\_metric\_alerts) | Map of name = criteria objects |
map(object({
# criteria.*.aggregation to be one of [Average Count Minimum Maximum Total]
aggregation = string
metric_name = string
# "Insights.Container/pods" "Insights.Container/nodes"
metric_namespace = string
# criteria.0.operator to be one of [Equals NotEquals GreaterThan GreaterThanOrEqual LessThan LessThanOrEqual]
operator = string
threshold = number
# Possible values are PT1M, PT5M, PT15M, PT30M and PT1H
frequency = string
# Possible values are PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H and P1D.
window_size = string
# severity: The severity of this Metric Alert. Possible values are 0, 1, 2, 3 and 4. Defaults to 3.
severity = number
}))
|
{
"active_connections": {
"aggregation": "Average",
"frequency": "PT5M",
"metric_name": "active_connections",
"metric_namespace": "Microsoft.DBforPostgreSQL/flexibleServers",
"operator": "GreaterThan",
"severity": 2,
"threshold": 80,
"window_size": "PT30M"
},
"connections_failed": {
"aggregation": "Total",
"frequency": "PT5M",
"metric_name": "connections_failed",
"metric_namespace": "Microsoft.DBforPostgreSQL/flexibleServers",
"operator": "GreaterThan",
"severity": 2,
"threshold": 80,
"window_size": "PT30M"
},
"cpu_percent": {
"aggregation": "Average",
"frequency": "PT5M",
"metric_name": "cpu_percent",
"metric_namespace": "Microsoft.DBforPostgreSQL/flexibleServers",
"operator": "GreaterThan",
"severity": 2,
"threshold": 4500,
"window_size": "PT30M"
},
"memory_percent": {
"aggregation": "Average",
"frequency": "PT5M",
"metric_name": "memory_percent",
"metric_namespace": "Microsoft.DBforPostgreSQL/flexibleServers",
"operator": "GreaterThan",
"severity": 2,
"threshold": 80,
"window_size": "PT30M"
},
"storage_percent": {
"aggregation": "Average",
"frequency": "PT5M",
"metric_name": "storage_percent",
"metric_namespace": "Microsoft.DBforPostgreSQL/flexibleServers",
"operator": "GreaterThan",
"severity": 2,
"threshold": 80,
"window_size": "PT30M"
}
}
| no | | [dns\_zone\_internal\_prefix](#input\_dns\_zone\_internal\_prefix) | The dns subdomain. | `string` | `null` | no | diff --git a/src/domains/fdr-common/env/weu-dev/terraform.tfvars b/src/domains/fdr-common/env/weu-dev/terraform.tfvars index f3306188f9..670e898820 100644 --- a/src/domains/fdr-common/env/weu-dev/terraform.tfvars +++ b/src/domains/fdr-common/env/weu-dev/terraform.tfvars @@ -116,7 +116,7 @@ cidr_subnet_cosmosdb_fdr = ["10.1.136.0/24"] cosmos_mongo_db_fdr_params = { enabled = true kind = "MongoDB" - capabilities = ["EnableMongo"] + capabilities = ["EnableMongo", "EnableUniqueCompoundNestedDocs"] offer_type = "Standard" consistency_policy = { consistency_level = "BoundedStaleness" @@ -140,6 +140,9 @@ cosmos_mongo_db_fdr_params = { throughput = 1000 container_default_ttl = 604800 # 7 days + + fdr_flow_container_ttl = "604800" # 7 days + fdr_payment_container_ttl = "604800" # 7 days } cosmos_mongo_db_fdr_re_params = { diff --git a/src/domains/fdr-common/env/weu-prod/terraform.tfvars b/src/domains/fdr-common/env/weu-prod/terraform.tfvars index 84a0d87f03..09f49b655e 100644 --- a/src/domains/fdr-common/env/weu-prod/terraform.tfvars +++ b/src/domains/fdr-common/env/weu-prod/terraform.tfvars @@ -118,7 +118,7 @@ cidr_subnet_cosmosdb_fdr = ["10.1.136.0/24"] cosmos_mongo_db_fdr_params = { enabled = true kind = "MongoDB" - capabilities = ["EnableMongo"] # Serverless accounts do not support multiple regions + capabilities = ["EnableMongo", "EnableUniqueCompoundNestedDocs"] # Serverless accounts do not support multiple regions offer_type = "Standard" consistency_policy = { consistency_level = "BoundedStaleness" @@ -143,6 +143,9 @@ cosmos_mongo_db_fdr_params = { container_default_ttl = 315576000 # 10 year in second + fdr_flow_container_ttl = "3024000" # 30 days + 5 days (deltaTime) + fdr_payment_container_ttl = "3024000" # 30 days + 5 days (deltaTime) + enable_serverless = false enable_autoscaling = true max_throughput = 2000 diff --git a/src/domains/fdr-common/env/weu-uat/terraform.tfvars b/src/domains/fdr-common/env/weu-uat/terraform.tfvars index af6653ceda..44adafe633 100644 --- a/src/domains/fdr-common/env/weu-uat/terraform.tfvars +++ b/src/domains/fdr-common/env/weu-uat/terraform.tfvars @@ -116,7 +116,7 @@ cidr_subnet_cosmosdb_fdr = ["10.1.136.0/24"] cosmos_mongo_db_fdr_params = { enabled = true kind = "MongoDB" - capabilities = ["EnableMongo"] + capabilities = ["EnableMongo", "EnableUniqueCompoundNestedDocs"] offer_type = "Standard" consistency_policy = { consistency_level = "BoundedStaleness" @@ -136,6 +136,9 @@ cosmos_mongo_db_fdr_params = { container_default_ttl = 2629800 # 1 month in second + fdr_flow_container_ttl = "3024000" # 30 days + 5 days (deltaTime) + fdr_payment_container_ttl = "3024000" # 30 days + 5 days (deltaTime) + enable_serverless = false enable_autoscaling = true max_throughput = 15000