blob: f9338073ef29d2c49ddac7f796f32e1c36394fb5 [file] [log] [blame]
<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-development/extensions-core/kafka-supervisor-operations">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v2.4.1">
<title data-rh="true">Apache Kafka supervisor operations reference | Apache® Druid</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" name="twitter:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" property="og:url" content="https://druid.apache.org/docs/latest/development/extensions-core/kafka-supervisor-operations"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Apache Kafka supervisor operations reference | Apache® Druid"><meta data-rh="true" name="description" content="Reference topic for running and maintaining Apache Kafka supervisors"><meta data-rh="true" property="og:description" content="Reference topic for running and maintaining Apache Kafka supervisors"><link data-rh="true" rel="icon" href="/img/favicon.png"><link data-rh="true" rel="canonical" href="https://druid.apache.org/docs/latest/development/extensions-core/kafka-supervisor-operations"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/latest/development/extensions-core/kafka-supervisor-operations" hreflang="en"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/latest/development/extensions-core/kafka-supervisor-operations" hreflang="x-default"><link rel="preconnect" href="https://www.google-analytics.com">
<link rel="preconnect" href="https://www.googletagmanager.com">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-131010415-1"></script>
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-131010415-1",{})</script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js"></script><link rel="stylesheet" href="/assets/css/styles.f80751b3.css">
<link rel="preload" href="/assets/js/runtime~main.dc5f839a.js" as="script">
<link rel="preload" href="/assets/js/main.a03dfc13.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedImage_ToTc themedImage--dark_i4oU"></div></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/technology">Technology</a><a class="navbar__item navbar__link" href="/use-cases">Use Cases</a><a class="navbar__item navbar__link" href="/druid-powered">Powered By</a><a class="navbar__item navbar__link" href="/docs/latest/design/">Docs</a><a class="navbar__item navbar__link" href="/community/">Community</a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Apache®</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Foundation<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://apachecon.com/?ref=druid.apache.org" target="_blank" rel="noopener noreferrer" class="dropdown__link">Events<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">License<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Thanks<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Security<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Sponsorship<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><a class="navbar__item navbar__link" href="/downloads/">Download</a><div class="searchBox_ZlJk"><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input type="search" id="search_input_react" placeholder="Loading..." aria-label="Search" class="navbar__search-input search-bar" disabled=""></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebarViewport_Xe31"><div class="sidebar_njMd"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/design/">Getting started</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/tutorials/tutorial-msq-extern">Tutorials</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/design/architecture">Design</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="/docs/latest/ingestion/">Ingestion</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/latest/ingestion/">Overview</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/latest/ingestion/data-formats">Ingestion concepts</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/latest/multi-stage-query/">SQL-based batch</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" tabindex="0" href="/docs/latest/development/extensions-core/kafka-ingestion">Streaming</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/latest/development/extensions-core/kafka-ingestion">Apache Kafka ingestion</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/latest/development/extensions-core/kafka-supervisor-reference">Apache Kafka supervisor</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/docs/latest/development/extensions-core/kafka-supervisor-operations">Apache Kafka operations</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/latest/development/extensions-core/kinesis-ingestion">Amazon Kinesis</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/docs/latest/ingestion/native-batch">Classic batch</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/latest/ingestion/ingestion-spec">Ingestion spec reference</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/latest/ingestion/schema-design">Schema design tips</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/latest/ingestion/faq">Troubleshooting FAQ</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/data-management/">Data management</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/querying/sql">Querying</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/api-reference/">API reference</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/configuration/">Configuration</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/operations/web-console">Operations</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/development/overview">Development</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/latest/misc/papers-and-talks">Misc</a></div></li></ul></nav></div></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Ingestion</span><meta itemprop="position" content="1"></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Streaming</span><meta itemprop="position" content="2"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Apache Kafka operations</span><meta itemprop="position" content="3"></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Apache Kafka supervisor operations reference</h1></header><p>This topic contains operations reference information to run and maintain Apache Kafka supervisors for Apache Druid. It includes descriptions of how some supervisor APIs work within Kafka Indexing Service.</p><p>For all supervisor APIs, see <a href="/docs/latest/api-reference/supervisor-api">Supervisor API reference</a>.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="getting-supervisor-status-report">Getting Supervisor Status Report<a href="#getting-supervisor-status-report" class="hash-link" aria-label="Direct link to Getting Supervisor Status Report" title="Direct link to Getting Supervisor Status Report"></a></h2><p><code>GET /druid/indexer/v1/supervisor/&lt;supervisorId&gt;/status</code> returns a snapshot report of the current state of the tasks managed by the given supervisor. This includes the latest
offsets as reported by Kafka, the consumer lag per partition, as well as the aggregate lag of all partitions. The
consumer lag per partition may be reported as negative values if the supervisor has not received a recent latest offset
response from Kafka. The aggregate lag value will always be &gt;= 0.</p><p>The status report also contains the supervisor&#x27;s state and a list of recently thrown exceptions (reported as
<code>recentErrors</code>, whose max size can be controlled using the <code>druid.supervisor.maxStoredExceptionEvents</code> configuration).
There are two fields related to the supervisor&#x27;s state - <code>state</code> and <code>detailedState</code>. The <code>state</code> field will always be
one of a small number of generic states that are applicable to any type of supervisor, while the <code>detailedState</code> field
will contain a more descriptive, implementation-specific state that may provide more insight into the supervisor&#x27;s
activities than the generic <code>state</code> field.</p><p>The list of possible <code>state</code> values are: <!-- -->[<code>PENDING</code>, <code>RUNNING</code>, <code>SUSPENDED</code>, <code>STOPPING</code>, <code>UNHEALTHY_SUPERVISOR</code>, <code>UNHEALTHY_TASKS</code>]</p><p>The list of <code>detailedState</code> values and their corresponding <code>state</code> mapping is as follows:</p><table><thead><tr><th>Detailed State</th><th>Corresponding State</th><th>Description</th></tr></thead><tbody><tr><td>UNHEALTHY_SUPERVISOR</td><td>UNHEALTHY_SUPERVISOR</td><td>The supervisor has encountered errors on the past <code>druid.supervisor.unhealthinessThreshold</code> iterations</td></tr><tr><td>UNHEALTHY_TASKS</td><td>UNHEALTHY_TASKS</td><td>The last <code>druid.supervisor.taskUnhealthinessThreshold</code> tasks have all failed</td></tr><tr><td>UNABLE_TO_CONNECT_TO_STREAM</td><td>UNHEALTHY_SUPERVISOR</td><td>The supervisor is encountering connectivity issues with Kafka and has not successfully connected in the past</td></tr><tr><td>LOST_CONTACT_WITH_STREAM</td><td>UNHEALTHY_SUPERVISOR</td><td>The supervisor is encountering connectivity issues with Kafka but has successfully connected in the past</td></tr><tr><td>PENDING (first iteration only)</td><td>PENDING</td><td>The supervisor has been initialized and hasn&#x27;t started connecting to the stream</td></tr><tr><td>CONNECTING_TO_STREAM (first iteration only)</td><td>RUNNING</td><td>The supervisor is trying to connect to the stream and update partition data</td></tr><tr><td>DISCOVERING_INITIAL_TASKS (first iteration only)</td><td>RUNNING</td><td>The supervisor is discovering already-running tasks</td></tr><tr><td>CREATING_TASKS (first iteration only)</td><td>RUNNING</td><td>The supervisor is creating tasks and discovering state</td></tr><tr><td>RUNNING</td><td>RUNNING</td><td>The supervisor has started tasks and is waiting for taskDuration to elapse</td></tr><tr><td>IDLE</td><td>IDLE</td><td>The supervisor is not creating tasks since the input stream has not received any new data and all the existing data is read.</td></tr><tr><td>SUSPENDED</td><td>SUSPENDED</td><td>The supervisor has been suspended</td></tr><tr><td>STOPPING</td><td>STOPPING</td><td>The supervisor is stopping</td></tr></tbody></table><p>On each iteration of the supervisor&#x27;s run loop, the supervisor completes the following tasks in sequence:
1) Fetch the list of partitions from Kafka and determine the starting offset for each partition (either based on the
last processed offset if continuing, or starting from the beginning or ending of the stream if this is a new topic).
2) Discover any running indexing tasks that are writing to the supervisor&#x27;s datasource and adopt them if they match
the supervisor&#x27;s configuration, else signal them to stop.
3) Send a status request to each supervised task to update our view of the state of the tasks under our supervision.
4) Handle tasks that have exceeded <code>taskDuration</code> and should transition from the reading to publishing state.
5) Handle tasks that have finished publishing and signal redundant replica tasks to stop.
6) Handle tasks that have failed and clean up the supervisor&#x27;s internal state.
7) Compare the list of healthy tasks to the requested <code>taskCount</code> and <code>replicas</code> configurations and create additional tasks if required in case supervisor is not idle.</p><p>The <code>detailedState</code> field will show additional values (those marked with &quot;first iteration only&quot;) the first time the
supervisor executes this run loop after startup or after resuming from a suspension. This is intended to surface
initialization-type issues, where the supervisor is unable to reach a stable state (perhaps because it can&#x27;t connect to
Kafka, it can&#x27;t read from the Kafka topic, or it can&#x27;t communicate with existing tasks). Once the supervisor is stable -
that is, once it has completed a full execution without encountering any issues - <code>detailedState</code> will show a <code>RUNNING</code>
state until it is idle, stopped, suspended, or hits a task failure threshold and transitions to an unhealthy state.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="getting-supervisor-ingestion-stats-report">Getting Supervisor Ingestion Stats Report<a href="#getting-supervisor-ingestion-stats-report" class="hash-link" aria-label="Direct link to Getting Supervisor Ingestion Stats Report" title="Direct link to Getting Supervisor Ingestion Stats Report"></a></h2><p><code>GET /druid/indexer/v1/supervisor/&lt;supervisorId&gt;/stats</code> returns a snapshot of the current ingestion row counters for each task being managed by the supervisor, along with moving averages for the row counters.</p><p>See <a href="/docs/latest/ingestion/tasks#row-stats">Task Reports: Row Stats</a> for more information.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="supervisor-health-check">Supervisor Health Check<a href="#supervisor-health-check" class="hash-link" aria-label="Direct link to Supervisor Health Check" title="Direct link to Supervisor Health Check"></a></h2><p><code>GET /druid/indexer/v1/supervisor/&lt;supervisorId&gt;/health</code> returns <code>200 OK</code> if the supervisor is healthy and
<code>503 Service Unavailable</code> if it is unhealthy. Healthiness is determined by the supervisor&#x27;s <code>state</code> (as returned by the
<code>/status</code> endpoint) and the <code>druid.supervisor.*</code> Overlord configuration thresholds.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="updating-existing-supervisors">Updating Existing Supervisors<a href="#updating-existing-supervisors" class="hash-link" aria-label="Direct link to Updating Existing Supervisors" title="Direct link to Updating Existing Supervisors"></a></h2><p><code>POST /druid/indexer/v1/supervisor</code> can be used to update existing supervisor spec.
Calling this endpoint when there is already an existing supervisor for the same dataSource will cause:</p><ul><li>The running supervisor to signal its managed tasks to stop reading and begin publishing.</li><li>The running supervisor to exit.</li><li>A new supervisor to be created using the configuration provided in the request body. This supervisor will retain the
existing publishing tasks and will create new tasks starting at the offsets the publishing tasks ended on.</li></ul><p>Seamless schema migrations can thus be achieved by simply submitting the new schema using this endpoint.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="suspending-and-resuming-supervisors">Suspending and Resuming Supervisors<a href="#suspending-and-resuming-supervisors" class="hash-link" aria-label="Direct link to Suspending and Resuming Supervisors" title="Direct link to Suspending and Resuming Supervisors"></a></h2><p>You can suspend and resume a supervisor using <code>POST /druid/indexer/v1/supervisor/&lt;supervisorId&gt;/suspend</code> and <code>POST /druid/indexer/v1/supervisor/&lt;supervisorId&gt;/resume</code>, respectively.</p><p>Note that the supervisor itself will still be operating and emitting logs and metrics,
it will just ensure that no indexing tasks are running until the supervisor is resumed.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="resetting-supervisors">Resetting Supervisors<a href="#resetting-supervisors" class="hash-link" aria-label="Direct link to Resetting Supervisors" title="Direct link to Resetting Supervisors"></a></h2><p>The <code>POST /druid/indexer/v1/supervisor/&lt;supervisorId&gt;/reset</code> operation clears stored
offsets, causing the supervisor to start reading offsets from either the earliest or latest
offsets in Kafka (depending on the value of <code>useEarliestOffset</code>). After clearing stored
offsets, the supervisor kills and recreates any active tasks, so that tasks begin reading
from valid offsets. </p><p>Use care when using this operation! Resetting the supervisor may cause Kafka messages
to be skipped or read twice, resulting in missing or duplicate data. </p><p>The reason for using this operation is to recover from a state in which the supervisor
ceases operating due to missing offsets. The indexing service keeps track of the latest
persisted Kafka offsets in order to provide exactly-once ingestion guarantees across
tasks. Subsequent tasks must start reading from where the previous task completed in
order for the generated segments to be accepted. If the messages at the expected
starting offsets are no longer available in Kafka (typically because the message retention
period has elapsed or the topic was removed and re-created) the supervisor will refuse
to start and in flight tasks will fail. This operation enables you to recover from this condition. </p><p>Note that the supervisor must be running for this endpoint to be available.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="terminating-supervisors">Terminating Supervisors<a href="#terminating-supervisors" class="hash-link" aria-label="Direct link to Terminating Supervisors" title="Direct link to Terminating Supervisors"></a></h2><p>The <code>POST /druid/indexer/v1/supervisor/&lt;supervisorId&gt;/terminate</code> operation terminates a supervisor and causes all
associated indexing tasks managed by this supervisor to immediately stop and begin
publishing their segments. This supervisor will still exist in the metadata store and its history may be retrieved
with the supervisor history API, but will not be listed in the &#x27;get supervisors&#x27; API response nor can it&#x27;s configuration
or status report be retrieved. The only way this supervisor can start again is by submitting a functioning supervisor
spec to the create API.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="capacity-planning">Capacity Planning<a href="#capacity-planning" class="hash-link" aria-label="Direct link to Capacity Planning" title="Direct link to Capacity Planning"></a></h2><p>Kafka indexing tasks run on MiddleManagers and are thus limited by the resources available in the MiddleManager
cluster. In particular, you should make sure that you have sufficient worker capacity (configured using the
<code>druid.worker.capacity</code> property) to handle the configuration in the supervisor spec. Note that worker capacity is
shared across all types of indexing tasks, so you should plan your worker capacity to handle your total indexing load
(e.g. batch processing, realtime tasks, merging tasks, etc.). If your workers run out of capacity, Kafka indexing tasks
will queue and wait for the next available worker. This may cause queries to return partial results but will not result
in data loss (assuming the tasks run before Kafka purges those offsets).</p><p>A running task will normally be in one of two states: <em>reading</em> or <em>publishing</em>. A task will remain in reading state for
<code>taskDuration</code>, at which point it will transition to publishing state. A task will remain in publishing state for as long
as it takes to generate segments, push segments to deep storage, and have them be loaded and served by a Historical process
(or until <code>completionTimeout</code> elapses).</p><p>The number of reading tasks is controlled by <code>replicas</code> and <code>taskCount</code>. In general, there will be <code>replicas * taskCount</code>
reading tasks, the exception being if taskCount &gt; {numKafkaPartitions} in which case {numKafkaPartitions} tasks will
be used instead. When <code>taskDuration</code> elapses, these tasks will transition to publishing state and <code>replicas * taskCount</code>
new reading tasks will be created. Therefore to allow for reading tasks and publishing tasks to run concurrently, there
should be a minimum capacity of:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">workerCapacity = 2 * replicas * taskCount</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>This value is for the ideal situation in which there is at most one set of tasks publishing while another set is reading.
In some circumstances, it is possible to have multiple sets of tasks publishing simultaneously. This would happen if the
time-to-publish (generate segment, push to deep storage, loaded on Historical) &gt; <code>taskDuration</code>. This is a valid
scenario (correctness-wise) but requires additional worker capacity to support. In general, it is a good idea to have
<code>taskDuration</code> be large enough that the previous set of tasks finishes publishing before the current set begins.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="supervisor-persistence">Supervisor Persistence<a href="#supervisor-persistence" class="hash-link" aria-label="Direct link to Supervisor Persistence" title="Direct link to Supervisor Persistence"></a></h2><p>When a supervisor spec is submitted via the <code>POST /druid/indexer/v1/supervisor</code> endpoint, it is persisted in the
configured metadata database. There can only be a single supervisor per dataSource, and submitting a second spec for
the same dataSource will overwrite the previous one.</p><p>When an Overlord gains leadership, either by being started or as a result of another Overlord failing, it will spawn
a supervisor for each supervisor spec in the metadata database. The supervisor will then discover running Kafka indexing
tasks and will attempt to adopt them if they are compatible with the supervisor&#x27;s configuration. If they are not
compatible because they have a different ingestion spec or partition allocation, the tasks will be killed and the
supervisor will create a new set of tasks. In this way, the supervisors are persistent across Overlord restarts and
fail-overs.</p><p>A supervisor is stopped via the <code>POST /druid/indexer/v1/supervisor/&lt;supervisorId&gt;/terminate</code> endpoint. This places a
tombstone marker in the database (to prevent the supervisor from being reloaded on a restart) and then gracefully
shuts down the currently running supervisor. When a supervisor is shut down in this way, it will instruct its
managed tasks to stop reading and begin publishing their segments immediately. The call to the shutdown endpoint will
return after all tasks have been signaled to stop but before the tasks finish publishing their segments.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="schemaconfiguration-changes">Schema/Configuration Changes<a href="#schemaconfiguration-changes" class="hash-link" aria-label="Direct link to Schema/Configuration Changes" title="Direct link to Schema/Configuration Changes"></a></h3><p>Schema and configuration changes are handled by submitting the new supervisor spec via the same
<code>POST /druid/indexer/v1/supervisor</code> endpoint used to initially create the supervisor. The Overlord will initiate a
graceful shutdown of the existing supervisor which will cause the tasks being managed by that supervisor to stop reading
and begin publishing their segments. A new supervisor will then be started which will create a new set of tasks that
will start reading from the offsets where the previous now-publishing tasks left off, but using the updated schema.
In this way, configuration changes can be applied without requiring any pause in ingestion.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="deployment-notes-on-kafka-partitions-and-druid-segments">Deployment Notes on Kafka partitions and Druid segments<a href="#deployment-notes-on-kafka-partitions-and-druid-segments" class="hash-link" aria-label="Direct link to Deployment Notes on Kafka partitions and Druid segments" title="Direct link to Deployment Notes on Kafka partitions and Druid segments"></a></h2><p>Druid assigns each Kafka indexing task Kafka partitions. A task writes the events it consumes from Kafka into a single segment for the segment granularity interval until it reaches one of the following: <code>maxRowsPerSegment</code>, <code>maxTotalRows</code> or <code>intermediateHandoffPeriod</code> limit. At this point, the task creates a new partition for this segment granularity to contain subsequent events.</p><p>The Kafka Indexing Task also does incremental hand-offs. Therefore segments become available as they are ready and you do not have to wait for all segments until the end of the task duration. When the task reaches one of <code>maxRowsPerSegment</code>, <code>maxTotalRows</code>, or <code>intermediateHandoffPeriod</code>, it hands off all the segments and creates a new new set of segments will be created for further events. This allows the task to run for longer durations without accumulating old segments locally on Middle Manager processes.</p><p>The Kafka Indexing Service may still produce some small segments. For example, consider the following scenario:</p><ul><li>Task duration is 4 hours</li><li>Segment granularity is set to an HOUR</li><li>The supervisor was started at 9:10
After 4 hours at 13:10, Druid starts a new set of tasks. The events for the interval 13:00 - 14:00 may be split across existing tasks and the new set of tasks which could result in small segments. To merge them together into new segments of an ideal size (in the range of ~500-700 MB per segment), you can schedule re-indexing tasks, optionally with a different segment granularity.</li></ul><p>For more detail, see <a href="/docs/latest/operations/segment-optimization">Segment size optimization</a>.
There is also ongoing work to support automatic segment compaction of sharded segments as well as compaction not requiring
Hadoop (see <a href="https://github.com/apache/druid/pull/5102" target="_blank" rel="noopener noreferrer">here</a>).</p></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/latest/development/extensions-core/kafka-supervisor-reference"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Apache Kafka supervisor</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/latest/development/extensions-core/kinesis-ingestion"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Amazon Kinesis</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#getting-supervisor-status-report" class="table-of-contents__link toc-highlight">Getting Supervisor Status Report</a></li><li><a href="#getting-supervisor-ingestion-stats-report" class="table-of-contents__link toc-highlight">Getting Supervisor Ingestion Stats Report</a></li><li><a href="#supervisor-health-check" class="table-of-contents__link toc-highlight">Supervisor Health Check</a></li><li><a href="#updating-existing-supervisors" class="table-of-contents__link toc-highlight">Updating Existing Supervisors</a></li><li><a href="#suspending-and-resuming-supervisors" class="table-of-contents__link toc-highlight">Suspending and Resuming Supervisors</a></li><li><a href="#resetting-supervisors" class="table-of-contents__link toc-highlight">Resetting Supervisors</a></li><li><a href="#terminating-supervisors" class="table-of-contents__link toc-highlight">Terminating Supervisors</a></li><li><a href="#capacity-planning" class="table-of-contents__link toc-highlight">Capacity Planning</a></li><li><a href="#supervisor-persistence" class="table-of-contents__link toc-highlight">Supervisor Persistence</a><ul><li><a href="#schemaconfiguration-changes" class="table-of-contents__link toc-highlight">Schema/Configuration Changes</a></li></ul></li><li><a href="#deployment-notes-on-kafka-partitions-and-druid-segments" class="table-of-contents__link toc-highlight">Deployment Notes on Kafka partitions and Druid segments</a></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="footer__bottom text--center"><div class="margin-bottom--sm"><img src="/img/favicon.png" class="themedImage_ToTc themedImage--light_HNdA footer__logo"><img src="/img/favicon.png" class="themedImage_ToTc themedImage--dark_i4oU footer__logo"></div><div class="footer__copyright">Copyright © 2023 Apache Software Foundation. Except where otherwise noted, licensed under CC BY-SA 4.0. Apache Druid, Druid, and the Druid logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.</div></div></div></footer></div>
<script src="/assets/js/runtime~main.dc5f839a.js"></script>
<script src="/assets/js/main.a03dfc13.js"></script>
</body>
</html>