datahub/assets/js/0bf62f0f.6fecb46a.js

1 line
8.2 KiB
JavaScript

"use strict";(self.webpackChunkdocs_website=self.webpackChunkdocs_website||[]).push([[25415],{89570:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>h,frontMatter:()=>u,metadata:()=>p,toc:()=>y});t(96540);var i=t(15680),a=t(53720),s=t(5400);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})),e}function l(e,n){if(null==e)return{};var t,i,a=function(e,n){if(null==e)return{};var t,i,a={},s=Object.keys(e);for(i=0;i<s.length;i++)t=s[i],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)t=s[i],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}const u={title:"Incidents",slug:"/api/tutorials/incidents",custom_edit_url:"https://github.com/datahub-project/datahub/blob/master/docs/api/tutorials/incidents.md"},d="Incidents",p={unversionedId:"docs/api/tutorials/incidents",id:"version-1.1.0/docs/api/tutorials/incidents",title:"Incidents",description:"Why Would You Use Incidents APIs?",source:"@site/versioned_docs/version-1.1.0/docs/api/tutorials/incidents.md",sourceDirName:"docs/api/tutorials",slug:"/api/tutorials/incidents",permalink:"/docs/1.1.0/api/tutorials/incidents",draft:!1,editUrl:"https://github.com/datahub-project/datahub/blob/master/docs/api/tutorials/incidents.md",tags:[],version:"1.1.0",frontMatter:{title:"Incidents",slug:"/api/tutorials/incidents",custom_edit_url:"https://github.com/datahub-project/datahub/blob/master/docs/api/tutorials/incidents.md"},sidebar:"overviewSidebar",previous:{title:"Custom Assertions",permalink:"/docs/1.1.0/api/tutorials/custom-assertions"},next:{title:"Operations",permalink:"/docs/1.1.0/api/tutorials/operations"}},c={},y=[{value:"Why Would You Use Incidents APIs?",id:"why-would-you-use-incidents-apis",level:2},{value:"Goal Of This Guide",id:"goal-of-this-guide",level:3},{value:"Prerequisites",id:"prerequisites",level:2},{value:"Raise Incident",id:"raise-incident",level:2},{value:"Get Incidents For Data Asset",id:"get-incidents-for-data-asset",level:2},{value:"Resolve Incidents",id:"resolve-incidents",level:2}],g={toc:y},m="wrapper";function h(e){var{components:n}=e,t=l(e,["components"]);return(0,i.yg)(m,o(function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},i=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),i.forEach((function(n){r(e,n,t[n])}))}return e}({},g,t),{components:n,mdxType:"MDXLayout"}),(0,i.yg)("h1",{id:"incidents"},"Incidents"),(0,i.yg)("h2",{id:"why-would-you-use-incidents-apis"},"Why Would You Use Incidents APIs?"),(0,i.yg)("p",null,"The Incidents APIs allow you to raise, retrieve, update and resolve data incidents via API. This is\nuseful for raising or resolving data incidents programmatically, for example from Airflow, Prefect, or Dagster DAGs.\nIncidents are also useful for conditional Circuit Breaking in these pipelines."),(0,i.yg)("h3",{id:"goal-of-this-guide"},"Goal Of This Guide"),(0,i.yg)("p",null,"This guide will show you how to raise, retrieve, update and resolve data incidents via API."),(0,i.yg)("h2",{id:"prerequisites"},"Prerequisites"),(0,i.yg)("p",null,"The actor making API calls must have the ",(0,i.yg)("inlineCode",{parentName:"p"},"Edit Incidents")," privileges for the Tables at hand."),(0,i.yg)("h2",{id:"raise-incident"},"Raise Incident"),(0,i.yg)("p",null,"You can raise a new Data Incident for an existing asset using the following APIs."),(0,i.yg)(a.A,{mdxType:"Tabs"},(0,i.yg)(s.A,{value:"graphql",label:"GraphQL",default:!0,mdxType:"TabItem"},(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre",className:"language-graphql"},'mutation raiseIncident {\n raiseIncident(\n input: {\n resourceUrn: "urn:li:dataset:(urn:li:dataPlatform:snowflake,public.prod.purchases,PROD)"\n type: OPERATIONAL\n title: "Data is Delayed"\n description: "Data is delayed on May 15, 2024 because of downtime in the Spark Cluster."\n }\n )\n}\n')),(0,i.yg)("p",null,"Where ",(0,i.yg)("inlineCode",{parentName:"p"},"resourceUrn")," is the unique identifier for the data asset (dataset, dashboard, chart, data job, or data flow) you want to raise the incident on."),(0,i.yg)("p",null,"Where supported Incident Types include"),(0,i.yg)("ul",null,(0,i.yg)("li",{parentName:"ul"},(0,i.yg)("inlineCode",{parentName:"li"},"OPERATIONAL")),(0,i.yg)("li",{parentName:"ul"},(0,i.yg)("inlineCode",{parentName:"li"},"FRESHNESS")),(0,i.yg)("li",{parentName:"ul"},(0,i.yg)("inlineCode",{parentName:"li"},"VOLUME")),(0,i.yg)("li",{parentName:"ul"},(0,i.yg)("inlineCode",{parentName:"li"},"COLUMN")),(0,i.yg)("li",{parentName:"ul"},(0,i.yg)("inlineCode",{parentName:"li"},"SQL")),(0,i.yg)("li",{parentName:"ul"},(0,i.yg)("inlineCode",{parentName:"li"},"DATA_SCHEMA")),(0,i.yg)("li",{parentName:"ul"},(0,i.yg)("inlineCode",{parentName:"li"},"CUSTOM"))),(0,i.yg)("p",null,"If you see the following response, a unique identifier for the new incident will be returned."),(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre",className:"language-json"},'{\n "data": {\n "raiseIncident": "urn:li:incident:new-incident-id"\n },\n "extensions": {}\n}\n'))),(0,i.yg)(s.A,{value:"python",label:"Python",mdxType:"TabItem"},(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre"},"Python SDK support coming soon!\n")))),(0,i.yg)("h2",{id:"get-incidents-for-data-asset"},"Get Incidents For Data Asset"),(0,i.yg)("p",null,"You can use retrieve the incidents and their statuses for a given Data Asset using the following APIs."),(0,i.yg)(a.A,{mdxType:"Tabs"},(0,i.yg)(s.A,{value:"graphql",label:"GraphQL",default:!0,mdxType:"TabItem"},(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre",className:"language-graphql"},'query getAssetIncidents {\n dataset(\n urn: "urn:li:dataset:(urn:li:dataPlatform:snowflake,public.prod.purchases,PROD)"\n ) {\n incidents(state: ACTIVE, start: 0, count: 20) {\n start\n count\n total\n incidents {\n urn\n incidentType\n title\n description\n status {\n state\n lastUpdated {\n time\n actor\n }\n }\n }\n }\n }\n}\n')),(0,i.yg)("p",null,"Where you can filter for active incidents by passing the ",(0,i.yg)("inlineCode",{parentName:"p"},"ACTIVE")," state and resolved incidents by passing the ",(0,i.yg)("inlineCode",{parentName:"p"},"RESOLVED")," state.\nThis will return all relevant incidents for the dataset.")),(0,i.yg)(s.A,{value:"python",label:"Python",mdxType:"TabItem"},(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre"},"Python SDK support coming soon!\n")))),(0,i.yg)("h2",{id:"resolve-incidents"},"Resolve Incidents"),(0,i.yg)("p",null,"You can update the status of an incident using the following APIs."),(0,i.yg)(a.A,{mdxType:"Tabs"},(0,i.yg)(s.A,{value:"graphql",label:"GraphQL",default:!0,mdxType:"TabItem"},(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre",className:"language-graphql"},'mutation updateIncidentStatus {\n updateIncidentStatus(\n input: {\n state: RESOLVED\n message: "The delayed data issue was resolved at 4:55pm on May 15."\n }\n )\n}\n')),(0,i.yg)("p",null,"You can also reopen an incident by updating the state from ",(0,i.yg)("inlineCode",{parentName:"p"},"RESOLVED")," to ",(0,i.yg)("inlineCode",{parentName:"p"},"ACTIVE"),"."),(0,i.yg)("p",null,"If you see the following response, the operation was successful:"),(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre",className:"language-json"},'{\n "data": {\n "updateIncidentStatus": true\n },\n "extensions": {}\n}\n'))),(0,i.yg)(s.A,{value:"python",label:"Python",mdxType:"TabItem"},(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre"},"Python SDK support coming soon!\n")))))}h.isMDXComponent=!0}}]);