Skip to content

Commit

Permalink
eventgrid: add support for shipping audit logs to log analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
jfchevrette committed Feb 24, 2025
1 parent 94b89d9 commit d8729c3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dev-infrastructure/configurations/region.tmpl.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ param maestroCertificateIssuer = '{{ .maestro.certIssuer }}'

// MI for resource access during pipeline runs
param aroDevopsMsiId = '{{ .aroDevopsMsiId }}'

// Log Analytics Workspace ID will be passed from region pipeline if enabled in config
param logAnalyticsWorkspaceId = '__logAnalyticsWorkspaceId__'
41 changes: 41 additions & 0 deletions dev-infrastructure/modules/maestro/maestro-infra.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ param maxClientSessionsPerAuthName int
])
param publicNetworkAccess string

@description('Log Analytics Workspace ID if logging to Log Analytics')
param logAnalyticsWorkspaceId string = ''

param certificateIssuer string

//
Expand Down Expand Up @@ -54,6 +57,44 @@ resource eventGridNamespace 'Microsoft.EventGrid/namespaces@2024-12-15-preview'
}
}

resource eventGridNamespaceDiagnostics 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (logAnalyticsWorkspaceId != '') {
scope: eventGridNamespace
name: eventGridNamespaceName
properties: {
logs: [
{
category: 'SuccessfulMqttConnections'
enabled: true
}
{
category: 'FailedMqttConnections'
enabled: true
}
{
category: 'MqttDisconnections'
enabled: true
}
{
category: 'FailedMqttPublishedMessages'
enabled: true
}
{
category: 'FailedMqttSubscriptionOperations'
enabled: true
}
{
category: 'SuccessfulHttpDataPlaneOperations'
enabled: true
}
{
category: 'FailedHttpDataPlaneOperations'
enabled: true
}
]
workspaceId: logAnalyticsWorkspaceId
}
}

// find a better way to register the OneCert
resource certificateSignerCA 'Microsoft.EventGrid/namespaces/caCertificates@2024-12-15-preview' = if (startsWith(certificateIssuer, 'OneCert')) {
parent: eventGridNamespace
Expand Down
4 changes: 4 additions & 0 deletions dev-infrastructure/region-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ resourceGroups:
input:
step: global-output
name: svcParentZoneResourceId
- name: logAnalyticsWorkspaceId
input:
step: global-output
name: logAnalyticsWorkspaceId
dependsOn:
- global-output
- name: metrics-infra
Expand Down
4 changes: 4 additions & 0 deletions dev-infrastructure/templates/region.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ param svcAcrResourceId string
@description('MSI that will be used during pipeline runs')
param aroDevopsMsiId string

// Log Analytics Workspace ID will be passed from global pipeline if enabled in config
param logAnalyticsWorkspaceId string = ''

import * as res from '../modules/resource.bicep'

// Tags the resource group
Expand Down Expand Up @@ -155,5 +158,6 @@ module maestroInfra '../modules/maestro/maestro-infra.bicep' = {
maxClientSessionsPerAuthName: maestroEventGridMaxClientSessionsPerAuthName
publicNetworkAccess: maestroEventGridPrivate ? 'Disabled' : 'Enabled'
certificateIssuer: maestroCertificateIssuer
logAnalyticsWorkspaceId: logAnalyticsWorkspaceId
}
}

0 comments on commit d8729c3

Please sign in to comment.