Jira Service Management の新しいナビゲーション

We’re in the process of rolling out these changes and the documentation may not match your experience. Bear with us while we update it to reflect the new changes. More about navigating the new Jira

アラートのカスタマイズとフィルタリングのための正規表現

 

Jira Service Management provides Java-like regular expressions to strengthen filtering and extracting information to define dynamic properties that you can use in integrations, alert policies, and callbacks. You can extract the desired information by using regular expressions in many cases - for example, defining a filtering rule with the Matches operator and extracting data to set for an alert field with the Extract string processing method.

「一致」ルールでフィルターするための正規表現

The conditions with Matches operator are met if whole string value matches the pattern of the given regular expression. If the type of the input value is List, then the condition is matched if at least one of the list items matches the given regular expression. With this operator, you can define complex filtering in a single condition rule and reduce your dependency on already-defined condition operators. Read more about condition operators.

[一致] 条件演算子の利用に適した一般的なユースケースの例は次のとおりです。

AND/OR で複数のルールを結合する

件名に "Daily Report (日次レポート)"、説明に Critical (クリティカル)、Error (エラー)、または Down (ダウン) が含まれている場合にメール統合でアラートを作成するには、[一致] ルール内で次の正規表現を使用できます。 .*(Critical|Error|Down).*

類似ルールの重複を防止する

アラートの説明が「server1, server2, ..., server100」のいずれかのサーバー名で始まる場合にアラートの再通知を行うには、20 個の [次で始まる] ルールを使用する代わりに、1 つの [一致] ルール内で次の正規表現を使用します。^(server(100|[1-9]\d?)).*

複雑なルールを定義する

アラート メッセージに有効なメール アドレスが含まれている場合に Webhook コールバックを実行するには、次の正規表現を使用します。 .*(\s+.*)?([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})(\s+.*)? 

Extract 文字列処理メソッドを使用してアラート フィールドを設定するための正規表現

You can use the extract string processing method to extract desired matching group according to a given regular expression to set into an alert field. Read more about string processing methods.

extract メソッドを使用して必要な結果を得るには、キャプチャ・グループの理解が必要な場合があります。これには次の 2 つの定義があります。

  • field_name.extract(reg_exp): 指定された正規表現の最初の括弧で囲まれたセクション (グループ) に一致する文字列の一部を指定します。文字列が指定された正規表現に一致しない場合は、空の文字列を返します。指定された正規表現が文字列と一致するが、括弧で囲まれたセクションを含まない場合は、文字列全体を返します。

  • field_name.extract(reg_exp, index): 指定された正規表現の index 番目の括弧で囲まれたセクション (グループ) に一致する文字列を指定します。文字列が指定された正規表現に一致しない場合は、空の文字列を返します。指定された正規表現が文字列と一致するが、index の数以上の括弧で囲まれたセクションを含まない場合は、文字列全体を返します。

Read more about capturing groups.

次に、両方のメソッド定義を使用する例をいくつか示します。

message: Host: First Second

message.extract(/Host: (\S+)/)

 = First

message.extract(/Host: (\S+) (\S+)/)

 = First

message.extract(/Host:(\S+)/)

 = 空の値

message.extract(/Host: (\S+)/, 0)

 = Host: First Second

message.extract(/Host: (\S+)/, 1)

 = First

message.extract(/Host: (\S+)/, 2)

 = Host: First

message.extract(/Host: (\S+) (\S+)/, 2)

 = Second

message.extract(/(\S)+/)

 = Host:

message.extract(/\S+/)

 = Host:

description: some value server3

description.extract(/(server(100|[1-9]\d?))/)

= server3

description.extract(/(server(100|[1-9]\d?))/, 1)

 = server3

description.extract(/(server(100|[1-9]\d?))/, 2)

 = 3

description.extract(/(server(100|[1-9]\d?))/, 3)

 = server3

description.extract(/server(100|[1-9]\d?)/, 0)

 = server3

description.extract(/server(100|[1-9]\d?)/, 1)

 = 3

description.extract(/server(100|[1-9]\d?)/, 2)

 = server3

description.extract(/(server(100|[1-9]\d?))/, 2)

 = 3

extract メソッドを使用して目的のアラート・フィールドを設定するには、次のいずれかのパターンでアラート・プロパティにテキストを書き込みます。

{{ field_name.extract(/reg_exp/) }}

{{ field_name.extract(/reg_exp/, group_number) }}

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。