

如需與 Amazon Timestream for LiveAnalytics 類似的功能，請考慮使用 Amazon Timestream for InfluxDB。它提供簡化的資料擷取和單一位數毫秒查詢回應時間，以進行即時分析。[在這裡](https://docs.aws.amazon.com//timestream/latest/developerguide/timestream-for-influxdb.html)進一步了解。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 將 Telegraf/InfluxDB 指標映射至 Timestream for LiveAnalytics 模型
<a name="Telegraf.how-it-works"></a>

 從 Telegraf 將資料寫入 Timestream for LiveAnalytics 時，資料會對應如下。
+ 時間戳記會寫入為時間欄位。
+ 標籤會寫入為維度。
+ 欄位會寫入為量值。
+ 測量大部分會寫入資料表名稱 （以下將詳細說明）。

適用於 Telegraf 的 Timestream for LiveAnalytics 輸出外掛程式提供多種選項，可在 Timestream for LiveAnalytics 中組織和儲存資料。這可以用範例描述，該範例以行通訊協定格式的資料開頭。

`weather,location=us-midwest,season=summer temperature=82,humidity=71 1465839830100400200 airquality,location=us-west no2=5,pm25=16 1465839830100400200`

以下說明資料。
+ 測量名稱為 `weather`和 `airquality`。
+ 標籤為 `location`和 `season`。
+ 欄位為 `temperature`、`no2`、 `humidity`和 `pm25`。

**Topics**
+ [將資料存放在多個資料表中](#Telegraf.how-it-works.multi-table-single-measure.title)
+ [將資料存放在單一資料表中](#Telegraf.how-it-works.single-table-single-measure.title)

## 將資料存放在多個資料表中
<a name="Telegraf.how-it-works.multi-table-single-measure.title"></a>

您可以選擇為每個測量建立單獨的資料表，並將每個欄位存放在每個資料表的個別資料列中。

組態為 `mapping_mode = "multi-table"`。
+ Timestream for LiveAnalytics 轉接器會建立兩個資料表，即 `weather`和 `airquality`。
+ 每個資料表列只會包含單一欄位。

產生的 LiveAnalytics 的 Timestream 資料表 `weather`和 `airquality`會如下所示。


**`weather`**  

| time | location | 季節 | measure\_name | measure\_value::bigint | 
| --- | --- | --- | --- | --- | 
|  2016-06-13 17：43：50  |  us-midwest  |  暑假  |  溫度  |  82  | 
|  2016-06-13 17：43：50  |  us-midwest  |  暑假  |  濕度  |  71  | 


**`airquality`**  

| time | location | measure\_name | measure\_value::bigint | 
| --- | --- | --- | --- | 
|  2016-06-13 17：43：50  |  us-midwest  |  no2   |  5  | 
|  2016-06-13 17：43：50  |  us-midwest  |  pm25   |  16  | 

## 將資料存放在單一資料表中
<a name="Telegraf.how-it-works.single-table-single-measure.title"></a>

您可以選擇將所有測量結果存放在單一資料表中，並將每個欄位存放在個別的資料表列中。

組態為 `mapping_mode = "single-table"`。使用 `single-table`、 `single_table_name`和 時有兩個額外的組態`single_table_dimension_name_for_telegraf_measurement_name`。
+ Timestream for LiveAnalytics 輸出外掛程式會建立名為 {{<single\_table\_name>}} 的單一資料表，其中包含 {{<single\_table\_dimension\_name\_for\_telegraf\_measurement\_name>}} 欄。
+ 資料表可以在單一資料表列中包含多個欄位。

產生的 LiveAnalytics Timestream 資料表如下所示。


**`weather`**  

| time | location | 季節 | {{<single\_table\_dimension\_name\_ for\_telegraf\_measurement\_name>}} | measure\_name | measure\_value::bigint | 
| --- | --- | --- | --- | --- | --- | 
|  2016-06-13 17：43：50  |  us-midwest  |  暑假  |  天氣  |  溫度  |  82  | 
|  2016-06-13 17：43：50  |  us-midwest  |  暑假  |  天氣  |  濕度  |  71  | 
|  2016-06-13 17：43：50  |  us-midwest  |  暑假  |  空氣品質  |  no2  |  5  | 
|  2016-06-13 17：43：50  |  us-midwest  |  暑假  |  天氣  |  pm25  |  16  | 