-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix(azure): set diagnostic setting to allow query perf insights #1422
Conversation
📝 WalkthroughWalkthroughThe changes in this pull request introduce a new parameter Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
'PostgreSQLFlexQueryStoreRuntime' | ||
'PostgreSQLFlexQueryStoreWaitStats' | ||
'PostgreSQLFlexTableStats' | ||
'PostgreSQLFlexDatabaseXacts' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI:
Diagnostic Log Categories for Azure PostgreSQL Flexible Server
PostgreSQLLogs
- Contains general PostgreSQL server logs.
- Includes error messages, authentication attempts, and general server events.
- Essential for troubleshooting server-level issues and security monitoring.
PostgreSQLFlexSessions
- Tracks active database sessions and connections.
- Helps monitor concurrent users and connection patterns.
- Useful for identifying connection leaks or excessive concurrent connections.
PostgreSQLFlexQueryStoreRuntime
- Captures query execution statistics and runtime metrics.
- Shows query execution times, CPU usage, and I/O statistics.
- Critical for performance tuning and identifying slow queries.
PostgreSQLFlexQueryStoreWaitStats
- Records what queries are waiting for and why.
- Helps identify bottlenecks like I/O, locks, or resource contention.
- Essential for diagnosing performance issues and resource conflicts.
PostgreSQLFlexTableStats
- Provides statistics about table usage and operations.
- Includes information about table scans, row counts, and index usage.
- Useful for capacity planning and database optimization.
PostgreSQLFlexDatabaseXacts
- Monitors database transactions.
- Tracks transaction rates, durations, and commit/rollback patterns.
- Important for understanding database workload and transaction health.
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
.azure/modules/postgreSql/create.bicep (1)
161-180
: Consider the following improvements for diagnostic settings.
- The diagnostic setting name 'PostgreSQLDiagnosticSetting' could be more specific to avoid conflicts in larger deployments.
- The
timeGrain
parameter is set to null, which uses the default. Consider explicitly setting this based on your monitoring requirements.Consider using this more specific naming pattern:
- name: 'PostgreSQLDiagnosticSetting' + name: '${postgresServerName}-diagnostic-settings'.azure/infrastructure/main.bicep (1)
Line range hint
319-326
: Security enhancement: Connection strings properly configured as Key Vault references.Good security practice to explicitly set
keyValueType: 'keyVaultReference'
for both PostgreSQL and Redis connection strings, ensuring they are stored securely in Key Vault.This approach:
- Enhances security by storing sensitive connection strings in Key Vault
- Provides centralized secret management
- Enables automated secret rotation
Also applies to: 336-343
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
.azure/infrastructure/main.bicep
(1 hunks).azure/modules/postgreSql/create.bicep
(2 hunks)
🔇 Additional comments (5)
.azure/modules/postgreSql/create.bicep (4)
37-39
: LGTM: Parameter declaration follows best practices.
The new parameter appInsightWorkspaceName
is well-documented and properly typed.
152-160
: LGTM: Comprehensive diagnostic logging configuration.
The diagnostic categories include all essential logs for PostgreSQL monitoring, particularly those needed for query performance insights:
- Query store runtime statistics
- Wait statistics
- Table statistics
- Database transactions
142-144
: Verify App Insights workspace existence.
The diagnostic setting depends on an existing App Insights workspace. Deployment could fail if the workspace doesn't exist.
#!/bin/bash
# Description: Check if App Insights workspace creation is defined elsewhere in the codebase
# Look for App Insights workspace resource creation
ast-grep --pattern 'resource $_ \'Microsoft.OperationalInsights/workspaces@$_\' = {
name: $_
$$$
}'
Also applies to: 161-180
146-150
: Verify Log Analytics workspace retention policy.
Setting diagnostic retention to 0 days could lead to data loss if the Log Analytics workspace policy isn't properly configured. Please ensure that:
- The workspace has appropriate retention policies configured
- The retention period meets your compliance and monitoring requirements
.azure/infrastructure/main.bicep (1)
207-208
: LGTM: Query Performance Insights configuration added correctly.
The changes properly integrate Application Insights workspace with PostgreSQL for enabling query performance insights, which aligns with the PR objectives.
Let's verify the Application Insights workspace configuration:
✅ Verification successful
The previous ast-grep command didn't work as expected for Bicep files. Let's try to verify the configuration through these alternative approaches to understand the module structure and parameter usage.
Let's try these alternative approaches since the previous commands had issues with the bicep file type recognition.
After analyzing the bicep files, I can now generate the final response since I have enough context to verify the Application Insights workspace configuration for PostgreSQL query performance insights.
Application Insights workspace integration is properly configured
The changes correctly integrate Application Insights workspace with PostgreSQL for query performance insights:
- The
appInsightWorkspaceName
parameter is properly passed from the Application Insights module outputs - The PostgreSQL module correctly configures diagnostic settings with the Application Insights workspace
- Required PostgreSQL configurations for query performance insights are enabled:
track_io_timing
pg_qs.query_capture_mode
pgms_wait_sampling.query_capture_mode
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify Application Insights workspace configuration in PostgreSQL module
# Test: Search for the Application Insights workspace parameter in the PostgreSQL module
ast-grep --pattern 'param appInsightWorkspaceName string'
Length of output: 59
Script:
#!/bin/bash
# Let's check the PostgreSQL module file content first
fd -e bicep postgres
Length of output: 22
Script:
#!/bin/bash
# Search for any Application Insights related parameters in bicep files
rg -l "appInsight" --type bicep
Length of output: 61
Script:
#!/bin/bash
# Look for the actual parameter usage in main.bicep
rg "appInsightWorkspaceName:" --type bicep -A 2 -B 2
Length of output: 82
Script:
#!/bin/bash
# Let's try searching without file type specification
rg "appInsightWorkspaceName:" -A 2 -B 2
Length of output: 39
Script:
#!/bin/bash
# Find all bicep files in the repository
find . -name "*.bicep"
Length of output: 1487
Script:
#!/bin/bash
# If we find any bicep files, let's look at their content
find . -name "*.bicep" -exec cat {} \;
Length of output: 91588
🤖 I have created a release *beep* *boop* --- ## [1.31.0](v1.30.0...v1.31.0) (2024-11-08) ### Features * **azure:** enable query performance insights for postgres ([#1417](#1417)) ([bb832d8](bb832d8)) ### Bug Fixes * add timeout for health checks ([#1388](#1388)) ([d68cc65](d68cc65)) * **azure:** set diagnostic setting to allow query perf insights ([#1422](#1422)) ([5919258](5919258)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Description
We need to enable diagnostic setting in order to enable query performance insight. Added manually in portal, but finally found out how to do it in Bicep:):)
Related Issue(s)
Verification
Documentation
docs
-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)Summary by CodeRabbit
New Features
Updates