[InfluxDB] 使用 Telegraf + Prometheus 監控 InfluxDB 效能


Posted by zoelin2022 on 2022-07-24

InfluxDB 監控指標可透過 http://localhost:8086/metrics 即時查詢,但在 v2 版本並無提供 Telegraf 的 input plugin,因此官方建議透過 Prometheus input plugin 將資料送進 InfluxDB
https://docs.influxdata.com/influxdb/v2.3/reference/internals/metrics/

1.進入編輯telegraf.conf文件

sudo vim /etc/telegraf/telegraf.conf

將 [[inputs.prometheus]] 註解取消,urls 新增 influx
[[inputs.prometheus]]

   ## An array of urls to scrape metrics from.
   urls = ["http://localhost:8086/metrics"]

2.重啟 telegraf

 sudo systemctl restart telegraf

3.在 InfluxDB 中即可做查詢
_field欄位中有多種指標可以更換查詢

 from(bucket: "ipoc")
   |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
   |> filter(fn: (r) => r["_measurement"] == "prometheus")
   |> filter(fn: (r) => r["url"] == "http://localhost:8086/metrics")
   |> filter(fn: (r) => r["_field"] == "influxdb_buckets_total")
   |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
   |> yield(name: "mean")

4.最後可以進 grafana 製作 dashboard


#InfluxDB #Telegraf #Prometheus







Related Posts

Day01-網頁介面基本認識

Day01-網頁介面基本認識

Leetcode 刷題 pattern - Bitwise XOR

Leetcode 刷題 pattern - Bitwise XOR

資結、Data structure 1-- linked list

資結、Data structure 1-- linked list


Comments