# 合成トランザクション監視

## 背景 <a href="#synthetictransactionmonitoring-background" id="synthetictransactionmonitoring-background"></a>

[Wikipedia ](https://ja.wikipedia.org/wiki/Synthetic_monitoring)では、合成モニタリングを以下のように定義しています。

(…) シミュレーションやスクリプト化された取引記録を使用して行う監視技術です。 行動スクリプト（またはパス）を作成して、顧客やエンドユーザーがサイト、アプリケーション、またはその他のソフトウェア（またはハードウェア）上で行うアクションまたはパスをシミュレートします。 これらのパスは、機能性、可用性、応答時間の測定など、特定の間隔で継続的に監視されます。

合成トランザクションモニタリング（STM）は、スクリプトまたは「ロボット」を使用してアプリケーションを継続的に監視します。

STMは以下の場面で有効です：

* アプリケーションの可用性を監視し、誰もアプリケーションを使用していないときでも問題や停止が発生した場合にアラートを受け取る。
* パフォーマンスのベースラインを定義する。
* アプリケーション全体（メインドメイン）、特定のページまたはトランザクションを監視する。

## 概要 <a href="#synthetictransactionmonitoring-overview" id="synthetictransactionmonitoring-overview"></a>

### 問題 <a href="#synthetictransactionmonitoring-problem" id="synthetictransactionmonitoring-problem"></a>

ビジネスアプリケーションやその下にある技術スタックは、アプリケーション、ネットワーク、またはインフラストラクチャの変更により壊れることがあり、結果的な停止は、従業員がそれを使用しようとする時にのみ気づかれます。 これにより、インシデントが急増し、従業員の生産性の低下が急速に進む可能性があります。

### 解決策 <a href="#synthetictransactionmonitoring-solution" id="synthetictransactionmonitoring-solution"></a>

従業員が利用する前に、全技術およびアプリケーションスタックをテストするため、実際の従業員が行う（まだ行っていない）操作をエミュレートするスクリプトを定期的に実行できるようにします。

専用のアラートにより、従業員が影響を受ける前に重大な問題を識別・修正できるため、チケットが発生する前に真のプロアクティブな対応が可能になります。

### 主な特徴: <a href="#synthetictransactionmonitoring-keyfeatures" id="synthetictransactionmonitoring-keyfeatures"></a>

* アプリケーション全体、およびその下にある技術スタックのすべての要素に対する可用性とパフォーマンスのプロアクティブな監視とアラート
* 合成データと実データのユーザー体験を比較し、ビジュアルに分析・報告するダッシュボード

## 設定 <a href="#synthetictransactionmonitoring-configuration" id="synthetictransactionmonitoring-configuration"></a>

### エンドポイント <a href="#synthetictransactionmonitoring-theendpoints" id="synthetictransactionmonitoring-theendpoints"></a>

合成スクリプトを実行したいエンドポイントを選択する。

### 専用エンドポイント <a href="#synthetictransactionmonitoring-dedicatedendpoints" id="synthetictransactionmonitoring-dedicatedendpoints"></a>

これらは、合成スクリプトの実行専用にし、他のシステムユーザーに影響を及ぼさないようにします。 これにより、例えば、共有エンドポイント上で他のプロセスが実行されているため発生する遅延のスパイクなど、誤検知を回避することもできます。

### 代表性のある <a href="#synthetictransactionmonitoring-representative" id="synthetictransactionmonitoring-representative"></a>

測定したい内容に応じて選択します。 一般的には、社員が実際に使用するデバイス、例えば、OS、CPU、メモリなどの観点で代表的なものを使用するのが最適です。

### 地理< a href="#synthetictransactionmonitoring-geography" id="synthetictransactionmonitoring-geography">

測定したいことによって、その場所も変わります。 例えば、特定の場所にいるユーザーに遅延の苦情が多い場合、その場所に焦点を当てたいとします。 彼らが接続するデータセンターやゲートウェイが離れている場合、そこに配置されたデバイスを選択してください。

データを収集するには、エンドポイントにNexthink Collectorとブラウザ拡張機能をインストールする必要があります。

### スクリプト< a href="#synthetictransactionmonitoring-thescripts" id="synthetictransactionmonitoring-thescripts">

スクリプトは、ユースケースに応じて作成し、カスタマイズする必要があります。

**注意**:\
こちらのリモートアクションでは、入力パラメータに設定されたURLに基づいてMicrosoft Edgeを通じてURLを起動します。そして30秒後にMicrosoft Edgeは終了します。 社員の業務を妨げないように、このリモートアクションを展開するデバイスを慎重に検討してください。\_

## 考慮事項: <a href="#synthetictransactionmonitoring-considerations" id="synthetictransactionmonitoring-considerations"></a>

* これらのツールに精通している場合は、制御性と自動化機能を高めるためにSeleniumとChromiumを使用できます。 Chromiumの場合、ブラウザが起動するたびにNexthinkのブラウザ拡張機能をロードして有効化する必要があります。
* ユースケースに基づいて実行頻度を選択できます。
* アプリケーションにログインする必要がある場合は、特定のアカウントの二要素認証が無効になっていることを確認してください。 また、アプリケーションに正しく認証し、一度認証すると追加の認証が不要であることを確認できます。

## データの収集 <a href="#synthetictransactionmonitoring-collectingthedata" id="synthetictransactionmonitoring-collectingthedata"></a>

1. Nexthink Collectorと拡張機能をインストールしてください。
2. ページロードの観点とトランザクションの観点を考慮してください。

**注意:** スクリプトがページのロードをトリガーしないアクションを実行する場合、それをApplication Experienceでトランザクションとして設定してください。 結果をよりよく分析するために、主要ページを設定することをお勧めします。

## データの可視化 <a href="#synthetictransactionmonitoring-visualizingthedata" id="synthetictransactionmonitoring-visualizingthedata"></a>

解決したいユースケースに応じたライブダッシュボードを構築することをお勧めします。 リアルタイムアラートを行うために、実際のユーザーデータや他のユースケースと結果を比較してください。

左側と右側の列で同じNQLクエリを使用します。 合成スクリプトの場合、合成テストが実行されているエンドポイントでフィルタリングし、実際のユーザーデータの場合はこれらを除外します。

### 例1 <a href="#synthetictransactionmonitoring-example1" id="synthetictransactionmonitoring-example1"></a>

**メトリック:** ページロード時間

**NQLクエリ（合成）:**

{% code title="Code" lineNumbers="true" %}

```
web.page_views
| where http://application.name  == "ABC"
| where device.name == "synthetic"
| summarize pageLoadTime = page_load_time.overall.avg()
```

{% endcode %}

**NQLクエリ（正確なユーザーデータ）:**

{% code title="Code" lineNumbers="true" %}

```
web.page_views
| where http://application.name  == "ABC"
| where device.name != "synthetic"
| summarize pageLoadTime = page_load_time.overall.avg()
```

{% endcode %}

### 例2 <a href="#synthetictransactionmonitoring-example2" id="synthetictransactionmonitoring-example2"></a>

**メトリック:** ページロード数

**NQLクエリ（合成）:**

{% code title="Code" lineNumbers="true" %}

```
web.page_views
| where http://application.name  == "ABC"
| where device.name == "synthetic"
| summarize numberOfPageLoads = number_of_page_views.sum()
```

{% endcode %}

**NQLクエリ（正確なユーザーデータ）:**

{% code title="Code" lineNumbers="true" %}

```
web.page_views
| where http://application.name  == "ABC"
| where device.name != "synthetic"
| summarize numberOfPageLoads = number_of_page_views.sum()
```

{% endcode %}

### 例3 <a href="#synthetictransactionmonitoring-example3" id="synthetictransactionmonitoring-example3"></a>

**メトリック:** トランザクションごとのトランザクション持続時間の棒グラフ

**NQLクエリ（合成）:**

{% code title="Code" lineNumbers="true" %}

```
web.transactions
| where http://application.name  == "ABC"
| where device.name == "synthetic"
| where status == COMPLETED
| summarize transaction_time = duration.avg() by transaction.name
| sort transaction_time desc
```

{% endcode %}

**NQLクエリ（正確なユーザーデータ）:**

{% code title="Code" lineNumbers="true" %}

```
web.transactions
| where http://application.name  == "ABC"
| where device.name != "synthetic"
| where status == COMPLETED
| summarize transaction_time = duration.avg() by transaction.name
| sort transaction_time desc
```

{% endcode %}

## アラート <a href="#synthetictransactionmonitoring-alerting" id="synthetictransactionmonitoring-alerting"></a>

アラートは合成モニタリングにおいて最も重要なユースケースであることが多いです。

### 例1 <a href="#synthetictransactionmonitoring-example1.1" id="synthetictransactionmonitoring-example1.1"></a>

**目的:** 高エラー率のアラート

**頻度:** 15分

**NQLクエリ:**

{% code title="Code" lineNumbers="true" %}

```
application.applications
 | with web.page_views during past 1h
 | where http://application.name  == "ABC"
 | where device.name == "synthetic"
 | where is_soft_navigation == false
 | compute total_number_of_page_views = number_of_page_views.sum()

 | with web.errors during past 1h
 | compute error_n = error.number_of_errors.sum()
 | where total_number_of_page_views> 10
 | where error_n> 10
 | summarize total_errors = error_n.sum(), total_navigations =  total_number_of_page_views.sum(),
   percentage_error_ratio = error_n.sum() * 100 / total_number_of_page_views.sum() by
   http://application.name
```

{% endcode %}

### 例2 <a href="#synthetictransactionmonitoring-example2.1" id="synthetictransactionmonitoring-example2.1"></a>

**目的:** 遅いページロード時間のアラート

**頻度:** 15分

**NQLクエリ:**

{% code title="コード" lineNumbers="true" %}

```
application.applications
| with web.page_views during past 1h
| where http://application.name  == "ABC"
| where device.name == "synthetic"
| where experience_level == frustrating
| compute number_of_slow_pages_count = count()
| with web.page_views during past 1h
| compute number_of_pages_count = count()
| where number_of_pages_count > 10
| summarize number_of_slow_pages = number_of_slow_pages_count.sum(), number_of_pages = number_of_pages_count.sum(),ratio_of_slow_pages = number_of_slow_pages_count.sum() *100 / number_of_pages_count.sum() by http://application.name 
| where ratio_of_slow_pages > 1
```

{% endcode %}
