Druid enables compaction without using user interface


I’m wondering if it’s possible to enable segment compression for a specific data source without using the Druid web interface. Could the compaction be activated via the API or a command?


Hi Fernando!

The short answer is yes. I pulled this example of a manual compaction task out of a great compaction discussion in Slack:

    "type": "compact",
    "dataSource": <task_datasource>,
    "ioConfig" : {
      "type" : "compact",
      "inputSpec" : {
        "type" : "interval",
        "interval" : "2022-01-11T00:00:00.000Z/2022-01-12T00:00:00.000Z"
    "tuningConfig" : {
      "type" : "index_parallel",
      "maxNumConcurrentSubTasks": 100

Does that look like it could work for your use case?



Dear Mark:

I appreciate your quick response and believe the advice you gave us may be helpful. In addition, I want to know if there is a way to turn on “automated compaction” without using the interface and instead using the API.

I’m going to test your solution, and as soon as I have results, I’ll comment.

Thanks a lot,

Hi @FDORADO - Everything you see in the Druid Console is an API :slight_smile:

The API for autocompaction can be found here: API reference · Apache Druid - specifically /druid/coordinator/v1/config/compaction


Thanks so much. Kyle, I had my suspicions, but I did not confirm this assertion. In this situation, I believe our problems could be resolved.

Regards and thanks again for your assistance.