はじめに
AWS から Appflow というデータ連携の新しいサービスがリリースされましたね!
連携できるサービスの中に ServiceNow があったので、AWS & ServiceNow の有資格者としては早速試さないわけにはいかないので、簡単に実装してみました。
1.事前準備
ServiceNow にてアカウントを作る。
何も見ずに早速 Appflow を作ろうとすると、こんな画面が出てきました。
まぁ、当たり前ですが、然るべき権限(role)を持ったユーザを指定してほしい、という事です。早速 ServiceNow で作りましょう。
ServiceNow のインスタンスは、Orland の Developer instance を使用しています。
role は以下の2つと指定されたので、まずはそれでやってみましょう。
- web_service_admin
- rest_api_explorer

2. Appflow を作成する
2-1. Appflow の作成
じゃあ、準備完了したので早速作りましょうかね。
テーブルの指定が出てきました。まぁ当たり前ですね。っていうか、テーブルの参照権限(role)をappflow_user
に付与していないのに出てくる、という事は、このテーブルは現在は固定値なんですね。テーブルから明らかですが、現在サポートしているのは、以下の2つだという事がわかります。
- CMDB
- ITSM
そのまま進んでみると、権限がなくて取れないエラーが起きますね。
2-2. ServiceNow で再権限付与
Incident を対象にしてみましょう。なので、ITIL
をつける事にします。
よくよく考えてみると、フィールドって書いてあるので、テーブルのカラム名を取得に行っているんじゃないかと想定。
ServiceNow 上では、テーブルのカラムは sys_dictionary
というテーブルに保持しているため、そのアクセス権がないんじゃないかと想定されますね。早速 personalize_dictionary
を付与しましょう。
2-3. Appflow 作成の続き
3. 動作確認
早速、動かしてみましょう。右上の フローを実行
を押すと、実行され、完了すると以下の様になります。
{"business_stc":"28800","calendar_stc":"102197","caller_id":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/681ccaf9c0a8016400b98a06818d57c7","value":"681ccaf9c0a8016400b98a06818d57c7"},"category":"inquiry","caused_by":"","child_incidents":"0","close_code":"Solved (Permanently)","hold_reason":"","incident_state":"7","notify":"1","parent_incident":"","problem_id":"","reopened_by":"","reopened_time":"","reopen_count":"0","resolved_at":"2016-12-13 21:43:14","resolved_by":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/5137153cc611227c000bbd1bd8cd2007","value":"5137153cc611227c000bbd1bd8cd2007"},"rfc":"","severity":"3","subcategory":"email","sys_id":"1c741bd70b2322007518478d83673af3"}
{"business_stc":"1749949","calendar_stc":"7333549","caller_id":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/5137153cc611227c000bbd1bd8cd2006","value":"5137153cc611227c000bbd1bd8cd2006"},"category":"inquiry","caused_by":"","child_incidents":"","close_code":"Closed/Resolved by Caller","hold_reason":"","incident_state":"7","notify":"1","parent_incident":"","problem_id":"","reopened_by":"","reopened_time":"","reopen_count":"","resolved_at":"2019-09-05 19:56:12","resolved_by":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"rfc":"","severity":"3","subcategory":"","sys_id":"46b66a40a9fe198101f243dfbc79033d"}
{"business_stc":"1864990","calendar_stc":"7851790","caller_id":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/5137153cc611227c000bbd1bd8cd2005","value":"5137153cc611227c000bbd1bd8cd2005"},"category":"database","caused_by":"","child_incidents":"","close_code":"Closed/Resolved by Caller","hold_reason":"","incident_state":"7","notify":"1","parent_incident":"","problem_id":"","reopened_by":"","reopened_time":"","reopen_count":"","resolved_at":"2019-09-05 19:56:12","resolved_by":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"rfc":"","severity":"3","subcategory":"","sys_id":"46b9490da9fe1981003c938dab89bda3"}
{"business_stc":"1720500","calendar_stc":"7246500","caller_id":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/9ee1b13dc6112271007f9d0efdb69cd0","value":"9ee1b13dc6112271007f9d0efdb69cd0"},"category":"inquiry","caused_by":"","child_incidents":"","close_code":"Closed/Resolved by Caller","hold_reason":"","incident_state":"7","notify":"1","parent_incident":"","problem_id":"","reopened_by":"","reopened_time":"","reopen_count":"","resolved_at":"2019-09-05 19:56:12","resolved_by":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"rfc":"","severity":"3","subcategory":"","sys_id":"46c03489a9fe19810148cd5b8cbf501e"}
~~~略~~~
連携されていますね!
4. Appflow のオプション機能(少し脱線)
右上の方に、式を追加
と値を変更
というボタンがありますので、押してみました。
4-1. 式を追加
取得したカラム同士の数値演算や文字列連結が出来ます。
試しに一番下の連結
を押したらこうなります。
これは文字列として連結する事が出来るようです。
4-2. 値を変更
こちらは値をマスクしたり、文字列そのものではなく、文字数にしたりすることが可能です。
値をマスクする
テキスト値の切り捨て
5. 考察
さて、本題に戻ります。データが連携されたのはいいんですが…
例えば、ServiceNow のインシデントとしては割と重要な以下とかがないんですよね…
- short description
- description
- comments
- work_notes
データ分析目的のデータ連携だから、という話なのかもしれません。
また、Problem
などは取れてはいますが、SYS_ID で取れている状態なので、分析するにしても Lookup で実レコードの値を持ってきたいですよね。
『それは Redshift
でやる』というのもまぁ当然の意見としてはありますが、Flow Designer
+ Database view
の方が楽なのでは?という場合もあるでしょうから、やりたい事に対して、いくつか方式案を検討した方がよさそうですね。
まだ機能の出始めという事ですし、データ連携は結構煩わしい箇所なので、それをGUIベースで簡単に出来るようにしたのは良いと思います。今後に期待しています。