Implementation:Apache Druid RuleEditor
| Knowledge Sources | |
|---|---|
| Domains | Web_Console, Data_Retention |
| Last Updated | 2026-02-10 10:00 GMT |
Overview
RuleEditor is a React component for editing a single Druid data retention rule, including its type, time period, interval, and tiered replication configuration.
Description
The component renders a collapsible card displaying the rule's human-readable description as a title, with controls for changing the rule type (load, drop, broadcast rules with period, interval, or forever variants), configuring the time period or interval, toggling the "include future" flag, and managing tiered replicant assignments. Each tier row allows selecting a tier name and replication count, with the ability to add or remove tiers. The component uses RuleUtil from the druid-models package for all rule transformations.
Usage
Used in the Druid web console's datasource retention rule configuration dialog to display and edit individual retention rules within an ordered rule list.
Code Reference
Source Location
- Repository: Apache Druid
- File: web-console/src/components/rule-editor/rule-editor.tsx
- Lines: 1-218
Signature
export interface RuleEditorProps {
rule: Rule;
tiers: string[];
onChange?: (newRule: Rule) => void;
onDelete?: () => void;
moveUp?: () => void;
moveDown?: () => void;
}
export const RuleEditor: React.NamedExoticComponent<RuleEditorProps>;
Import
import { RuleEditor } from './components/rule-editor/rule-editor';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| rule | Rule | Yes | The retention rule object to edit |
| tiers | string[] | Yes | List of available historical tier names for the tier selector |
| onChange | (newRule: Rule) => void | No | Callback fired with the updated rule; absence makes the editor read-only |
| onDelete | () => void | No | Callback to delete this rule; absence hides the delete button |
| moveUp | () => void | No | Callback to move this rule up in the list; absence hides the move-up button |
| moveDown | () => void | No | Callback to move this rule down in the list; absence hides the move-down button |
Outputs
| Name | Type | Description |
|---|---|---|
| JSX.Element | div | A collapsible rule editor card with type selector, period/interval inputs, and tier replicant controls |
Usage Examples
Rule editor in a retention configuration dialog
<RuleEditor
rule={rule}
tiers={['_default_tier', 'hot', 'cold']}
onChange={updatedRule => updateRuleAtIndex(index, updatedRule)}
onDelete={() => deleteRuleAtIndex(index)}
moveUp={index > 0 ? () => moveRule(index, -1) : undefined}
moveDown={index < rules.length - 1 ? () => moveRule(index, 1) : undefined}
/>