Skip to content

Commit

Permalink
Transition to Log Analytics style App Insights
Browse files Browse the repository at this point in the history
  • Loading branch information
joelverhagen committed Oct 1, 2023
1 parent 348ef6e commit dbf6bf5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
35 changes: 20 additions & 15 deletions deploy/bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ param leaseContainerName string
param userManagedIdentityName string
param location string

param logAnalyticsWorkspaceName string
param appInsightsName string
param appInsightsDailyCapGb int
param actionGroupName string
Expand Down Expand Up @@ -56,26 +57,30 @@ resource userManagedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2
location: location
}

resource appInsights 'Microsoft.Insights/components@2015-05-01' = {
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
name: logAnalyticsWorkspaceName
location: location
properties: {
features: {
immediatePurgeDataOn30Days: true
}
sku: {
name: 'PerGB2018'
}
retentionInDays: 30
workspaceCapping: {
dailyQuotaGb: appInsightsDailyCapGb
}
}
}

resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
name: appInsightsName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
}

// This produces a warning due to limited type definitions, but works.
// See: https://github.com/Azure/bicep/issues/784#issuecomment-830997209
#disable-next-line BCP081
resource billing 'CurrentBillingFeatures' = {
name: 'Basic'
properties: {
CurrentBillingFeatures: 'Basic'
DataVolumeCap: {
Cap: appInsightsDailyCapGb
WarningThreshold: 90
}
}
WorkspaceResourceId: logAnalyticsWorkspace.id
}
}

Expand Down
1 change: 1 addition & 0 deletions deploy/config/ev2-dev-usnc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"WorkerCountPerPlan": 1,
"WorkerPlanCount": 1,
"WorkerLogLevel": "Warning",
"LogAnalyticsWorkspaceName": "ev2-dev-usnc-insights-la",
"AppInsightsName": "ev2-dev-usnc-insights-ai",
"AppInsightsDailyCapGb": 1,
"ActionGroupName": "ev2-dev-usnc",
Expand Down
5 changes: 5 additions & 0 deletions deploy/scripts/NuGet.Insights.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class ResourceSettings {
[ValidateNotNullOrEmpty()]
[string]$Location

[ValidateNotNullOrEmpty()]
[string]$LogAnalyticsWorkspaceName

[ValidateNotNullOrEmpty()]
[string]$AppInsightsName

Expand Down Expand Up @@ -168,6 +171,7 @@ class ResourceSettings {
}

Set-OrDefault Location "West US 2"
Set-OrDefault LogAnalyticsWorkspaceName "NuGetInsights-$StampName"
Set-OrDefault AppInsightsName "NuGetInsights-$StampName"
Set-OrDefault AppInsightsDailyCapGb 1
Set-OrDefault ActionGroupName "NuGetInsights-$StampName"
Expand Down Expand Up @@ -534,6 +538,7 @@ function New-MainParameters(
actionGroupShortName = $ResourceSettings.ActionGroupShortName;
alertEmail = $ResourceSettings.AlertEmail;
alertPrefix = $ResourceSettings.AlertPrefix;
logAnalyticsWorkspaceName = $ResourceSettings.LogAnalyticsWorkspaceName;
appInsightsDailyCapGb = $ResourceSettings.AppInsightsDailyCapGb;
appInsightsName = $ResourceSettings.AppInsightsName;
deploymentLabel = $DeploymentLabel;
Expand Down

0 comments on commit dbf6bf5

Please sign in to comment.