Skip to content

Commit f80a3db

Browse files
authored
Enable diagnostics for search service (Azure-Samples#1676)
* GPt4 version * Enable diagnostics for search service
1 parent 938c674 commit f80a3db

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
param searchServiceName string = ''
2+
3+
@description('Resource ID of log analytics workspace.')
4+
param workspaceId string
5+
6+
@description('Optional. The name of logs that will be streamed.')
7+
param logCategoriesToEnable array = ['OperationLogs']
8+
9+
@description('Optional. The name of metrics that will be streamed.')
10+
param metricsToEnable array = [
11+
'AllMetrics'
12+
]
13+
14+
var diagnosticsLogs = [
15+
for category in logCategoriesToEnable: {
16+
category: category
17+
enabled: true
18+
}
19+
]
20+
21+
var diagnosticsMetrics = [
22+
for metric in metricsToEnable: {
23+
category: metric
24+
timeGrain: null
25+
enabled: true
26+
}
27+
]
28+
29+
resource searchService 'Microsoft.Search/searchServices@2023-11-01' existing = {
30+
name: searchServiceName
31+
}
32+
33+
resource app_diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
34+
name: '${searchServiceName}-diagnostics'
35+
scope: searchService
36+
properties: {
37+
workspaceId: workspaceId
38+
metrics: diagnosticsMetrics
39+
logs: diagnosticsLogs
40+
}
41+
}

infra/main.bicep

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,15 @@ module searchService 'core/search/search-services.bicep' = {
466466
}
467467
}
468468

469+
module searchDiagnostics 'core/search/search-diagnostics.bicep' = if (useApplicationInsights) {
470+
name: 'search-diagnostics'
471+
scope: searchServiceResourceGroup
472+
params: {
473+
searchServiceName: searchService.outputs.name
474+
workspaceId: useApplicationInsights ? monitoring.outputs.logAnalyticsWorkspaceId : ''
475+
}
476+
}
477+
469478
module storage 'core/storage/storage-account.bicep' = {
470479
name: 'storage'
471480
scope: storageResourceGroup

0 commit comments

Comments
 (0)