IM-BPM for Accel Platform IM-BPM 仕様書 第8版 2018-04-01

4.12. Elasticsearch連携機能

Elasticsearchとの連携について説明します。

4.12.1. Elasticsearch連携について

Elasticsearchは、Elastic社が提供するオープンソース全文検索エンジンです。

Elasticsearchは、データをJSON形式で格納することができます。
Elasticsearch連携では、プロセスインスタンスに関する情報をElasticsearchに保存する為の機能です。
保存されたデータは、Elastic社が提供するKibanaを利用することにより可視化する事ができます。
Elasticsearch連携ではプロセスインスタンスに含まれる変数情報も含めて全てElasticsearchに保存するため
業務プロセスで利用されている任意のデータを可視化することができます。

4.12.2. Elasticsearch連携方式

Elasticsearchでは、TCP TransportとHTTPによる連携方式があります。
Elasticsearch連携は全てHTTPによるデータの登録を行います。

連携のタイミングは、プロセスの実行が完了する直前です。
Elasticsearchに対し、httpによるバルクリクエストを行います。
連携に失敗した場合、プロセスインスタンスの処理は継続します。

4.12.3. 登録されるデータ

登録されるデータ例:

{
  "_index": "im_bpm-default-20160725",
  "_type": "im_bpm",
  "_id": "AVYfNl7gDFByk9GXT5rc",
  "_score": null,
  "_source": {
    "source_activity_id": "servicetask1",
    "sequence_flow_id": "flow2",
    "type_activiti": "SEQUENCEFLOW_TAKEN",
    "target_activity_type": "endEvent",
    "source_activity_type": "serviceTask",
    "target_activity_id": "endevent1",
    "user_cd": "master",
    "process_definition_id": "service:1:8e28em7kuuyr2m7",
    "source_activity_name": "Service Task",
    "execution_id": "8e2ao18qwuztbm7",
    "process_instance_id": "8e2ao18qwuztbm7",
    "target_activity_behavior_class": "jp.co.intra_mart.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior",
    "source_activity_behavior_class": "jp.co.intra_mart.activiti.engine.impl.bpmn.helper.ClassDelegate",
    "target_activity_name": "End",
    "time": "2016-07-25T08:21:12+0900",
    "variables": {
      "foo": "FOO",
      "bar": "BAR"
    }
  },
  "fields": {
    "time": [
      1469402472000
    ]
  },
  "sort": [
    1469402472000
  ]
}

4.12.4. 連携イベント

Elasticsearchに登録されるプロセス内のイベントデータ配下の種類が存在します。
  • アクティビティの開始: activity_started
  • アクティビティの完了: activity_completed
  • アクティビティのキャンセル: activity_cancelled
  • アクティビティに対するシグナルの受信: activity_signaled
  • アクティビティに対するメッセージの受信: activity_messge_received
  • シーケンスフローによる遷移: sequenceflow_taken
  • ユーザタスクの作成: task_creted
  • ユーザタスクに対する担当者の割当: task_assigned
  • ユーザタスクの完了: taks_completed
  • プロセスインスタンスの開始: process_started
  • プロセスインスタンスの終了: process_completed
  • プロセスインスタンスのエラー終了: process_completed_with_error_end_event
  • プロセスインスタンスのキャンセル: process_cancelled
上記のイベントは設定ファイルによりそれぞれデータの登録の制御が可能です。
詳細は設定ファイルリファレンスを御覧ください。

以下のイベントは、プロセスインスタンスに含まれる変数情報も含めてElasticsearchに登録されます。
  • ユーザタスクの完了: taks_completed
  • プロセスインスタンスの終了: process_completed
  • プロセスインスタンスのエラー終了: process_completed_with_error_end_event

4.12.5. インデックスのパターン

Elasticsearchに対してデータを登録する際、index, typeの指定が行えます。
設定ファイルに含めるindex, typeはプレースホルダを埋め込む事により動的に変更することが可能です。

例: im_bpm-${yyyyMMdd}

利用可能な置換文字は以下の通りです。
  • yyyyMMdd: 年月日
  • yyyyMM: 年月
  • yyyy: 年
  • MM: 月
  • dd: 日
  • tenantId: テナントID

4.12.6. インデックステンプレート例

Elasticsearchは、事前にindex templateを登録する必要があります。

index template例:

{
  "template": "im_bpm-default-*",
  "mappings": {
    "im_bpm": {
      "properties": {
        "type_activiti": {
          "type": "string",
          "index": "not_analyzed"
        },
        "time": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "user_cd": {
          "type": "string",
          "index": "not_analyzed"
        },
        "user_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "process_definition_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "process_instance_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "execution_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "activity_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "activity_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "activity_type": {
          "type": "string",
          "index": "not_analyzed"
        },
        "behavior_class": {
          "type": "string",
          "index": "not_analyzed"
        },
        "activity_cause": {
          "type": "string",
          "index": "not_analyzed"
        },
        "error_code": {
          "type": "string",
          "index": "not_analyzed"
        },
        "message_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "message_data": {
          "type": "string",
          "index": "not_analyzed"
        },
        "signal_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "signal_data": {
          "type": "string",
          "index": "not_analyzed"
        },
        "activity_duration": {
          "type": "long"
        },
        "nested_process_definition_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "nested_process_instance_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "process_cause": {
          "type": "string",
          "index": "not_analyzed"
        },
        "process_duration": {
          "type": "long"
        },
        "sequence_flow_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "source_activity_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "source_activity_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "source_activity_type": {
          "type": "string",
          "index": "not_analyzed"
        },
        "source_activity_behavior_class": {
          "type": "string",
          "index": "not_analyzed"
        },
        "target_activity_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "target_activity_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "target_activity_type": {
          "type": "string",
          "index": "not_analyzed"
        },
        "target_activity_behavior_class": {
          "type": "string",
          "index": "not_analyzed"
        },
        "task_id": {
          "type": "string",
          "index": "not_analyzed"
        },
        "task_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "task_definition_key": {
          "type": "string",
          "index": "not_analyzed"
        },
        "description": {
          "type": "string",
          "index": "not_analyzed"
        },
        "assignee": {
          "type": "string",
          "index": "not_analyzed"
        },
        "owner": {
          "type": "string",
          "index": "not_analyzed"
        },
        "category": {
          "type": "string",
          "index": "not_analyzed"
        },
        "due_date": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "form_key": {
          "type": "string",
          "index": "not_analyzed"
        },
        "priority": {
          "type": "string",
          "index": "not_analyzed"
        },
        "task_duration": {
          "type": "long"
        }
      }
    }
  }
}

コラム

上記テンプレートに加えて、プロセスインスタンスで利用される変数 (variables) 配下のプロパティを個別に指定する必要があります。

4.12.7. HTTP Proxy

Elasticsearchに対してHTTP Proxyが必要となる場合には、Proxyの指定をシステムプロパティで行います。

例:
httpの場合
-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=9080
httpsの場合
-Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=9080

利用されているアプリケーションサーバに対して設定を行ってください。
Resinの場合には、{RESIN_HOME}/conf/resin.properties に含まれる jvm_args プロパティに追記します。