Skip to content

Commit ef1080a

Browse files
authored
Merge pull request Azure-Samples#25 from Azure-Samples/app-insights
chore: Add Azure Application Insights for observability
2 parents cf6f011 + ebb3f29 commit ef1080a

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

infra/manifests/api/config.tmpl.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ data:
1313
AZURE_SEARCH_ENDPOINT: {{.Env.AZURE_SEARCH_ENDPOINT}}
1414
AZURE_SEARCH_API_KEY: {{.Env.AZURE_SEARCH_API_KEY}}
1515
AZURE_SEARCH_INDEX_NAME: {{.Env.AZURE_SEARCH_INDEX_NAME}}
16+
APPLICATIONINSIGHTS_CONNECTION_STRING: {{.Env.APPLICATIONINSIGHTS_CONNECTION_STRING}}
1617
VECTORDB_TYPE: {{.Env.VECTORDB_TYPE}}
1718

infra/manifests/api/deployment.tmpl.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ spec:
4242
value: {{.Env.AZURE_SEARCH_INDEX_NAME}}
4343
- name: VECTORDB_TYPE
4444
value: {{.Env.VECTORDB_TYPE}}
45+
- name: APPLICATIONINSIGHTS_CONNECTION_STRING
46+
value: {{.Env.APPLICATIONINSIGHTS_CONNECTION_STRING}}
4547
resources:
4648
requests:
4749
memory: "256Mi"

infra/observability.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,14 @@ resource "azurerm_monitor_data_collection_rule_association" "example_msci_to_aks
5757
target_resource_id = azurerm_kubernetes_cluster.aks[0].id
5858
data_collection_rule_id = azurerm_monitor_data_collection_rule.example_msci[0].id
5959
}
60+
61+
62+
resource "azurerm_application_insights" "applicationinsights" {
63+
count = local.deploy_observability_tools ? 1 : 0
64+
name = "ai-${local.resource_token}"
65+
location = azurerm_resource_group.rg.location
66+
resource_group_name = azurerm_resource_group.rg.name
67+
application_type = "web"
68+
workspace_id = azurerm_log_analytics_workspace.example[0].id
69+
tags = local.tags
70+
}

infra/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ output "AZURE_RESOURCE_GROUP" {
7070
output "AZURE_TENANT_ID" {
7171
value = data.azurerm_client_config.current.tenant_id
7272
}
73+
7374
output "AZURE_SEARCH_ENDPOINT" {
7475
value = "https://${azurerm_search_service.search.name}.search.windows.net"
7576
}
@@ -95,3 +96,8 @@ output "BING_SEARCH_KEY" {
9596
value = jsondecode(data.azapi_resource_action.bing.output).key1
9697
sensitive = true
9798
}
99+
100+
output "APPLICATIONINSIGHTS_CONNECTION_STRING" {
101+
value = local.deploy_observability_tools ? "" : azurerm_application_insights.applicationinsights[0].connection_string
102+
sensitive = true
103+
}

infra/search.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ resource "azurerm_search_service" "search" {
1313

1414
local_authentication_enabled = true
1515
authentication_failure_mode = "http403"
16-
semantic_search_sku = "free"
16+
semantic_search_sku = "free"
1717
}

0 commit comments

Comments
 (0)