Skip to content

Commit

Permalink
Merge pull request #25 from Azure-Samples/app-insights
Browse files Browse the repository at this point in the history
chore: Add Azure Application Insights for observability
  • Loading branch information
codebytes authored May 15, 2024
2 parents cf6f011 + ebb3f29 commit ef1080a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions infra/manifests/api/config.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ data:
AZURE_SEARCH_ENDPOINT: {{.Env.AZURE_SEARCH_ENDPOINT}}
AZURE_SEARCH_API_KEY: {{.Env.AZURE_SEARCH_API_KEY}}
AZURE_SEARCH_INDEX_NAME: {{.Env.AZURE_SEARCH_INDEX_NAME}}
APPLICATIONINSIGHTS_CONNECTION_STRING: {{.Env.APPLICATIONINSIGHTS_CONNECTION_STRING}}
VECTORDB_TYPE: {{.Env.VECTORDB_TYPE}}

2 changes: 2 additions & 0 deletions infra/manifests/api/deployment.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ spec:
value: {{.Env.AZURE_SEARCH_INDEX_NAME}}
- name: VECTORDB_TYPE
value: {{.Env.VECTORDB_TYPE}}
- name: APPLICATIONINSIGHTS_CONNECTION_STRING
value: {{.Env.APPLICATIONINSIGHTS_CONNECTION_STRING}}
resources:
requests:
memory: "256Mi"
Expand Down
11 changes: 11 additions & 0 deletions infra/observability.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ resource "azurerm_monitor_data_collection_rule_association" "example_msci_to_aks
target_resource_id = azurerm_kubernetes_cluster.aks[0].id
data_collection_rule_id = azurerm_monitor_data_collection_rule.example_msci[0].id
}


resource "azurerm_application_insights" "applicationinsights" {
count = local.deploy_observability_tools ? 1 : 0
name = "ai-${local.resource_token}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
application_type = "web"
workspace_id = azurerm_log_analytics_workspace.example[0].id
tags = local.tags
}
6 changes: 6 additions & 0 deletions infra/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ output "AZURE_RESOURCE_GROUP" {
output "AZURE_TENANT_ID" {
value = data.azurerm_client_config.current.tenant_id
}

output "AZURE_SEARCH_ENDPOINT" {
value = "https://${azurerm_search_service.search.name}.search.windows.net"
}
Expand All @@ -95,3 +96,8 @@ output "BING_SEARCH_KEY" {
value = jsondecode(data.azapi_resource_action.bing.output).key1
sensitive = true
}

output "APPLICATIONINSIGHTS_CONNECTION_STRING" {
value = local.deploy_observability_tools ? "" : azurerm_application_insights.applicationinsights[0].connection_string
sensitive = true
}
2 changes: 1 addition & 1 deletion infra/search.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ resource "azurerm_search_service" "search" {

local_authentication_enabled = true
authentication_failure_mode = "http403"
semantic_search_sku = "free"
semantic_search_sku = "free"
}

0 comments on commit ef1080a

Please sign in to comment.