Skip to content

Commit

Permalink
Add Log Analytics (#548)
Browse files Browse the repository at this point in the history
* fix: update deprecated azure terraform fields

* feat: add new log analytics workspace for gratibot logs
  • Loading branch information
Pactionly authored Jun 24, 2024
1 parent 2268571 commit fc51e17
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion infra/terraform/cosmosdb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resource "azurerm_cosmosdb_account" "db_account" {
offer_type = "Standard"
kind = "MongoDB"

enable_automatic_failover = true
automatic_failover_enabled = true

capabilities { # forces replacement
name = "EnableMongo"
Expand Down
22 changes: 22 additions & 0 deletions infra/terraform/log-analytics.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resource "azurerm_log_analytics_workspace" "gratibot" {
name = "gratibot-${var.environment}"
location = var.location
resource_group_name = var.resource_group_name
sku = "PerGB2018"
retention_in_days = 30
daily_quota_gb = 0.5
}

resource "azurerm_monitor_diagnostic_setting" "gratibot-logs" {
name = "gratibot-logs"
target_resource_id = azurerm_linux_web_app.gratibot_app_service.id
log_analytics_workspace_id = azurerm_log_analytics_workspace.gratibot.id

enabled_log {
category = "AppServiceConsoleLogs"
}
metric {
category = "AllMetrics"
enabled = false
}
}
2 changes: 1 addition & 1 deletion infra/terraform/vault.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "azurerm_role_assignment" "gratibot" {

resource "azurerm_key_vault_secret" "mongo_connection_string" {
name = "mongo-connection-string"
value = azurerm_cosmosdb_account.db_account.connection_strings[0]
value = azurerm_cosmosdb_account.db_account.primary_mongodb_connection_string
key_vault_id = data.azurerm_key_vault.gratibot.id
}

Expand Down

0 comments on commit fc51e17

Please sign in to comment.