blob: 4fdd1c8bccf7ae68ffacea09a203dcad3be82e4b [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[4546],{15680:(e,a,n)=>{n.d(a,{xA:()=>p,yg:()=>c});var t=n(96540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function r(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a<arguments.length;a++){var n=null!=arguments[a]?arguments[a]:{};a%2?r(Object(n),!0).forEach((function(a){s(e,a,n[a])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))}))}return e}function o(e,a){if(null==e)return{};var n,t,s=function(e,a){if(null==e)return{};var n,t,s={},r=Object.keys(e);for(t=0;t<r.length;t++)n=r[t],a.indexOf(n)>=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(t=0;t<r.length;t++)n=r[t],a.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var i=t.createContext({}),u=function(e){var a=t.useContext(i),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},p=function(e){var a=u(e.components);return t.createElement(i.Provider,{value:a},e.children)},d="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},g=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,r=e.originalType,i=e.parentName,p=o(e,["components","mdxType","originalType","parentName"]),d=u(n),g=s,c=d["".concat(i,".").concat(g)]||d[g]||m[g]||r;return n?t.createElement(c,l(l({ref:a},p),{},{components:n})):t.createElement(c,l({ref:a},p))}));function c(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var r=n.length,l=new Array(r);l[0]=g;var o={};for(var i in a)hasOwnProperty.call(a,i)&&(o[i]=a[i]);o.originalType=e,o[d]="string"==typeof e?e:s,l[1]=o;for(var u=2;u<r;u++)l[u]=n[u];return t.createElement.apply(null,l)}return t.createElement.apply(null,n)}g.displayName="MDXCreateElement"},19365:(e,a,n)=>{n.d(a,{A:()=>l});var t=n(96540),s=n(20053);const r={tabItem:"tabItem_Ymn6"};function l(e){var a=e.children,n=e.hidden,l=e.className;return t.createElement("div",{role:"tabpanel",className:(0,s.A)(r.tabItem,l),hidden:n},a)}},11470:(e,a,n)=>{n.d(a,{A:()=>N});var t=n(58168),s=n(96540),r=n(20053),l=n(23104),o=n(56347),i=n(57485),u=n(31682),p=n(89466);function d(e){return function(e){var a,n;return null!=(a=null==(n=s.Children.map(e,(function(e){if(!e||(0,s.isValidElement)(e)&&(a=e.props)&&"object"==typeof a&&"value"in a)return e;var a;throw new Error("Docusaurus error: Bad <Tabs> child <"+("string"==typeof e.type?e.type:e.type.name)+'>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.')})))?void 0:n.filter(Boolean))?a:[]}(e).map((function(e){var a=e.props;return{value:a.value,label:a.label,attributes:a.attributes,default:a.default}}))}function m(e){var a=e.values,n=e.children;return(0,s.useMemo)((function(){var e=null!=a?a:d(n);return function(e){var a=(0,u.X)(e,(function(e,a){return e.value===a.value}));if(a.length>0)throw new Error('Docusaurus error: Duplicate values "'+a.map((function(e){return e.value})).join(", ")+'" found in <Tabs>. Every value needs to be unique.')}(e),e}),[a,n])}function g(e){var a=e.value;return e.tabValues.some((function(e){return e.value===a}))}function c(e){var a=e.queryString,n=void 0!==a&&a,t=e.groupId,r=(0,o.W6)(),l=function(e){var a=e.queryString,n=void 0!==a&&a,t=e.groupId;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return null!=t?t:null}({queryString:n,groupId:t});return[(0,i.aZ)(l),(0,s.useCallback)((function(e){if(l){var a=new URLSearchParams(r.location.search);a.set(l,e),r.replace(Object.assign({},r.location,{search:a.toString()}))}}),[l,r])]}function y(e){var a,n,t,r,l=e.defaultValue,o=e.queryString,i=void 0!==o&&o,u=e.groupId,d=m(e),y=(0,s.useState)((function(){return function(e){var a,n=e.defaultValue,t=e.tabValues;if(0===t.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(n){if(!g({value:n,tabValues:t}))throw new Error('Docusaurus error: The <Tabs> has a defaultValue "'+n+'" but none of its children has the corresponding value. Available values are: '+t.map((function(e){return e.value})).join(", ")+". If you intend to show no default tab, use defaultValue={null} instead.");return n}var s=null!=(a=t.find((function(e){return e.default})))?a:t[0];if(!s)throw new Error("Unexpected error: 0 tabValues");return s.value}({defaultValue:l,tabValues:d})})),h=y[0],T=y[1],v=c({queryString:i,groupId:u}),f=v[0],b=v[1],N=(a=function(e){return e?"docusaurus.tab."+e:null}({groupId:u}.groupId),n=(0,p.Dv)(a),t=n[0],r=n[1],[t,(0,s.useCallback)((function(e){a&&r.set(e)}),[a,r])]),R=N[0],_=N[1],k=function(){var e=null!=f?f:R;return g({value:e,tabValues:d})?e:null}();return(0,s.useLayoutEffect)((function(){k&&T(k)}),[k]),{selectedValue:h,selectValue:(0,s.useCallback)((function(e){if(!g({value:e,tabValues:d}))throw new Error("Can't select invalid tab value="+e);T(e),b(e),_(e)}),[b,_,d]),tabValues:d}}var h=n(92303);const T={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};function v(e){var a=e.className,n=e.block,o=e.selectedValue,i=e.selectValue,u=e.tabValues,p=[],d=(0,l.a_)().blockElementScrollPositionUntilNextRender,m=function(e){var a=e.currentTarget,n=p.indexOf(a),t=u[n].value;t!==o&&(d(a),i(t))},g=function(e){var a,n=null;switch(e.key){case"Enter":m(e);break;case"ArrowRight":var t,s=p.indexOf(e.currentTarget)+1;n=null!=(t=p[s])?t:p[0];break;case"ArrowLeft":var r,l=p.indexOf(e.currentTarget)-1;n=null!=(r=p[l])?r:p[p.length-1]}null==(a=n)||a.focus()};return s.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":n},a)},u.map((function(e){var a=e.value,n=e.label,l=e.attributes;return s.createElement("li",(0,t.A)({role:"tab",tabIndex:o===a?0:-1,"aria-selected":o===a,key:a,ref:function(e){return p.push(e)},onKeyDown:g,onClick:m},l,{className:(0,r.A)("tabs__item",T.tabItem,null==l?void 0:l.className,{"tabs__item--active":o===a})}),null!=n?n:a)})))}function f(e){var a=e.lazy,n=e.children,t=e.selectedValue,r=(Array.isArray(n)?n:[n]).filter(Boolean);if(a){var l=r.find((function(e){return e.props.value===t}));return l?(0,s.cloneElement)(l,{className:"margin-top--md"}):null}return s.createElement("div",{className:"margin-top--md"},r.map((function(e,a){return(0,s.cloneElement)(e,{key:a,hidden:e.props.value!==t})})))}function b(e){var a=y(e);return s.createElement("div",{className:(0,r.A)("tabs-container",T.tabList)},s.createElement(v,(0,t.A)({},e,a)),s.createElement(f,(0,t.A)({},e,a)))}function N(e){var a=(0,h.A)();return s.createElement(b,(0,t.A)({key:String(a)},e))}},94378:(e,a,n)=>{n.r(a),n.d(a,{assets:()=>m,contentTitle:()=>p,default:()=>h,frontMatter:()=>u,metadata:()=>d,toc:()=>g});var t=n(58168),s=n(98587),r=(n(96540),n(15680)),l=n(11470),o=n(19365),i=["components"],u={id:"data-management-api",title:"Data management API",sidebar_label:"Data management"},p=void 0,d={unversionedId:"api-reference/data-management-api",id:"api-reference/data-management-api",title:"Data management API",description:"\x3c!--",source:"@site/docs/latest/api-reference/data-management-api.md",sourceDirName:"api-reference",slug:"/api-reference/data-management-api",permalink:"/docs/latest/api-reference/data-management-api",draft:!1,tags:[],version:"current",frontMatter:{id:"data-management-api",title:"Data management API",sidebar_label:"Data management"},sidebar:"docs",previous:{title:"Retention rules",permalink:"/docs/latest/api-reference/retention-rules-api"},next:{title:"Automatic compaction",permalink:"/docs/latest/api-reference/automatic-compaction-api"}},m={},g=[{value:"Segment management",id:"segment-management",level:2},{value:"Segment IDs",id:"segment-ids",level:3},{value:"Mark a single segment unused",id:"mark-a-single-segment-unused",level:3},{value:"URL",id:"url",level:4},{value:"Header",id:"header",level:4},{value:"Responses",id:"responses",level:4},{value:"Sample request",id:"sample-request",level:4},{value:"Sample response",id:"sample-response",level:4},{value:"Mark a single segment as used",id:"mark-a-single-segment-as-used",level:3},{value:"URL",id:"url-1",level:4},{value:"Header",id:"header-1",level:4},{value:"Responses",id:"responses-1",level:4},{value:"Sample request",id:"sample-request-1",level:4},{value:"Sample response",id:"sample-response-1",level:4},{value:"Mark a group of segments unused",id:"mark-a-group-of-segments-unused",level:3},{value:"URL",id:"url-2",level:4},{value:"Request body",id:"request-body",level:4},{value:"Responses",id:"responses-2",level:4},{value:"Sample request",id:"sample-request-2",level:4},{value:"Sample response",id:"sample-response-2",level:4},{value:"Mark a group of segments used",id:"mark-a-group-of-segments-used",level:3},{value:"URL",id:"url-3",level:4},{value:"Request body",id:"request-body-1",level:4},{value:"Responses",id:"responses-3",level:4},{value:"Sample request",id:"sample-request-3",level:4},{value:"Sample response",id:"sample-response-3",level:4},{value:"Mark all segments unused",id:"mark-all-segments-unused",level:3},{value:"URL",id:"url-4",level:4},{value:"Responses",id:"responses-4",level:4},{value:"Sample request",id:"sample-request-4",level:4},{value:"Sample response",id:"sample-response-4",level:4},{value:"Mark all segments used",id:"mark-all-segments-used",level:3},{value:"URL",id:"url-5",level:4},{value:"Header",id:"header-2",level:4},{value:"Responses",id:"responses-5",level:4},{value:"Sample request",id:"sample-request-5",level:4},{value:"Sample response",id:"sample-response-5",level:4},{value:"Segment deletion",id:"segment-deletion",level:2},{value:"Permanently delete segments",id:"permanently-delete-segments",level:3},{value:"URL",id:"url-6",level:4},{value:"Responses",id:"responses-6",level:4},{value:"Sample request",id:"sample-request-6",level:4},{value:"Sample response",id:"sample-response-6",level:4}],c={toc:g},y="wrapper";function h(e){var a=e.components,n=(0,s.A)(e,i);return(0,r.yg)(y,(0,t.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"This topic describes the data management API endpoints for Apache Druid.\nThis includes information on how to mark segments as used or unused and delete them from Druid."),(0,r.yg)("p",null,"In this topic, ",(0,r.yg)("inlineCode",{parentName:"p"},"http://ROUTER_IP:ROUTER_PORT")," is a placeholder for your Router service address and port.\nReplace it with the information for your deployment.\nFor example, use ",(0,r.yg)("inlineCode",{parentName:"p"},"http://localhost:8888")," for quickstart deployments."),(0,r.yg)("admonition",{type:"info"},(0,r.yg)("p",{parentName:"admonition"},"Avoid using indexing or kill tasks and these APIs at the same time for the same datasource and time chunk.")),(0,r.yg)("h2",{id:"segment-management"},"Segment management"),(0,r.yg)("p",null,"You can mark segments as used by sending POST requests to the datasource, but the Coordinator may subsequently mark segments as unused if they meet any configured ",(0,r.yg)("a",{parentName:"p",href:"/docs/latest/operations/rule-configuration#drop-rules"},"drop rules"),".\nEven if these API requests update segments to used, you still need to configure a ",(0,r.yg)("a",{parentName:"p",href:"/docs/latest/operations/rule-configuration#load-rules"},"load rule")," to load them onto Historical processes."),(0,r.yg)("p",null,"When you use these APIs concurrently with an indexing task or a kill task, the behavior is undefined.\nDruid terminates some segments and marks others as used.\nFurthermore, it is possible that all segments could be unused, yet an indexing task might still be able to read data from these segments and complete successfully."),(0,r.yg)("h3",{id:"segment-ids"},"Segment IDs"),(0,r.yg)("p",null,"You must provide segment IDs when using many of the endpoints described in this topic.\nFor information on segment IDs, see ",(0,r.yg)("a",{parentName:"p",href:"/docs/latest/design/segments#segment-identification"},"Segment identification"),".\nFor information on finding segment IDs in the web console, see ",(0,r.yg)("a",{parentName:"p",href:"/docs/latest/operations/web-console#segments"},"Segments"),"."),(0,r.yg)("h3",{id:"mark-a-single-segment-unused"},"Mark a single segment unused"),(0,r.yg)("p",null,'Marks the state of a segment as unused, using the segment ID.\nThis is a "soft delete" of the segment from Historicals.\nTo undo this action, ',(0,r.yg)("a",{parentName:"p",href:"#mark-a-single-segment-as-used"},"mark the segment used"),"."),(0,r.yg)("p",null,"Note that this endpoint returns an HTTP ",(0,r.yg)("inlineCode",{parentName:"p"},"200 OK")," response code even if the segment ID or datasource doesn't exist."),(0,r.yg)("h4",{id:"url"},"URL"),(0,r.yg)("code",{class:"deleteAPI"},"DELETE")," ",(0,r.yg)("code",null,"/druid/coordinator/v1/datasources/:datasource/segments/:segmentId"),(0,r.yg)("h4",{id:"header"},"Header"),(0,r.yg)("p",null,"The following headers are required for this request:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},"Content-Type: application/json\nAccept: application/json, text/plain\n")),(0,r.yg)("h4",{id:"responses"},"Responses"),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"1",label:"200 SUCCESS",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Successfully updated segment")))),(0,r.yg)("hr",null),(0,r.yg)("h4",{id:"sample-request"},"Sample request"),(0,r.yg)("p",null,"The following example updates the segment ",(0,r.yg)("inlineCode",{parentName:"p"},"wikipedia_hour_2015-09-12T16:00:00.000Z_2015-09-12T17:00:00.000Z_2023-08-10T04:12:03.860Z")," from datasource ",(0,r.yg)("inlineCode",{parentName:"p"},"wikipedia_hour")," as ",(0,r.yg)("inlineCode",{parentName:"p"},"unused"),"."),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"2",label:"cURL",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-shell"},"curl --request DELETE \"http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/datasources/wikipedia_hour/segments/wikipedia_hour_2015-09-12T16:00:00.000Z_2015-09-12T17:00:00.000Z_2023-08-10T04:12:03.860Z\" \\\n--header 'Content-Type: application/json' \\\n--header 'Accept: application/json, text/plain'\n"))),(0,r.yg)(o.A,{value:"3",label:"HTTP",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-HTTP"},"DELETE /druid/coordinator/v1/datasources/wikipedia_hour/segments/wikipedia_hour_2015-09-12T16:00:00.000Z_2015-09-12T17:00:00.000Z_2023-08-10T04:12:03.860Z HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\nContent-Type: application/json\nAccept: application/json, text/plain\n")))),(0,r.yg)("h4",{id:"sample-response"},"Sample response"),(0,r.yg)("details",null,(0,r.yg)("summary",null,"Show sample response"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "segmentStateChanged": true\n}\n'))),(0,r.yg)("h3",{id:"mark-a-single-segment-as-used"},"Mark a single segment as used"),(0,r.yg)("p",null,"Marks the state of a segment as used, using the segment ID."),(0,r.yg)("h4",{id:"url-1"},"URL"),(0,r.yg)("code",{class:"postAPI"},"POST")," ",(0,r.yg)("code",null,"/druid/coordinator/v1/datasources/segments/:segmentId"),(0,r.yg)("h4",{id:"header-1"},"Header"),(0,r.yg)("p",null,"The following headers are required for this request:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},"Content-Type: application/json\nAccept: application/json, text/plain\n")),(0,r.yg)("h4",{id:"responses-1"},"Responses"),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"4",label:"200 SUCCESS",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Successfully updated segments")))),(0,r.yg)("hr",null),(0,r.yg)("h4",{id:"sample-request-1"},"Sample request"),(0,r.yg)("p",null,"The following example updates the segment with ID ",(0,r.yg)("inlineCode",{parentName:"p"},"wikipedia_hour_2015-09-12T18:00:00.000Z_2015-09-12T19:00:00.000Z_2023-08-10T04:12:03.860Z")," to used."),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"5",label:"cURL",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-shell"},"curl --request POST \"http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/datasources/wikipedia_hour/segments/wikipedia_hour_2015-09-12T18:00:00.000Z_2015-09-12T19:00:00.000Z_2023-08-10T04:12:03.860Z\" \\\n--header 'Content-Type: application/json' \\\n--header 'Accept: application/json, text/plain'\n"))),(0,r.yg)(o.A,{value:"6",label:"HTTP",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-HTTP"},"POST /druid/coordinator/v1/datasources/wikipedia_hour/segments/wikipedia_hour_2015-09-12T18:00:00.000Z_2015-09-12T19:00:00.000Z_2023-08-10T04:12:03.860Z HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\nContent-Type: application/json\nAccept: application/json, text/plain\n")))),(0,r.yg)("h4",{id:"sample-response-1"},"Sample response"),(0,r.yg)("details",null,(0,r.yg)("summary",null,"Show sample response"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "segmentStateChanged": true\n}\n'))),(0,r.yg)("h3",{id:"mark-a-group-of-segments-unused"},"Mark a group of segments unused"),(0,r.yg)("p",null,"Marks the state of a group of segments as unused, using an array of segment IDs or an interval.\nPass the array of segment IDs or interval as a JSON object in the request body."),(0,r.yg)("p",null,"For the interval, specify the start and end times as ISO 8601 strings to identify segments inclusive of the start time and exclusive of the end time.\nDruid only updates the segments completely contained within the specified interval; partially overlapping segments are not affected."),(0,r.yg)("h4",{id:"url-2"},"URL"),(0,r.yg)("code",{class:"postAPI"},"POST")," ",(0,r.yg)("code",null,"/druid/coordinator/v1/datasources/:datasource/markUnused"),(0,r.yg)("h4",{id:"request-body"},"Request body"),(0,r.yg)("p",null,"The group of segments is sent as a JSON request payload that accepts one of the following properties:"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:null},"Property"),(0,r.yg)("th",{parentName:"tr",align:null},"Description"),(0,r.yg)("th",{parentName:"tr",align:null},"Example"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:null},(0,r.yg)("inlineCode",{parentName:"td"},"interval")),(0,r.yg)("td",{parentName:"tr",align:null},"ISO 8601 segments interval."),(0,r.yg)("td",{parentName:"tr",align:null},(0,r.yg)("inlineCode",{parentName:"td"},'"2015-09-12T03:00:00.000Z/2015-09-12T05:00:00.000Z"'))),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:null},(0,r.yg)("inlineCode",{parentName:"td"},"segmentIds")),(0,r.yg)("td",{parentName:"tr",align:null},"Array of segment IDs."),(0,r.yg)("td",{parentName:"tr",align:null},(0,r.yg)("inlineCode",{parentName:"td"},'["segmentId1", "segmentId2"]'))))),(0,r.yg)("h4",{id:"responses-2"},"Responses"),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"7",label:"200 SUCCESS",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Successfully updated segments"))),(0,r.yg)(o.A,{value:"8",label:"204 NO CONTENT",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Invalid datasource name"))),(0,r.yg)(o.A,{value:"9",label:"400 BAD REQUEST",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Invalid request payload")))),(0,r.yg)("hr",null),(0,r.yg)("h4",{id:"sample-request-2"},"Sample request"),(0,r.yg)("p",null,"The following example marks two segments from the ",(0,r.yg)("inlineCode",{parentName:"p"},"wikipedia_hour")," datasource unused based on their segment IDs."),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"10",label:"cURL",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-shell"},'curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/datasources/wikipedia_hour/markUnused" \\\n--header \'Content-Type: application/json\' \\\n--data \'{\n "segmentIds": [\n "wikipedia_hour_2015-09-12T14:00:00.000Z_2015-09-12T15:00:00.000Z_2023-08-10T04:12:03.860Z",\n "wikipedia_hour_2015-09-12T04:00:00.000Z_2015-09-12T05:00:00.000Z_2023-08-10T04:12:03.860Z"\n ]\n}\'\n'))),(0,r.yg)(o.A,{value:"11",label:"HTTP",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-HTTP"},'POST /druid/coordinator/v1/datasources/wikipedia_hour/markUnused HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\nContent-Type: application/json\nContent-Length: 230\n\n{\n "segmentIds": [\n "wikipedia_hour_2015-09-12T14:00:00.000Z_2015-09-12T15:00:00.000Z_2023-08-10T04:12:03.860Z",\n "wikipedia_hour_2015-09-12T04:00:00.000Z_2015-09-12T05:00:00.000Z_2023-08-10T04:12:03.860Z"\n ]\n}\n')))),(0,r.yg)("h4",{id:"sample-response-2"},"Sample response"),(0,r.yg)("details",null,(0,r.yg)("summary",null,"Show sample response"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "numChangedSegments": 2\n}\n'))),(0,r.yg)("h3",{id:"mark-a-group-of-segments-used"},"Mark a group of segments used"),(0,r.yg)("p",null,"Marks the state of a group of segments as used, using an array of segment IDs or an interval.\nPass the array of segment IDs or interval as a JSON object in the request body."),(0,r.yg)("p",null,"For the interval, specify the start and end times as ISO 8601 strings to identify segments inclusive of the start time and exclusive of the end time.\nDruid only updates the segments completely contained within the specified interval; partially overlapping segments are not affected."),(0,r.yg)("h4",{id:"url-3"},"URL"),(0,r.yg)("code",{class:"postAPI"},"POST")," ",(0,r.yg)("code",null,"/druid/coordinator/v1/datasources/:datasource/markUsed"),(0,r.yg)("h4",{id:"request-body-1"},"Request body"),(0,r.yg)("p",null,"The group of segments is sent as a JSON request payload that accepts one of the following properties:"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:null},"Property"),(0,r.yg)("th",{parentName:"tr",align:null},"Description"),(0,r.yg)("th",{parentName:"tr",align:null},"Example"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:null},(0,r.yg)("inlineCode",{parentName:"td"},"interval")),(0,r.yg)("td",{parentName:"tr",align:null},"ISO 8601 segments interval."),(0,r.yg)("td",{parentName:"tr",align:null},(0,r.yg)("inlineCode",{parentName:"td"},'"2015-09-12T03:00:00.000Z/2015-09-12T05:00:00.000Z"'))),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:null},(0,r.yg)("inlineCode",{parentName:"td"},"segmentIds")),(0,r.yg)("td",{parentName:"tr",align:null},"Array of segment IDs."),(0,r.yg)("td",{parentName:"tr",align:null},(0,r.yg)("inlineCode",{parentName:"td"},'["segmentId1", "segmentId2"]'))))),(0,r.yg)("h4",{id:"responses-3"},"Responses"),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"12",label:"200 SUCCESS",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Successfully updated segments"))),(0,r.yg)(o.A,{value:"13",label:"204 NO CONTENT",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Invalid datasource name"))),(0,r.yg)(o.A,{value:"14",label:"400 BAD REQUEST",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Invalid request payload")))),(0,r.yg)("hr",null),(0,r.yg)("h4",{id:"sample-request-3"},"Sample request"),(0,r.yg)("p",null,"The following example marks two segments from the ",(0,r.yg)("inlineCode",{parentName:"p"},"wikipedia_hour")," datasource used based on their segment IDs."),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"15",label:"cURL",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-shell"},'curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/datasources/wikipedia_hour/markUsed" \\\n--header \'Content-Type: application/json\' \\\n--data \'{\n "segmentIds": [\n "wikipedia_hour_2015-09-12T14:00:00.000Z_2015-09-12T15:00:00.000Z_2023-08-10T04:12:03.860Z",\n "wikipedia_hour_2015-09-12T04:00:00.000Z_2015-09-12T05:00:00.000Z_2023-08-10T04:12:03.860Z"\n ]\n}\'\n'))),(0,r.yg)(o.A,{value:"16",label:"HTTP",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-HTTP"},'POST /druid/coordinator/v1/datasources/wikipedia_hour/markUsed HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\nContent-Type: application/json\nContent-Length: 230\n\n{\n "segmentIds": [\n "wikipedia_hour_2015-09-12T14:00:00.000Z_2015-09-12T15:00:00.000Z_2023-08-10T04:12:03.860Z",\n "wikipedia_hour_2015-09-12T04:00:00.000Z_2015-09-12T05:00:00.000Z_2023-08-10T04:12:03.860Z"\n ]\n}\n')))),(0,r.yg)("h4",{id:"sample-response-3"},"Sample response"),(0,r.yg)("details",null,(0,r.yg)("summary",null,"Show sample response"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "numChangedSegments": 2\n}\n'))),(0,r.yg)("h3",{id:"mark-all-segments-unused"},"Mark all segments unused"),(0,r.yg)("p",null,'Marks the state of all segments of a datasource as unused.\nThis action performs a "soft delete" of the segments from Historicals.'),(0,r.yg)("p",null,"Note that this endpoint returns an HTTP ",(0,r.yg)("inlineCode",{parentName:"p"},"200 OK")," response code even if the datasource doesn't exist."),(0,r.yg)("h4",{id:"url-4"},"URL"),(0,r.yg)("code",{class:"deleteAPI"},"DELETE")," ",(0,r.yg)("code",null,"/druid/coordinator/v1/datasources/:datasource"),(0,r.yg)("h4",{id:"responses-4"},"Responses"),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"17",label:"200 SUCCESS",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Successfully updated segments")))),(0,r.yg)("hr",null),(0,r.yg)("h4",{id:"sample-request-4"},"Sample request"),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"18",label:"cURL",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-shell"},'curl --request DELETE "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/datasources/wikipedia_hour"\n'))),(0,r.yg)(o.A,{value:"19",label:"HTTP",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-HTTP"},"DELETE /druid/coordinator/v1/datasources/wikipedia_hour HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\n")))),(0,r.yg)("h4",{id:"sample-response-4"},"Sample response"),(0,r.yg)("details",null,(0,r.yg)("summary",null,"Show sample response"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "numChangedSegments": 24\n}\n'))),(0,r.yg)("h3",{id:"mark-all-segments-used"},"Mark all segments used"),(0,r.yg)("p",null,"Marks the state of all unused segments of a datasource as used.\nThe endpoint returns the number of changed segments."),(0,r.yg)("p",null,"Note that this endpoint returns an HTTP ",(0,r.yg)("inlineCode",{parentName:"p"},"200 OK")," response code even if the datasource doesn't exist."),(0,r.yg)("h4",{id:"url-5"},"URL"),(0,r.yg)("code",{class:"postAPI"},"POST")," ",(0,r.yg)("code",null,"/druid/coordinator/v1/datasources/:datasource"),(0,r.yg)("h4",{id:"header-2"},"Header"),(0,r.yg)("p",null,"The following headers are required for this request:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},"Content-Type: application/json\nAccept: application/json, text/plain\n")),(0,r.yg)("h4",{id:"responses-5"},"Responses"),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"20",label:"200 SUCCESS",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Successfully updated segments")))),(0,r.yg)("hr",null),(0,r.yg)("h4",{id:"sample-request-5"},"Sample request"),(0,r.yg)("p",null,"The following example updates all unused segments of ",(0,r.yg)("inlineCode",{parentName:"p"},"wikipedia_hour")," to used.\n",(0,r.yg)("inlineCode",{parentName:"p"},"wikipedia_hour")," contains one unused segment eligible to be marked as used."),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"21",label:"cURL",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-shell"},"curl --request POST \"http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/datasources/wikipedia_hour\" \\\n--header 'Content-Type: application/json' \\\n--header 'Accept: application/json, text/plain'\n"))),(0,r.yg)(o.A,{value:"22",label:"HTTP",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-HTTP"},"POST /druid/coordinator/v1/datasources/wikipedia_hour HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\nContent-Type: application/json\nAccept: application/json, text/plain\n")))),(0,r.yg)("h4",{id:"sample-response-5"},"Sample response"),(0,r.yg)("details",null,(0,r.yg)("summary",null,"Show sample response"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "numChangedSegments": 1\n}\n'))),(0,r.yg)("h2",{id:"segment-deletion"},"Segment deletion"),(0,r.yg)("h3",{id:"permanently-delete-segments"},"Permanently delete segments"),(0,r.yg)("p",null,"The DELETE endpoint sends a ",(0,r.yg)("a",{parentName:"p",href:"/docs/latest/ingestion/tasks"},"kill task")," for a given interval and datasource. The interval value is an ISO 8601 string delimited by ",(0,r.yg)("inlineCode",{parentName:"p"},"_"),". This request permanently deletes all metadata for unused segments and removes them from deep storage."),(0,r.yg)("p",null,"Note that this endpoint returns an HTTP ",(0,r.yg)("inlineCode",{parentName:"p"},"200 OK")," response code even if the datasource doesn't exist."),(0,r.yg)("p",null,"This endpoint supersedes the deprecated endpoint: ",(0,r.yg)("inlineCode",{parentName:"p"},"DELETE /druid/coordinator/v1/datasources/:datasource?kill=true&interval=:interval")),(0,r.yg)("h4",{id:"url-6"},"URL"),(0,r.yg)("code",{class:"deleteAPI"},"DELETE")," ",(0,r.yg)("code",null,"/druid/coordinator/v1/datasources/:datasource/intervals/:interval"),(0,r.yg)("h4",{id:"responses-6"},"Responses"),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"23",label:"200 SUCCESS",mdxType:"TabItem"},(0,r.yg)("p",null,(0,r.yg)("em",{parentName:"p"},"Successfully sent kill task")))),(0,r.yg)("hr",null),(0,r.yg)("h4",{id:"sample-request-6"},"Sample request"),(0,r.yg)("p",null,"The following example sends a kill task to permanently delete segments in the datasource ",(0,r.yg)("inlineCode",{parentName:"p"},"wikipedia_hour")," from the interval ",(0,r.yg)("inlineCode",{parentName:"p"},"2015-09-12")," to ",(0,r.yg)("inlineCode",{parentName:"p"},"2015-09-13"),"."),(0,r.yg)(l.A,{mdxType:"Tabs"},(0,r.yg)(o.A,{value:"24",label:"cURL",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-shell"},'curl --request DELETE "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/datasources/wikipedia_hour/intervals/2015-09-12_2015-09-13"\n'))),(0,r.yg)(o.A,{value:"25",label:"HTTP",mdxType:"TabItem"},(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-HTTP"},"DELETE /druid/coordinator/v1/datasources/wikipedia_hour/intervals/2015-09-12_2015-09-13 HTTP/1.1\nHost: http://ROUTER_IP:ROUTER_PORT\n")))),(0,r.yg)("h4",{id:"sample-response-6"},"Sample response"),(0,r.yg)("p",null,"A successful request returns an HTTP ",(0,r.yg)("inlineCode",{parentName:"p"},"200 OK")," and an empty response body."))}h.isMDXComponent=!0}}]);