ServiceNow에서 REST API 엔드포인트 만들기

이 태스크에 대한 정보

IBM Storage Insights에서 수신한 웹훅을 처리하려면, ServiceNow 인스턴스에서 REST API 엔드포인트를 만들어야 합니다.

프로시저

ServiceNow에서 REST API 엔드포인트를 만들려면 다음 단계를 완료하세요:

  1. ServiceNow 인스턴스에 액세스하고 스크립트된 REST API 페이지로 이동합니다.
    페이지를 빠르게 찾으려면 모두 메뉴의 검색 표시줄에 "Scripted REST APIs" 를 입력하십시오.
  2. 새로 작성을 클릭하십시오.
  3. 적합한 이름 및 API ID를 입력하십시오.
  4. 제출을 클릭하십시오.
    새 REST API 엔드포인트가 작성됩니다.
  5. 스크립트된 REST API 페이지에서 새로 작성된 REST API 엔드포인트를 여십시오.
  6. 자원 탭에서 새로 작성을 클릭하십시오.
    1. 이 자원의 이름을 제공하십시오.
    2. HTTP 메서드를 POST로 설정합니다.
    3. 다음 코드 스니펫을 스크립트 섹션에 붙여넣으십시오.
      (function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
        var event = request.body.data;
        var inc = new GlideRecord('incident');
        var prefixMsg = "";
        var eventTime = new GlideTime(event.occurrenceTimeInMs || event.occurrenceTime);
        inc.initialize();
        inc.caller_id = event.caller;
        if (event.alertSource) {
          prefixMsg = "You don't need to act on this incident as it is generated to verify the webhook connection from your IBM Storage Insights. The webhook connection was successful and the payload received from IBM Storage Insights is as follows: ";
          inc.impact = 3;
          inc.urgency = 3;
          inc.short_description = "The test incident that is generated because you tested the webhook connection from your IBM Storage Insights instance.";
          inc.description = prefixMsg + JSON.stringify(event, null, '\t');
        } else if (event.name == "Ransomware Threat Detection" || event.name == "Workload anomaly event") {
          prefixMsg = "This incident is created automatically as there was a ransomware threat alert triggered in your IBM Storage Insights. You can take necessary actions to mitigate the issue. The payload received from IBM Storage Insights is as follows: ";
          inc.impact = 1;
          inc.urgency = 1;
          inc.short_description = event.name + " alert was triggered on your IBM Storage Insights on " + eventTime.getByFormat('dd MMMM YYYY');
          inc.description = prefixMsg + JSON.stringify(event, null, '\t');
        } else {
          prefixMsg = "This incident is created automatically as there was an alert triggered in your IBM Storage Insights. You can take necessary actions to mitigate the issue. The payload received from IBM Storage Insights is as follows: ";
          inc.impact = 1;
          inc.urgency = 1;
          inc.short_description = event.name + " alert was triggered on your IBM Storage Insights on " + eventTime.getByFormat('dd MMMM YYYY');
          inc.description = prefixMsg + JSON.stringify(event, null, '\t');
        }
        inc.insert();
        var responseBody = {};
        responseBody.message = "Incident created.";
        responseBody.incidentnumber = inc.number;
        response.setBody(responseBody);
      })(request, response);
      주: 코드 스니펫에는 ServiceNow에서 인시던트를 생성하는 로직이 포함되어 있습니다. 에서 만든 인시던트의 긴급성영향 수준은 ServiceNow 에서 트리거된 알림이 있는 경우 긴급성 및 영향 수준이 높음으로 설정됩니다 IBM Storage Insights. IBM Storage Insights에서 웹훅 연결을 테스트하는 경우 이러한 필드는 낮은 수준으로 설정됩니다. 인시던트 작성의 필요에 따라 코드 스니펫을 세분화할 수 있습니다.
    4. 인증 필요가 선택되어 있는지 확인하여 기본 인증 및 OAuth 2.0 인증 유형을 사용하여 IBM Storage Insights에서 웹훅의 유효성을 검사합니다. 제출을 클릭합니다.
    5. 자원 섹션의 자원 경로 컬럼에서 사용 가능한 자원 경로를 기록해 두십시오.
      리소스 경로는 웹훅을 생성할 때 웹훅 URL 필드에 제공해야 합니다 IBM Storage Insights.

결과

REST API 엔드포인트가 작성되었습니다. 이제 IBM Storage Insights 인스턴스에서 웹훅을 생성하여 추가 통합을 할 수 있습니다. ServiceNow에 대한 웹훅 만들기을 참조하세요.