Skip to content

Commit

Permalink
DTSPO-15909 - migrated Application Insights (#136)
Browse files Browse the repository at this point in the history
* DTSPO-15909 - migrated Application Insights

* fix tf version
  • Loading branch information
cpareek authored Jan 4, 2024
1 parent 73a08a8 commit 83d4d1f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .terraform-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.7
1.6.6
27 changes: 14 additions & 13 deletions app-insights.tf
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
resource "azurerm_key_vault_secret" "AZURE_APPINSIGHTS_KEY" {
name = "app-insights-instrumentation-key"
value = azurerm_application_insights.appinsights.instrumentation_key
value = module.application_insights.instrumentation_key
key_vault_id = module.vault.key_vault_id
}

resource "azurerm_key_vault_secret" "app_insights_connection_string" {
name = "app-insights-connection-string"
value = azurerm_application_insights.appinsights.connection_string
value = module.application_insights.connection_string
key_vault_id = module.vault.key_vault_id
}

resource "azurerm_application_insights" "appinsights" {
name = "${var.product}-${var.env}"
module "application_insights" {
source = "[email protected]:hmcts/terraform-module-application-insights?ref=main"

env = var.env
product = var.product
location = var.location
resource_group_name = azurerm_resource_group.rg.name
application_type = var.application_type
tags = var.common_tags
resource_group_name = azurerm_resource_group.rg.name

common_tags = var.common_tags
}

lifecycle {
ignore_changes = [
# Ignore changes to appinsights as otherwise upgrading to the Azure provider 2.x
# destroys and re-creates this appinsights instance
application_type,
]
}
moved {
from = azurerm_application_insights.appinsights
to = module.application_insights.azurerm_application_insights.this
}
4 changes: 2 additions & 2 deletions exception-alert.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// single alert to minify unnecessary cost because threshold used in here is minimal
module "reform-scan-exception-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Reform_Scan_exception"
Expand Down
8 changes: 4 additions & 4 deletions liveness-alert.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "blob-router-service-liveness-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Blob_Router_Service_liveness"
Expand All @@ -26,8 +26,8 @@ EOF

module "reform-scan-notification-service-liveness-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Reform_Scan_Notification_Service_liveness"
Expand Down
12 changes: 6 additions & 6 deletions no-envelopes-processed-alert.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "no-cft-envelopes-processed-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "No_cft_envelopes_processed_-_Blob_Router"
Expand All @@ -25,8 +25,8 @@ EOF

module "no-crime-envelopes-processed-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "No_crime_envelopes_processed_-_Blob_Router"
Expand All @@ -50,8 +50,8 @@ EOF

module "no-pcq-envelopes-processed-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "No_pcq_envelopes_processed_-_Blob_Router"
Expand Down
13 changes: 6 additions & 7 deletions notification-alert.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module "reform-scan-notifications-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name

enabled = var.env == "prod"
alert_name = "Reform_Scan_notification"
alert_desc = "Triggers when notification service receives at least 5 notifications within a 30 minutes window timeframe."
common_tags = var.common_tags
location = var.location
app_insights_name = module.application_insights.name
enabled = var.env == "prod"
alert_name = "Reform_Scan_notification"
alert_desc = "Triggers when notification service receives at least 5 notifications within a 30 minutes window timeframe."
common_tags = var.common_tags

app_insights_query = "traces | where message startswith 'Started processing notification message'"

Expand Down
32 changes: 16 additions & 16 deletions scheduled-jobs-alert.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "blob-dispatcher-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Dispatch_Files"
Expand All @@ -22,8 +22,8 @@ module "blob-dispatcher-alert" {

module "delete-dispatched-files-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Delete_Dispatched_Files"
Expand All @@ -44,8 +44,8 @@ module "delete-dispatched-files-alert" {

module "handle-rejected-files-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Handle_Rejected_Files"
Expand All @@ -69,8 +69,8 @@ module "handle-rejected-files-alert" {

module "reject-duplicates-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Reject_Duplicates"
Expand All @@ -94,8 +94,8 @@ module "reject-duplicates-alert" {

module "delete-rejected-files-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Delete_Rejected_Files"
Expand All @@ -119,8 +119,8 @@ module "delete-rejected-files-alert" {

module "check-new-envelopes-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Check-New-Envelopes"
Expand All @@ -142,8 +142,8 @@ module "check-new-envelopes-alert" {

module "send-notifications-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Reform-Scan-Send-Notifications"
Expand All @@ -164,8 +164,8 @@ module "send-notifications-alert" {

module "send-notifications-to-scan-provider-alert" {
source = "[email protected]:hmcts/cnp-module-metric-alert"
location = azurerm_application_insights.appinsights.location
app_insights_name = azurerm_application_insights.appinsights.name
location = var.location
app_insights_name = module.application_insights.name

enabled = var.env == "prod"
alert_name = "Reform-Scan-Pending-Notifications"
Expand Down

0 comments on commit 83d4d1f

Please sign in to comment.