Implementation:Apache Druid RetentionDialog
| Knowledge Sources | |
|---|---|
| Domains | Web_Console, Retention_Rules |
| Last Updated | 2026-02-10 10:00 GMT |
Overview
RetentionDialog is a React dialog component that provides a comprehensive editor for Druid data retention rules with form-based and JSON editing modes.
Description
The RetentionDialog component wraps a SnitchDialog to manage retention rules for a specific datasource or cluster defaults. It loads available historical tiers via SQL or Coordinator API and displays rule history for audit review. Users can add, delete, reorder, and edit rules using either RuleEditor components in form mode or a JsonInput with RETENTION_RULE_COMPLETIONS in JSON mode. The dialog shows cluster default rules (with an edit link) as fallback rules when editing datasource-specific rules. Rules are saved through the onSave callback with an audit comment.
Usage
Used from the datasources view when an administrator wants to configure or modify retention rules that control how long data segments are kept, replicated, and distributed across tiers.
Code Reference
Source Location
- Repository: Apache Druid
- File: web-console/src/dialogs/retention-dialog/retention-dialog.tsx
- Lines: 1-219
Signature
export interface RetentionDialogProps {
datasource: string;
rules: Rule[];
defaultRules: Rule[];
capabilities: Capabilities;
onEditDefaults(): void;
onCancel(): void;
onSave(datasource: string, newRules: Rule[], comment: string): void | Promise<void>;
}
export const RetentionDialog = React.memo(function RetentionDialog(
props: RetentionDialogProps,
): JSX.Element;
Import
import { RetentionDialog } from 'web-console/src/dialogs/retention-dialog/retention-dialog';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| datasource | string | Yes | Name of the datasource whose retention rules are being edited |
| rules | Rule[] | Yes | Current retention rules for the datasource |
| defaultRules | Rule[] | Yes | Cluster default retention rules shown as fallback |
| capabilities | Capabilities | Yes | Cluster capabilities object used to determine API access methods |
| onEditDefaults | () => void | Yes | Callback to navigate to editing cluster default rules |
| onCancel | () => void | Yes | Callback invoked when the dialog is cancelled |
| onSave | (datasource, newRules, comment) => void or Promise<void> | Yes | Callback invoked to save the updated rules with an audit comment |
Outputs
| Name | Type | Description |
|---|---|---|
| rendered dialog | JSX.Element | A SnitchDialog wrapping a rule editor with add/delete/reorder controls, form/JSON toggle, tier loading, and history review |
Usage Examples
Editing Datasource Retention Rules
<RetentionDialog
datasource="wikipedia"
rules={currentRules}
defaultRules={clusterDefaults}
capabilities={capabilities}
onEditDefaults={() => editClusterDefaults()}
onCancel={() => setShowRetention(false)}
onSave={(ds, rules, comment) => saveRules(ds, rules, comment)}
/>