4 デフォルト・テンプレートの使用
この章では、PagerDutyコネクタに付属のデフォルト・チケッティング・テンプレートについて詳しく説明します。 チケット・テンプレートでは、Enterprise Managerのインシデントおよび基になるイベントの属性と、PagerDutyチケットの属性とのマッピングを指定します。
テンプレート・プロセス
すべての即時利用可能なテンプレートは、インシデントのチケットを作成するときに、次のアクションを実行します。
-
Description
(PagerDutyチケットの説明)にインシデント情報を書き込みます。 -
インシデント・メッセージに基づいて、PagerDutyチケットのサマリーを設定します。
あらかじめ用意されているテンプレートは次のとおりです。
-
pagerDutyCreateUpdateAndResolve.xsl
pagerDutyCreateUpdateAndResolve.xsl
テンプレートは、イベントの重大度値がクリアになると、チケットのステータスを「解決済」に設定します。 -
pagerDutyCreateAndUpdate.xsl
pagerDutyCreateAndUpdate.xsl
テンプレートは、Oracle Enterprise Managerの詳細変更時にチケットを更新しますが、イベント重大度がクリアになったときにチケットをクローズしません。
チケット・テンプレートの読取り
次の表に、pagerDutyCreateUpdateAndResolve.xsl
を使用したチケット作成の例を示します。 この表は、チケット・テンプレートの内容の解釈に役立ちます。 表内の*はリテラル文字列を表し、**は属性が該当する場合
を示します また、この表は、チケット作成マッピングについて、PagerDutyチケット属性とそれに対応するEnterprise Managerのインシデント値も示しています。
チケット作成マッピングは、pagerDutyCreateUpdateAndResolve.xsl
と pagerDutyCreateAndUpdate.xsl
で同じものです。
表4-1 チケット作成マッピング(すべてのテンプレート)
PagerDutyチケットの属性 | Enterprise Managerインシデントの属性 | 値 |
---|---|---|
タイプ |
. |
"incident" * |
service/id |
$SERVICE_ID$ |
構成時にサービスIDの値に設定します |
service/type |
. |
"service_reference" * |
body/type |
. |
"incident_body" * |
body/details |
サマリー 重大度コード 優先度 通知ルール名 通知ルール所有者 ターゲット・タイプ ターゲット名 オブジェクト所有者 ターゲット・プロパティ 最終更新日 インシデントURL |
サマリー - 発行されたインシデントについての詳細 重大度コード - Oracle Enterprise Managerでのインシデントの重大度 優先度 - Oracle Enterprise Managerでのインシデントの優先度 通知ルール名 - チケットを作成したルールの名前(自動チケットのみ) 通知ルール所有者 - チケットを作成したルールを所有するユーザーの名前(自動チケットのみ) ターゲット・タイプ - インシデントが発行されたターゲットのタイプ ターゲット名 - インシデントが発行されたターゲットの名前 オブジェクト所有者 - インシデントが発行されたオブジェクトを所有するユーザーの名前 ターゲット・プロパティ - インシデントに関する追加の名前と値。 ホスト、バージョン、OS、プラットフォームなど 最終更新日 - インシデントがOracle Enterprise Managerで作成された日付 インシデントURL - ユーザーをOracle Enterprise Managerインシデントに誘導するURLリンク |
タイトル |
重大度コード サマリー |
重大度コード - Oracle Enterprise Managerでのインシデントの重大度 サマリー - 発行されたインシデントについての詳細。 |
緊急度 |
重大度コード |
Oracle Enterprise Managerでのインシデントの重大度。 重大度が「致命的」または「クリティカル」クリティカルの場合は、緊急度を「High」に設定します。それ以外の場合は、緊急度を「Low」に設定します。 |
ステータス |
. |
「resolve」にハードコードされています。
ノート: これは、pagerDutyCreateUpdateAndResolve.xsl にのみあります |
このマッピング表を参照として使用し、次のXSLTファイルを読み取ります。
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:emcf="http://xmlns.oracle.com/sysman/connector" version="1.0"> <xsl:template match="emcf:EMIncident"> <!-- Please remember to backup all files before editing --> <!-- This area is where variables are set to be used in the rest of the template. By default there have two variables set: * Action: Used to figure out if the the connector is 'creating', 'updating' or 'closing' the PagerDuty Ticket. * Severity: Used to set the Urgency of the PagerDuty ticket. If you want to add or change variables, do so below. --> <xsl:variable name="action"> <xsl:choose> <xsl:when test="normalize-space(emcf:TicketID) = ''">CREATE</xsl:when> <xsl:when test="(emcf:SystemAttributes/emcf:SeverityCode = 'CLEAR')">CLOSE</xsl:when> <xsl:otherwise>UPDATE</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="severity"> <xsl:choose> <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'">high</xsl:when> <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'">high</xsl:when> <xsl:otherwise>low</xsl:otherwise> </xsl:choose> </xsl:variable> <Message> <!-- The following areas (Method, Variables, and Headers) should not be edited. They are used to make communication work between Oracle Enterprise Manager and PagerDuty. --> <Method> <xsl:choose> <xsl:when test="$action = 'CREATE'">POST</xsl:when> <xsl:when test="$action = 'UPDATE'">PUT</xsl:when> <xsl:when test="$action = 'CLOSE'">PUT</xsl:when> <xsl:otherwise>ERROR</xsl:otherwise> </xsl:choose> </Method> <Variables> <Variable> <Name>TKT_ID</Name> <Value> <xsl:value-of select="normalize-space(emcf:TicketID)" /> </Value> </Variable> </Variables> <Headers> <Header> <Name>Authorization</Name> <Value>Token token=$TOKEN$</Value> </Header> <Header> <Name>Accept</Name> <Value>application/vnd.pagerduty+json;version=2</Value> </Header> <Header> <Name>From</Name> <Value>$USER_EMAIL$</Value> </Header> </Headers> <!-- The body is used to send data to PagerDuty. By default the connector sends data either On Create, Update or Close. Fields that are sent when the ticket is created are found under the following header: <xsl:if test="$action = 'CREATE'"> * Details: This fills in the 'details' section of the ticket in PagerDuty. Fields that are sent when the ticket is created or updated are found under the following header: <xsl:if test="$action = 'CREATE' or $action = 'UPDATE'"> * Title: This is the title of the ticket in PagerDuty. * Urgency: This sets the urgency ('High' or 'Low') based on the incident's severity. Fields that are sent when the ticket is closed are found under the following header: <xsl:if test="$action = 'CLOSE'"> * Status: This is hard-coded to 'resolved' to close the ticket in PagerDuty. --> <Body> <object> <object name="incident"> <string name="type">incident</string> <object name="service"> <string name="id">$SERVICE_ID$</string> <string name="type">service_reference</string> </object> <xsl:if test="$action = 'CREATE'"> <object name="body"> <string name="type">incident_body</string> <string name="details">Incident created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary" /> Original Severity: <xsl:value-of select="emcf:SystemAttributes/emcf:SeverityCode" /> Original Priority: <xsl:value-of select="emcf:SystemAttributes/emcf:Priority" /> <xsl:choose> <xsl:when test="normalize-space(emcf:NotificationRuleName) != ''"> Incident trigged by the following rule: <xsl:value-of select="emcf:NotificationRuleName" /> </xsl:when> </xsl:choose> <xsl:choose> <xsl:when test="normalize-space(emcf:NotificationRuleOwner) != ''"> Rule is owned by: <xsl:value-of select="emcf:NotificationRuleOwner" /> </xsl:when> </xsl:choose> Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType" /> Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName" /> Original Owner: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:SourceObjInfo/emcf:ObjOwner" /> Additional Properties: <xsl:for-each select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetProperty"> * <xsl:value-of select="./emcf:Name" />: <xsl:value-of select="./emcf:Value" /> </xsl:for-each> This incident was created at: <xsl:value-of select="emcf:SystemAttributes/emcf:LastUpdatedDate" /> To manage the incident in Enterprise Manager, click here: <xsl:value-of select="emcf:SystemAttributes/emcf:IncidentURL" /> </string> </object> </xsl:if> <xsl:if test="$action = 'CREATE' or $action = 'UPDATE'"> <string name="title"> <xsl:value-of select="emcf:SystemAttributes/emcf:SeverityCode" />: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary" /> </string> <string name="urgency"> <xsl:value-of select="$severity" /> </string> </xsl:if> <xsl:if test="$action = 'CLOSE'"> <string name="status">resolved</string> </xsl:if> </object> </object> </Body> </Message> </xsl:template> </xsl:stylesheet>
チケット・テンプレートのカスタマイズ
あらかじめ用意されているチケット・テンプレートで要件を満たせない場合は、テンプレートを変更できます。 変更するには、既存のテンプレートのいずれかを基本テンプレートとして使用することをお薦めします。 そのチケット・テンプレートを新しいファイルにコピーし、変更を加えた後、新しいチケット・テンプレートとして登録してください。
テンプレートは、EM CLIコマンドを使用するかわりに、Enterprise Managerで直接編集することもできます。 詳細は、「テンプレートの編集」と「テンプレートのリストア」を参照してください。 詳細は、「テンプレートの編集」と「テンプレートのリストア」を参照してください。
ほとんどの場合、チケット・テンプレートを変更するときには、マッピングのみを変更します。 次の例では、このコンセプトについて説明しています。
例4-1 警告の重大度を緊急度Highにする場合
警告の重大度をPagerDutyの緊急度highに変更するテンプレートを作成するには、変数重大度の下でテンプレートに次の属性を追加します。
<xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'">high</xsl:when>
例4-2 タイトル名の変更
インシデント・サマリーが、PagerDutyチケットのメッセージと重大度の両方ではなくタイトルとしてのみ表示されるようにするには、次の属性を変更します。
<string name="title"> <xsl:value-of select="emcf:SystemAttributes/emcf:Summary" /> </string>
テンプレートは細かくカスタマイズできます。 複雑な変更は、XSLTに習熟したユーザーのみが行うことをお薦めします。
インシデントまたはイベント・ルールは、インシデントに適切なチケット・テンプレートを関連付けるためのフィルタとして使用できます。 チケット・テンプレートは、必要な数だけ使用できます。 1つのインシデントまたはイベント・ルールは、1つのチケット・テンプレートのみを持つことができます。
新規テンプレートの定義
あらかじめ用意されているテンプレートは、デフォルトのHPD:IncidentInterface_CreateフォームとHPD:IncidentInterfaceフォームに基づいています。 新たに定義するチケット・テンプレートがこれらのフォームに基づく場合、「チケット・テンプレートのカスタマイズ」の内容が適用されます。
ただし、別のフォームを使用する場合は、新たにチケット・テンプレートを定義する必要があります。
Enterprise Manager属性
次の表に、PagerDutyの使用時にマップできるEnterprise Managerのフィールドを示します。
表4-2 Enterprise Manager属性
データ・フィールド | 説明 |
---|---|
EMUser |
|
TicketID |
現在のインシデントに関連付けられているチケットを識別します(チケット作成後に使用可能)。 |
TargetType |
インシデントが関連付けられているターゲットのタイプ( |
TargetName |
インシデントが関連付けられているターゲットの名前。 例: |
TargetProperties |
TargetPropertiesには、ターゲットに固有の環境または使用コンテキストの情報が格納されます。 たとえば、ホスト・ターゲットの場合、TargetPropertiesの名前/値ペアは次のとおりです。
これらは、即時利用可能なユーザー定義のターゲット・プロパティです。 追加のターゲット・プロパティが追加されている場合は、チケット情報とともに表示されます。 |
サマリー |
インシデントの説明。 例: CPU使用率が100%で、警告(80)またはクリティカル(95)のしきい値を超えています。 |
Severity |
このインシデントの重大度: |
CollectionTime |
インシデント発生時のタイムスタンプ。 |
IncidentURL |
インシデントのインシデント詳細ページへのURL。 |
NotificationRuleName |
自動チケット発行中に通知を作成したインシデント・ルールの名前。 |
TargetTimezone |
インシデントに関連付けられているターゲットのタイムゾーン。 |
チケット・テンプレート作成用の書式
カスタムPagerDutyフォームのチケット・テンプレートを作成するには、次の書式に従います。
例4-3 カスタムPagerDutyフォームのテンプレート書式
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:emcf="http://xmlns.oracle.com/sysman/connector" version="1.0"> <xsl:template match="emcf:EMIncident"> * [Insert any variables needed here] <Message> <Method> <xsl:choose> <xsl:when test="$action = 'CREATE'">POST</xsl:when> <xsl:when test="$action = 'UPDATE'">PUT</xsl:when> <xsl:when test="$action = 'CLOSE'">PUT</xsl:when> <xsl:otherwise>ERROR</xsl:otherwise> </xsl:choose> </Method> <Variables> <Variable> <Name>TKT_ID</Name> <Value> <xsl:value-of select="normalize-space(emcf:TicketID)" /> </Value> </Variable> </Variables> <Headers> <Header> <Name>Authorization</Name> <Value>Token token=$TOKEN$</Value> </Header> <Header> <Name>Accept</Name> <Value>application/vnd.pagerduty+json;version=2</Value> </Header> <Header> <Name>From</Name> <Value>$USER_EMAIL$</Value> </Header> </Headers> <Body> * [Insert body changes (details you are sending to PagerDuty) here] </Body> </Message> </xsl:template> </xsl:stylesheet>