Telegraf 與 Timestream for InfluxDB 3 整合 - Amazon Timestream

如需類似 Amazon Timestream for LiveAnalytics 的功能,請考慮使用 Amazon Timestream for InfluxDB。它提供簡化的資料擷取和單一位數毫秒查詢回應時間,以進行即時分析。在這裡進一步了解。

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

Telegraf 與 Timestream for InfluxDB 3 整合

Telegraf 是以外掛程式為基礎的資料收集代理程式,具有超過 300 個輸入外掛程式,用於從各種來源和輸出外掛程式收集指標,以將資料寫入不同的目的地。其「隨plug-and-play」架構非常適合快速收集指標並將其報告至 InfluxDB 3。

要求

  • Telegraf 1.9.2 或更新版本 – 如需安裝說明,請參閱Telegraf 安裝文件。

  • InfluxDB 3 叢集端點和登入資料。

  • 與 InfluxDB 3 叢集的網路連線。

Telegraf 組態選項

Telegraf 提供兩個與 InfluxDB 3 相容的輸出外掛程式:

  1. outputs.influxdb_v2- 建議用於新部署。

  2. outputs.influxdb(v1) - 適用於現有的 v1 組態。

我們建議您使用outputs.influxdb_v2plugin 連線到 InfluxDB v2 相容性 API:

[[outputs.influxdb_v2]] urls = ["https://your-cluster-endpoint:8086"] token = "${INFLUX_TOKEN}" # Use environment variable for security organization = "" # Can be left empty for InfluxDB 3 bucket = "DATABASE_NAME" ## Optional: Enable gzip compression content_encoding = "gzip" ## Optional: Increase timeout for high-latency networks timeout = "10s" ## Optional: Configure batching metric_batch_size = 5000 metric_buffer_limit = 50000

使用舊版 v1 輸出外掛程式

對於使用 v1 外掛程式的現有 Telegraf 組態:

[[outputs.influxdb]] urls = ["https://your-cluster-endpoint:8086"] database = "DATABASE_NAME" skip_database_creation = true username = "ignored" # Required but ignored password = "${INFLUX_TOKEN}" # Use environment variable content_encoding = "gzip" ## Optional: Configure write parameters timeout = "10s" metric_batch_size = 5000 metric_buffer_limit = 50000

基本 Telegraf 組態範例

以下是收集系統指標並將其寫入 InfluxDB 3 的完整範例:

# Global Agent Configuration [agent] interval = "10s" round_interval = true metric_batch_size = 5000 metric_buffer_limit = 50000 collection_jitter = "0s" flush_interval = "10s" flush_jitter = "0s" precision = "s" hostname = "" omit_hostname = false # Input Plugins - Collect system metrics [[inputs.cpu]] percpu = true totalcpu = true collect_cpu_time = false report_active = false [[inputs.disk]] ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] [[inputs.mem]] [[inputs.net]] interfaces = ["eth*", "en*"] [[inputs.system]] # Output Plugin - Write to InfluxDB 3 [[outputs.influxdb_v2]] urls = ["https://your-cluster-endpoint:8086"] token = "${INFLUX_TOKEN}" organization = "" bucket = "telegraf_metrics" content_encoding = "gzip"

Telegraf with InfluxDB 3 的最佳實務

  • 安全性

    • 將權杖儲存在環境變數或秘密存放區中。

    • 切勿在組態檔案中硬式編碼字符。

    • 使用 HTTPS 端點進行生產部署。

  • 效能最佳化

    • 使用 content_encoding = "gzip" 啟用 gzip 壓縮。

    • 設定適當的批次大小 (5000-10000 指標)。

    • 根據可用的記憶體設定緩衝區限制。

    • 使用適合您使用案例的精確度 (秒通常足夠)。

  • 網路組態

    • 對於私有叢集,在相同的 VPC 中執行 Telegraf。

    • 為您的網路延遲設定適當的逾時。

    • 使用寫入器/讀取器端點進行寫入操作。

  • 監控

    • 啟用 Telegraf 的內部指標外掛程式來監控客服人員效能。

    • 監控寫入錯誤和重試。

    • 設定緩衝區溢位條件的提醒。

  • 資料組織

    • 在輸入外掛程式之間使用一致的標籤命名。

    • 利用 Telegraf 的處理器外掛程式來標準化資料。

    • 套用標籤篩選以控制基數。

執行 Telegraf

若要使用組態啟動 Telegraf,請執行下列動作:

# Test configuration telegraf --config telegraf.conf --test # Run Telegraf telegraf --config telegraf.conf # Run as a service (systemd) sudo systemctl start telegraf

時間序列資料的常見 Telegraf 外掛程式

熱門輸入外掛程式:

  • inputs.cpuinputs.meminputs.disk- 系統指標。

  • inputs.dockerinputs.kubernetes- 容器指標。

  • inputs.prometheus- 擴展 Prometheus 端點。

  • inputs.snmp- 網路裝置監控。

  • inputs.mqtt_consumer- IoT 資料收集。

  • inputs.http_listener_v2- HTTP Webhook 接收器。

實用的處理器外掛程式:

  • processors.regex- 轉換標籤/欄位名稱。

  • processors.converter- 變更欄位資料類型。

  • processors.aggregator- 彙總指標。

  • processors.filter- 根據條件篩選指標。

透過利用 Telegraf 廣泛的外掛程式生態系統搭配 InfluxDB 3,您可以建置全方位的監控解決方案,從各種來源收集資料,並有效率地將其寫入您的時間序列資料庫。