Skip to main content
The Automatic Compaction API allows you to configure and monitor automatic compaction using Coordinator duties in Apache Druid.
You can also use compaction supervisors (experimental) instead of Coordinator-based compaction.

Manage automatic compaction

Create or update compaction configuration

Creates or updates automatic compaction configuration for a datasource. Only the dataSource property is required; Druid fills other properties with default values.
curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction" \
--header 'Content-Type: application/json' \
--data '{
    "dataSource": "wikipedia_hour",
    "skipOffsetFromLatest": "PT0S",
    "tuningConfig": {
        "partitionsSpec": {
            "type": "dynamic"
        },
        "type": "index_parallel"
    },
    "granularitySpec": {
        "segmentGranularity": "DAY"
    }
}'
dataSource
string
required
Name of the datasource to configure compaction for.
skipOffsetFromLatest
string
ISO-8601 duration. Skip segments within this time from the latest segment.
tuningConfig
object
Tuning configuration for compaction tasks including partitioning strategy.
granularitySpec
object
Granularity specification including segmentGranularity for compacted segments.
{}

Remove compaction configuration

Removes automatic compaction configuration for a datasource.
curl --request DELETE \
  "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction/wikipedia_hour"
dataSource
string
required
Name of the datasource.
{}

View compaction configuration

Get all compaction configurations

Retrieves all automatic compaction configurations and cluster-level settings.
curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction"
compactionConfigs
array
Array of compaction configurations for all datasources.
compactionTaskSlotRatio
number
Ratio of task slots allocated to compaction tasks (default: 0.1).
maxCompactionTaskSlots
integer
Maximum number of task slots for compaction (default: 2147483647).

Get compaction configuration for a datasource

Retrieves the automatic compaction configuration for a specific datasource.
curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction/wikipedia_hour"
dataSource
string
required
Name of the datasource.
{
    "dataSource": "wikipedia_hour",
    "taskPriority": 25,
    "inputSegmentSizeBytes": 100000000000000,
    "skipOffsetFromLatest": "PT0S",
    "tuningConfig": {
        "partitionsSpec": {
            "type": "dynamic",
            "maxRowsPerSegment": 5000000
        },
        "type": "index_parallel"
    },
    "granularitySpec": {
        "segmentGranularity": "DAY"
    }
}

Get compaction configuration history

Retrieves the history of compaction configuration changes for a datasource.
curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction/wikipedia_hour/history"
dataSource
string
required
Name of the datasource.
interval
string
ISO-8601 interval to filter results (e.g., 2023-01-01/2023-12-31).
count
integer
Limit the number of history entries returned.
globalConfig
object
Cluster-level compaction configuration at the time of change.
compactionConfig
object
Datasource compaction configuration.
auditInfo
object
Information about who made the change.
auditTime
string
ISO-8601 timestamp of the change.

View compaction status

Get segments awaiting compaction

Returns the total size of segments awaiting compaction for a datasource.
curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/compaction/progress?dataSource=wikipedia_hour"
dataSource
string
required
Name of the datasource.
{
    "remainingSegmentSize": 7615837
}

Get compaction status and statistics

Retrieves status and statistics from the latest automatic compaction run for all datasources.
curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/compaction/status"
dataSource
string
Filter results by datasource name.
latestStatus
array
Array of status objects for each datasource.
dataSource
string
Name of the datasource.
scheduleStatus
string
Compaction scheduling status: NOT_ENABLED or RUNNING.
bytesAwaitingCompaction
integer
Total bytes waiting to be compacted.
bytesCompacted
integer
Total bytes already compacted.
bytesSkipped
integer
Total bytes skipped (not eligible for compaction).
segmentCountAwaitingCompaction
integer
Number of segments waiting to be compacted.
{
    "latestStatus": [
        {
            "dataSource": "wikipedia_api",
            "scheduleStatus": "RUNNING",
            "bytesAwaitingCompaction": 0,
            "bytesCompacted": 0,
            "bytesSkipped": 64133616,
            "segmentCountAwaitingCompaction": 0,
            "segmentCountCompacted": 0,
            "segmentCountSkipped": 8
        },
        {
            "dataSource": "wikipedia_hour",
            "scheduleStatus": "RUNNING",
            "bytesAwaitingCompaction": 0,
            "bytesCompacted": 5998634,
            "bytesSkipped": 0,
            "segmentCountAwaitingCompaction": 0,
            "segmentCountCompacted": 1,
            "segmentCountSkipped": 0
        }
    ]
}

Build docs developers (and LLMs) love