4 デフォルト・テンプレートの使用

この章では、Jiraコネクタに付属のデフォルト・チケット・テンプレートについて詳しく説明します。チケット・テンプレートは、Enterprise Managerのインシデントおよび基になるイベントの属性と、Jiraチケットの属性との間のマッピングを指定します。

テンプレート・プロセス

すべての即時利用可能なテンプレートは、インシデントのチケットを作成するときに、次のアクションを実行します。

  1. Description (Jiraチケットの説明)にインシデント情報を書き込みます。

  2. インシデント・メッセージに基づいてJiraチケット・タイトルを設定します。

あらかじめ用意されているテンプレートは次のとおりです。

  • jiraStoryCreateAndUpdate.xsl

    このテンプレートは、JiraでOracle Enterpriseインシデントをストーリ・チケットとして作成します。

  • jiraBugCreateAndUpdate.xsl

    このテンプレートは、JiraでOracle Enterpriseインシデントをバグ・チケットとして作成します。

  • jiraTaskCreateAndUpdate.xsl

    このテンプレートは、JiraでOracle Enterpriseインシデントをタスク・チケットとして作成します。

  • jiraSubtaskCreateAndUpdate.xsl

    このテンプレートは、JiraでOracle Enterpriseインシデントをサブタスク・チケットとして作成します。

  • jiraIncidentCreateAndUpdate.xsl

    このテンプレートは、JiraでOracle Enterpriseインシデントをインシデント・チケットとして作成します。

  • jiraProblemCreateAndUpdate.xsl

    このテンプレートは、JiraでOracle Enterpriseインシデントを問題チケットとして作成します。

  • jiraServiceRequestCreateAndUpdate.xsl

    このテンプレートは、JiraでOracle Enterpriseインシデントをサービス・リクエスト・チケットとして作成します。

チケット・テンプレートの読取り

次の表に、jiraStoryCreateAndUpdate.xslを使用したチケット作成の例を示します。この表は、チケット・テンプレートの内容の解釈に役立ちます。表内の*は、リテラル文字列を表し、**は属性が該当する場合を示します。また、この表は、チケット作成マッピングについて、Jiraチケット属性とそれに対応するEnterprise Managerのインシデント値も示しています。

チケット作成マッピングは、jiraStoryCreateAndUpdate.xsl jiraBugCreateAndUpdate.xsljiraTaskCreateAndUpdate.xslおよびjiraSubtaskCreateAndUpdate.xsl.で同じです。

表4-1 チケット作成マッピング(すべてのテンプレート)

Jiraチケット属性 Enterprise Managerインシデントの属性

問題のタイプ

.

10001 (これはストーリのタイプおよびテンプレート間の変更です)

プロジェクト/キー

$PROJECT_ID$

構成時にプロジェクト・キーの値に設定します。

ラベル

.

"oracle_enterprise_manager" *

説明

サマリー

重大度コード

優先度

通知ルール名

通知ルール所有者

ターゲット・タイプ

ターゲット名

オブジェクト所有者

ターゲット・プロパティ

最終更新日

インシデントURL

サマリー – 発行されたインシデントについての詳細

重大度コード - Oracle Enterprise Managerでのインシデントの重大度

優先度 - Oracle Enterprise Managerでのインシデントの優先度

通知ルール名 - チケットを作成したルールの名前(自動チケットのみ)

通知ルール所有者 - チケットを作成したルールを所有するユーザーの名前(自動チケットのみ)

ターゲット・タイプ - インシデントが発行されたターゲットのタイプ

ターゲット名 – インシデントが発行されたターゲットの名前

オブジェクト所有者 - インシデントが発行されたオブジェクトを所有するユーザーの名前

ターゲット・プロパティ - インシデントに関する追加の名前と値。ホスト、バージョン、OS、プラットフォームなど

最終更新日 - インシデントがOracle Enterprise Managerで作成された日付

インシデントURL - ユーザーをOracle Enterprise Managerインシデントに誘導するURLリンク

タイトル

サマリー

サマリー – 新たに発行したインシデントについての詳細*

このマッピング表を参照として使用し、XSLTファイル(jiraStoryCreateAndUpdate.xsl)を読み取ります。

<?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 are two variables set:
          * Action: Used to figure out if the connector is 'creating' or 'updating' the Jira Ticket.
          * Severity: Used to set the Severity of the Jira ticket (if used).
          * Priority: Used to set the Priority of the Jira 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:otherwise>UPDATE</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="severity">
      <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'">Sev-0</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'">Sev-0</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'">Sev-1</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'ADVISORY'">Sev-2</xsl:when>
        <xsl:otherwise>Sev-3</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="priority">
      <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:Priority = 'Urgent'">Highest</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:Priority = 'Very High'">Highest</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:Priority = 'High'">High</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:Priority = 'Medium'">Medium</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:Priority = 'Low'">Low</xsl:when>
        <xsl:otherwise>Medium</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 Jira.
        -->
      <Method>
        <xsl:choose>
          <xsl:when test="$action = 'CREATE'">POST</xsl:when>
          <xsl:when test="$action = 'UPDATE'">POST</xsl:when>
          <xsl:otherwise>ERROR</xsl:otherwise>
        </xsl:choose>
      </Method>
      <Variables>
        <Variable>
          <Name>TKT_KEY</Name>
          <Value>
            <xsl:value-of select="normalize-space(emcf:TicketID)" />
          </Value>
        </Variable>
      </Variables>
      <Headers>
        <Header>
          <Name>Authorization</Name>
          <Value>Basic $TOKEN$</Value>
        </Header>
        <Header>
          <Name>Accept</Name>
          <Value>*/*</Value>
        </Header>
      </Headers>
      <!--
        The body is used to send data to Jira. By default, the connector sends data either 'On Create' or 'On Update'.
        
        Fields that are sent when the ticket is created are found under the following header: <xsl:if test="$action = 'CREATE'">
          * Summary: This is the title of Jira ticket
          * Issue Type: This is the type of the Jira ticket. By default, it is set to 'Story'
          * Project: This is the project the Jira tickets will be created under. This is taken from the configuration settings.
          * Labels: This is an array of any labels you wanted added to the ticket.    
          * Description: This is the description of the Jira ticket.
          * Priority: This is the priority of the Jira ticket based on the priority of the Oracle Enterprise Manager ticket.

        Fields that are sent when the ticket is updated are found under the following header: <xsl:if test="$action = 'UPDATE'">
        Note: These items will be sent as a 'comment' in Jira
          * Body: This is the description of current values when an incident is updated in Oracle Enterprise Manager

        There are also a number of fields that are not enabled in Jira by default. They are included but commented out.
        To see if you have these fields enabled, go to your Jira project > 'Project Settings' > 'Issue Types' > 'Story'
        If your Jira instance uses these fields, feel free to uncomment them and your tickets will be created with them as well.
        Note: If you uncomment a field that your Jira project is not using, it will fail to create the ticket.
        
        Additionally, there are a number of fields that Jira has provided or that you have created called 'custom fields'.
        To find your custom fields navigate to 'Administration (gear icon)' > 'Issues' > 'Custom Fields'.
        To find the ID of your custom field, click on the '...' and select 'Edit Details' or 'View field information'.
        Once you are on this page, the ID will be in the URL.
          Examples:
            * customFieldId=10000
            * id=10004
        Once you have your ID, you can add a custom field with the name customfield_<ID>.

        Here are a few examples with some different types of custom fields:
          Let's say we wanted to add the 'requested participants' field in Jira and found it's ID was '30032'
          Requested participants is an array of users. To add it to the fields, we would add the following:
          <array name="customfield_30032">
            [
              <object>
                <string name='id'>"USER ID 1"</string>,
              </object>
              <object>
                <string name='id'>"USER ID 2"</string>
              <object>
            ]
          </array>
        
          Let's say we wanted to add the 'severity' field in Jira and found it's ID was '30043'
          Severity is an object with a value. To add it to the fields, we would add the following:
          <object name="customfield_30043">
            <string name="value">"SEV-0"</string>
          </object>

          If you don't want all your issues to be SEV-0 in Jira, use the $severity variable above to dynamically set severity:
          <object name="customfield_30043">
            <string name="value">
              <xsl:value-of select="$severity"/>
            </string>
          </object>

          Finally, let's say you wanted to add a component to Jira based on Target Type in Oracle Enterprise Manager. This would require a few steps.
          First, we need to set a component variable. This variable will be located above with the other variables (action, severity and priority).
          Here is an example of what that variable would look like:
          <xsl:variable name="component">
            <xsl:choose>
              <xsl:when test="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType = 'host'">Host</xsl:when>
              <xsl:when test="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType = 'agent'">Agent</xsl:when>
              <xsl:otherwise>Default</xsl:otherwise>
            </xsl:choose>
          </xsl:variable>

          In this example you can see that we look if the target type is a 'host' or 'agent' and returns the component name based on that ('Host' or 'Agent').
          If it does not find either target type, it returns a default value of 'Default'.
          If you would like to add more target types, simply copy one of the 'when' statements and change the target type and return value.

          Now, that the variable is set, we must verify that our return values are valid components in Jira.
          To do that, go to your Jira Project > 'Project Settings' > 'Components'
          If the component does not exist, click 'Create component' and create it. In this example, we created 'Host', 'Agent', and 'Default'.

          Finally, in the body below, we need to add component. It needs to be added under the line: <object name="fields">
          Here is a good example of what that should look like:
          <array name="components">
            [
            <object>
              <string name="name"><xsl:value-of select="$component"/></string>
            </object>
            ]
          </array>
        -->
      <Body>
        <object>
          <xsl:if test="$action = 'CREATE'">
            <object name="fields">
              <object name="issuetype">
                <string name="name">Story</string>
              </object>
              <!-- This is the title of the Jira ticket. -->
              <string name="summary">
                <xsl:value-of select="emcf:SystemAttributes/emcf:Summary" />
              </string>
              <!-- This is the Project that the ticket is created under in Jira. This is taken from the configuration settings. -->
              <object name="project">
                <string name="key">$PROJECT_ID$</string>
              </object>
              <!-- This is an array of labels applied to the ticket in Jira. By default, we added the label 'oracle_enterprise_manager' -->
              <array name="labels">
                [
                <string>oracle_enterprise_manager</string>
                ]
              </array>
              <!-- This is the main description of the ticket in Jira. -->
              <object name="description">
                <string name="type">doc</string>
                <number name="version">1</number>
                <array name="content">
                  [
                  <object>
                    <string name="type">paragraph</string>
                    <array name="content">
                      [
                      <object>
                        <string name="text">Incident created in Oracle 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 Oracle Enterprise Manager, </string>
                        <string name="type">text</string>
                      </object>
                      <object>
                        <string name="text">click here.</string>
                        <string name="type">text</string>
                        <array name="marks">
                          [
                          <object>
                            <string name="type">link</string>
                            <object name="attrs">
                              <string name="href">
                                <xsl:value-of select="emcf:SystemAttributes/emcf:IncidentURL" />
                              </string>
                            </object>
                          </object>
                          ]
                        </array>
                      </object>
                      ]
                    </array>
                  </object>
                  ]
                </array>
              </object>
              <!-- Sets Priority in your Jira Issue. -->
              <object name="priority">
                <string name="name">
                  <xsl:value-of select="$priority" />
                </string>
              </object>
              <!-- This will put the Jira Issue into a component (or subsection). Replace 'COMPONENT NAME-X' with the component names you wish the Issue to be a part of. -->
              <!--
                <array name="components">
                  [
                  <object>
                    <string name="name">COMPONENT NAME-1</string>
                  </object>
                  <object>
                    <string name="name">COMPONENT NAME-2</string>
                  </object>
                  ]
                </array>
              -->
              <!-- This will set the reporter of the Jira Issue. Replace 'REPORTER ID' with the User's ID. -->
              <!--
                <object name="reporter">
                  <string name="id">REPORTER ID</string>
                </object>
              -->
              <!-- This will set the version of the release this Issue should be completed in. Replace 'FIXVERSION NAME-X' and implement the versions this should be worked on. -->
              <!--
                <array name="fixVersions">
                  [
                  <object>
                    <string name="name">FIXVERSION NAME-1</string>
                  </object>
                  <object>
                    <string name="name">FIXVERSION NAME-2</string>
                  </object>
                  ]
                </array>
              -->
              <!-- This will set the remaining time and the original estimated time for the Jira Issue. Replace '100' with the number of minutes for each estimate. -->
              <!--
                <object name="timetracking">
                  <string name="remainingEstimate">100</string>
                  <string name="originalEstimate">100</string>
                </object>
              -->
              <!-- This will set environment details in the Jira Issue. By default, it will link to the Target URL inside Oracle Enterprise Manager. To add more details, implement them under 'text'. -->
              <!--
                <object name="environment">
                  <string name="type">doc</string>
                  <number name="version">1</number>
                  <array name="content">
                    [
                    <object>
                      <string name="type">paragraph</string>
                      <array name="content">
                        [
                        <object>
                          <string name="text">To visit the target in Oracle Enterprise Manager, </string>
                          <string name="type">text</string>
                        </object>
                        <object>
                          <string name="text">click here.</string>
                          <string name="type">text</string>
                          <array name="marks">
                            [
                            <object>
                              <string name="type">link</string>
                              <object name="attrs">
                                <string name="href"><xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/></string>
                              </object>
                            </object>
                            ]
                          </array>
                        </object>
                        ]
                      </array>
                    </object>
                    ]
                  </array>
                </object>
              -->
              <!-- This will set the affected version the Jira Issue was found on. Replace 'VERSION NAME-X' with the version name. -->
              <!--
                <array name="versions">
                  [
                  <object>
                    <string name="name">VERSION NAME-1</string>
                  </object>
                  <object>
                    <string name="name">VERSION NAME-2</string>
                  </object>
                  ]
                </array>
              -->
              <!-- This will set the date the Jira issue is due by. Replace YYYY-MM-DD with the Year, Month and Day. -->
              <!--
                <string name="duedate">YYYY-MM-DD</string>
              -->
              <!-- This will assign the Jira Issue to a user. Replace 'ASSIGNEE ID' with the User's ID. -->
              <!--
                <object name="assignee">
                  <string name="id">ASSIGNEE ID</string>
                </object>
              -->
            </object>
          </xsl:if>
          <xsl:if test="$action = 'UPDATE'">
            <object name="body">
              <string name="type">doc</string>
              <number name="version">1</number>
              <array name="content">
                [
                <object>
                  <string name="type">paragraph</string>
                  <array name="content">
                    [
                    <object>
                      <string name="text">The incident was updated in Oracle Enterprise Manager.
<xsl:value-of select="emcf:SystemAttributes/emcf:Summary" />

Severity is currently: <xsl:value-of select="emcf:SystemAttributes/emcf:SeverityCode" />
Priority is currently: <xsl:value-of select="emcf:SystemAttributes/emcf:Priority" />
Owner is currently: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:SourceObjInfo/emcf:ObjOwner" />
This incident was updated at: <xsl:value-of select="emcf:SystemAttributes/emcf:LastUpdatedDate" />
                      </string>
                      <string name="type">text</string>
                    </object>
                    ]
                  </array>
                </object>
                ]
              </array>
            </object>
          </xsl:if>
        </object>
      </Body>
    </Message>
  </xsl:template>
</xsl:stylesheet>

チケット・テンプレートのカスタマイズ

あらかじめ用意されているチケット・テンプレートで要件を満たせない場合は、テンプレートを変更できます。変更するには、既存のテンプレートのいずれかを基本テンプレートとして使用することをお薦めします。そのチケット・テンプレートを新しいファイルにコピーし、変更を加えた後、新しいチケット・テンプレートとして登録してください。

テンプレートは、EM CLIコマンドを使用するかわりに、Enterprise Managerで直接編集することもできます。詳細は、「テンプレートの編集」と「テンプレートのリストア」を参照してください。詳細は、「テンプレートの編集」「テンプレートのリストア」を参照してください。

ほとんどの場合、チケット・テンプレートを変更するときには、マッピングのみを変更します。次の例では、このコンセプトについて説明しています。

例4-1 Jiraチケットへの期日の追加

Jiraで期日を持つテンプレートを作成するには、テンプレートで次のコードを見つけてコメント・ブラケット(<!- - および- ->)を削除し、日付を設定します。

<!-- 
     <string name="duedate">2023-02-17</string>
--> 

例4-2 テンプレートへのカスタム・フィールドの追加

Jiraでは、独自のカスタム・フィールドを作成できます。独自のカスタム・フィールドを追加するには、JiraでIDを検索し、テンプレートに追加します。カスタム・フィールドを検索するには、「管理」(歯車アイコン)メニューから、「問題」「カスタム・フィールド」の順に選択します。カスタム・フィールドのIDを検索するには、省略記号(...)をクリックし、「詳細の編集」またはフィールド情報の表示を選択します。このページを表示すると、IDがURLに含まれます。IDを取得したら、customfield_<ID>という名前のカスタム・フィールドを追加できます。カスタム文字列フィールドの例を次に示します。

<string name="customfield_20000">"My custom field value"</string>

テンプレートは細かくカスタマイズできます。複雑な変更は、XSLTに習熟したユーザーのみが行うことをお薦めします。

インシデントまたはイベント・ルールは、インシデントに適切なチケット・テンプレートを関連付けるためのフィルタとして使用できます。チケット・テンプレートは、必要な数だけ使用できます。1つのインシデントまたはイベント・ルールは、1つのチケット・テンプレートのみを持つことができます。

新規テンプレートの定義

すぐに使用できるテンプレートは、デフォルトのフォームに基づきます。新たに定義するチケット・テンプレートがこれらのフォームに基づく場合、「チケット・テンプレートのカスタマイズ」の内容が適用されます。

ただし、別のフォームを使用する場合は、新たにチケット・テンプレートを定義する必要があります。

Enterprise Manager属性

次の表に、Jiraの使用時にマップできるEnterprise Managerのフィールドを示します。

表4-2 Enterprise Manager属性

データ・フィールド 説明

EMUser

  • 自動チケット発行の場合、これはインシデント・ルール所有者です。

  • チケットを手動発行した場合は、チケット作成をトリガーしたコンソール・ユーザーです。

TicketID

現在のインシデントに関連付けられているチケットを識別します(チケット作成後に使用可能)。

TargetType

インシデントが関連付けられているターゲットのタイプ(hostなど)。

TargetName

インシデントが関連付けられているターゲットの名前。例: Database1またはyourhost.example.com

TargetProperties

TargetPropertiesには、ターゲットに固有の環境または使用コンテキストの情報が格納されます。たとえば、ホスト・ターゲットの場合、TargetPropertiesの名前/値ペアは次のとおりです。

  • コメント — 管理サービスとリポジトリを実行しているホスト。

  • 連絡先 — John Doe

  • デプロイメント・タイプ — 本番

  • 事業部門 — 開発

  • 場所 — Redwood Shores

これらは、即時利用可能なユーザー定義のターゲット・プロパティです。追加のターゲット・プロパティが追加されている場合は、チケット情報とともに表示されます。

サマリー

インシデントの説明。たとえば: CPU使用率が100%で、警告(80)またはクリティカル(95)のしきい値を超えています。

優先度 lowからurgentへのインシデントの優先度。

Severity

このインシデントの重大度: critical、warning、clearまたはdown

CollectionTime

インシデント発生時のタイムスタンプ。

IncidentURL

インシデントのインシデント詳細ページへのURL。

NotificationRuleName

自動チケット発行中に通知を作成したインシデント・ルールの名前。

TargetTimezone

インシデントに関連付けられているターゲットのタイムゾーン。

チケット・テンプレート作成用の書式

カスタムJiraフォームのチケット・テンプレートを作成するには、次の書式に従います。

例4-3 カスタムJiraフォームのテンプレート書式

<?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'">POST</xsl:when>
          <xsl:otherwise>ERROR</xsl:otherwise>
        </xsl:choose>
      </Method>
      <Variables>
        <Variable>
          <Name>TKT_KEY</Name>
          <Value>
            <xsl:value-of select="normalize-space(emcf:TicketID)" />
          </Value>
        </Variable>
      </Variables>
      <Headers>
        <Header>
          <Name>Authorization</Name>
          <Value>Basic $TOKEN$</Value>
        </Header>
        <Header>
          <Name>Accept</Name>
          <Value>*/*</Value>
        </Header>
      </Headers>
      <Body>
* [Insert body changes (details you are sending to Jira) here]
      </Body>
    </Message>
  </xsl:template>
</xsl:stylesheet>