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

fix(slack-notifier): exclude health checks from alerts #1335

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

arealmaas
Copy link
Collaborator

@arealmaas arealmaas commented Oct 23, 2024

Description

Logging has changed a bit so need to change the endpoint to exclude from alerts. We don't want to log the health-check endpoint traces, but that has to be tweaked in another PR

Related Issue(s)

  • N/A

Slack discussion: https://digdir.slack.com/archives/C079XRW5G5A/p1729643530959569

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • Documentation is updated (either in docs-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)

Summary by CodeRabbit

  • New Features

    • Enhanced alerting logic for the Slack Notifier function app to broaden the scope of monitored requests.
    • Defined SKU parameters to ensure valid options for resource deployment.
  • Bug Fixes

    • Adjusted criteria for exception alerting to improve monitoring accuracy.

@arealmaas arealmaas requested review from a team as code owners October 23, 2024 07:50
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

📝 Walkthrough

Walkthrough

The pull request modifies the Bicep template for deploying a Slack Notifier function app. Key changes include adjustments to the alerting criteria for the exceptionOccuredAlertRule resource, focusing on requests that do not start with "/health". Additionally, a new sku parameter is introduced with defined allowed values for various resources, enhancing the deployment's validity. The overall structure of the deployment parameters and resources remains consistent, while the output declaration for functionAppPrincipalId is unchanged.

Changes

File Change Summary
.azure/modules/functionApp/slackNotifier.bicep - Added parameter: param sku Sku
- Added type definition: type Sku
- Modified resource: exceptionOccuredAlertRule to change alerting criteria.

Possibly related PRs

Suggested reviewers

  • oskogstad
  • MagnusSandgren

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6b926f4 and 42be333.

📒 Files selected for processing (1)
  • .azure/modules/functionApp/slackNotifier.bicep (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
.azure/modules/functionApp/slackNotifier.bicep (3)

Line range hint 20-54: Well-structured SKU type definition!

The exported Sku type definition is comprehensive and follows best practices:

  • Properly constrains allowed values for storage and app service plan configurations
  • Enables type safety and prevents deployment errors
  • Facilitates reuse through the @export() decorator

164-166: Clean implementation of health check exclusion.

The query modification effectively implements the requirement to exclude health checks from Slack alerts while maintaining:

  • Clear and readable KQL syntax
  • Proper integration with existing alert criteria
  • Consistent filtering approach

165-165: Verify health check path patterns.

The change correctly implements the PR objective to exclude health checks from alerts. However, please verify:

  1. Are there any variations of health check paths that should also be excluded? (e.g., /healthz, /health-check)
  2. Is /health the standardized prefix across all services?

Let's check for other health check patterns in the codebase:

✅ Verification successful

Let me try a different search strategy to find health check endpoint patterns.

The previous command failed because of incorrect glob pattern syntax. The new commands will:

  1. Search across all files for any health check related patterns
  2. Specifically look in configuration files where endpoint paths are commonly defined

This will help us verify if there are other health check path patterns that need to be excluded in the alert rule.


Based on the search results, I can now provide a final response:

Health check path pattern is correctly implemented

The exclusion pattern !startswith "/health" in the alert rule is correct and comprehensive because:

  1. The codebase consistently uses /health as the base path for all health-related endpoints, as seen in AspNetUtilitiesExtensions.cs:
    • /health (main health endpoint)
    • /health/startup
    • /health/liveness
    • /health/readiness
    • /health/deep
  2. The only other health endpoint pattern found is /healthz which is used only in the ChangeDataCapture service, which is a separate component not related to this alert rule.

The current filter will properly exclude all health check endpoints from the alerts while maintaining monitoring for actual application exceptions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for health check endpoint definitions
rg -i "health|healthz|health-check" -g "*.cs|*.fs|*.ts|*.js"

Length of output: 211


Script:

#!/bin/bash
# Search for health check patterns in all files
rg -i "health|healthz|health-check"

# Also search specifically in configuration files
rg -i "health|healthz|health-check" -g "*.json" -g "*.yaml" -g "*.yml" -g "*.bicep"

Length of output: 11230


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@arealmaas arealmaas merged commit 0a4331a into main Oct 23, 2024
21 checks passed
@arealmaas arealmaas deleted the fix/slack-notifier branch October 23, 2024 11:31
arealmaas pushed a commit that referenced this pull request Oct 23, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.26.2](v1.26.1...v1.26.2)
(2024-10-23)


### Bug Fixes

* **slack-notifier:** exclude health checks from alerts
([#1335](#1335))
([0a4331a](0a4331a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants