robusta icon indicating copy to clipboard operation
robusta copied to clipboard

feat: Enable per-alert Incident Severity, metadata improvements

Open igorhrcek opened this issue 1 month ago • 1 comments

Changes

This PR improves on existing Incident.io implementation and allows to define per-alert incident severity in Incident.io (until now severity was determined by the alert severity, however not all alerts with the critical severity should have the same Incident.io severity).

The following configurational changes were made:

  1. severity_alert_label_name - label on the alert that will contain information about Incident.io severity. Default set to robusta_incidentio_severity.
  2. severity_default - sane default in case when label is not defined
  3. dashboard_url_annotation_name - Incident.io has something called the source_url. Usually, that can be a link toward Grafana dashboard or anything else. In this case, it is a name of the alert annotation. Default set to dashboard_url.
  4. runbook_url_annotation_name - same as with the Dashboard URL, stored as metadata information that can be extracted and parsed in Incident.io interface.
  5. Added metadata["additional_info"] for passing additional metadata information to Incident.io

Please note that severity names must be mapped in the Incident.io interface (whatever you pass - minor, major, critical) to the actual severity ID.

These changes are running on our production for months without any issues.

Risks

None

Performance impact

None

Security impact

None

How to QA

  1. Configure Incident.io Sink
  2. Send a few simulated requests
./robusta playbooks trigger prometheus_alert --namespace=monitoring alert_name="IncidentIoSeverityTesting" severity=critical labels="robusta_incidentio_severity:major"
./robusta playbooks trigger prometheus_alert --namespace=monitoring alert_name="IncidentIoSeverityTesting" severity=critical labels="robusta_incidentio_severity:major" annotations="dashboard_url=https://grafana.com,runbook_url=https://google.com"
  1. Go to Incident.io UI, find alerts and inspect payload

igorhrcek avatar Dec 06 '25 19:12 igorhrcek

Walkthrough

The Incident.io sink is refactored to restructure metadata handling into a list of dictionaries, extends block type support via dynamic handling, introduces a private helper method for normalized block type naming, and conditionally includes source_url in payloads based on platform enablement.

Changes

Cohort / File(s) Summary
Incident.io Sink Refactoring
src/robusta/core/sinks/incidentio/incidentio_sink.py
Added docstring for sink class; removed LinksBlock/Link/LinkType imports; reworked metadata handling to build additional_info as structured list of dictionaries instead of plain text; introduced private helper __get_block_type_name() for normalized block type naming; extended __to_unformatted_text() with dynamic support for additional block types (FileBlock, EmptyFileBlock, PrometheusBlock, ScanReportBlock, CallbackBlock, DividerBlock) and fallback to common attributes; added conditional source_url inclusion based on platform_enabled flag; adjusted error logging format

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Metadata restructuring: Verify that the shift from plain text to structured dictionaries (type/content pairs) doesn't break downstream consumers of additional_info
  • Block type dynamic handling: Ensure __get_block_type_name() correctly normalizes all supported block types and the fallback logic handles edge cases appropriately
  • Extended block support in __to_unformatted_text(): Review the new block type handlers to confirm they extract the correct attributes and don't introduce unexpected text formatting
  • Conditional source_url logic: Confirm that platform_enabled gating works correctly and doesn't inadvertently filter payloads in production scenarios

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: enabling per-alert Incident.io severity and improving metadata handling.
Description check ✅ Passed The description clearly explains the changes, configurations, risks, and QA instructions, directly related to the changeset.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Dec 06 '25 20:12 coderabbitai[bot]