Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(azure): enable query performance insights for postgres #1417

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .azure/infrastructure/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ import { Sku as SlackNotifierSku } from '../modules/functionApp/slackNotifier.bi
param slackNotifierSku SlackNotifierSku

import { Sku as PostgresSku } from '../modules/postgreSql/create.bicep'
param postgresSku PostgresSku

param postgresConfiguration {
sku: PostgresSku
enableQueryPerformanceInsight: bool
}

import { Sku as ServiceBusSku } from '../modules/serviceBus/main.bicep'
param serviceBusSku ServiceBusSku
Expand Down Expand Up @@ -199,7 +203,8 @@ module postgresql '../modules/postgreSql/create.bicep' = {
administratorLoginPassword: contains(keyVaultSourceKeys, 'dialogportenPgAdminPassword${environment}')
? srcKeyVaultResource.getSecret('dialogportenPgAdminPassword${environment}')
: secrets.dialogportenPgAdminPassword
sku: postgresSku
sku: postgresConfiguration.sku
enableQueryPerformanceInsight: postgresConfiguration.enableQueryPerformanceInsight
subnetId: vnet.outputs.postgresqlSubnetId
vnetId: vnet.outputs.virtualNetworkId
tags: tags
Expand Down
9 changes: 6 additions & 3 deletions .azure/infrastructure/prod.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ param slackNotifierSku = {
applicationServicePlanName: 'Y1'
applicationServicePlanTier: 'Dynamic'
}
param postgresSku = {
name: 'Standard_B1ms'
tier: 'Burstable'
param postgresConfiguration = {
sku: {
name: 'Standard_B1ms'
tier: 'Burstable'
}
enableQueryPerformanceInsight: false
}

param redisSku = {
Expand Down
9 changes: 6 additions & 3 deletions .azure/infrastructure/staging.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ param slackNotifierSku = {
applicationServicePlanName: 'Y1'
applicationServicePlanTier: 'Dynamic'
}
param postgresSku = {
name: 'Standard_B1ms'
tier: 'Burstable'
param postgresConfiguration = {
sku: {
name: 'Standard_B1ms'
tier: 'Burstable'
}
enableQueryPerformanceInsight: true
}

param redisSku = {
Expand Down
9 changes: 6 additions & 3 deletions .azure/infrastructure/test.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ param slackNotifierSku = {
applicationServicePlanName: 'Y1'
applicationServicePlanTier: 'Dynamic'
}
param postgresSku = {
name: 'Standard_B2s'
tier: 'Burstable'
param postgresConfiguration = {
sku: {
name: 'Standard_B2s'
tier: 'Burstable'
}
enableQueryPerformanceInsight: false
arealmaas marked this conversation as resolved.
Show resolved Hide resolved
}

param redisSku = {
Expand Down
9 changes: 6 additions & 3 deletions .azure/infrastructure/yt01.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ param slackNotifierSku = {
applicationServicePlanName: 'Y1'
applicationServicePlanTier: 'Dynamic'
}
param postgresSku = {
name: 'Standard_B1ms'
tier: 'Burstable'
param postgresConfiguration = {
sku: {
name: 'Standard_B1ms'
tier: 'Burstable'
}
enableQueryPerformanceInsight: true
}

param redisSku = {
Expand Down
30 changes: 30 additions & 0 deletions .azure/modules/postgreSql/create.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type Sku = {
@description('The SKU of the PostgreSQL server')
param sku Sku

@description('Enable query performance insight')
param enableQueryPerformanceInsight bool

@description('The Key Vault to store the PostgreSQL administrator login password')
@secure()
param srcKeyVault object
Expand Down Expand Up @@ -106,6 +109,33 @@ resource postgres 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' = {
tags: tags
}

resource track_io_timing 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2023-12-01-preview' = if (enableQueryPerformanceInsight) {
parent: postgres
name: 'track_io_timing'
properties: {
value: 'on'
source: 'user-override'
}
}

resource pg_qs_query_capture_mode 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2023-12-01-preview' = if (enableQueryPerformanceInsight) {
parent: postgres
name: 'pg_qs.query_capture_mode'
properties: {
value: 'all'
source: 'user-override'
}
}

resource pgms_wait_sampling_query_capture_mode 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2023-12-01-preview' = if (enableQueryPerformanceInsight) {
parent: postgres
name: 'pgms_wait_sampling.query_capture_mode'
properties: {
value: 'all'
source: 'user-override'
}
}

module adoConnectionString '../keyvault/upsertSecret.bicep' = {
name: 'adoConnectionString'
params: {
Expand Down
Loading