Try   HackMD

influxdb+Telegraf+grafana+docker 重點步驟

tags: grafana docker
​​​​docker run --net influxdb  -p=8086:8086  -d --restart=always --name influxdb influxdb:latest
​​​​-d 讓容器在後臺(windows service)執行

​docker run --net influxdb -h="telegraf"  -it -d --name=telegraf -v=D:/talagraf/conf:/etc/telegraf/ -e="INFLUX_TOKEN=NeyAu2XeG9hW01VFfX6tM4iA4HBRzsMhhHdNVGX92CiC47yaHlPMms4g4G5Dk5Fs6Thu6rypVLGhapuyZBCVTg==" telegraf:latest 

​docker run --net influxdb  -d --name=telegraf telegraf:latest telegraf --config http://influxdb:8086/api/v2/telegrafs/085712587b8c6000

1.可以使用c#做一個服務 來定時傳資料給influxdb

2.用Telegraf收集器 來定時傳資料給influxdb

所以如果要收集主機的記憶體cpu量之類的

可以用以上兩種方法

Telegraf有各種套件可以收集各種 軟體或是硬體的log 他主要是一份txt檔 設定好即可


influxdb 如果用mssql來比對的話 名稱會是哪些呢

bucket=>database

SELECT <field_key>[,<field_key>,<tag_key>] FROM <measurement_name>[,<measurement_name>]

Measurement=>Table

Field 是 欄位
tag 是 有索引的欄位

如果你這張Measurement (A) Field 會比較常被查詢 那就把(A) 改成 tag


基本上沒人再使用InfluxDB的gui 因為grafana強多了


建議使用InfluxDB.Client 套件


接著講到telegraf

這是來使用memory的模組


Grafana

​​​​docker run -d --name=grafana --net=influxdb --restart=always -p 3000:3000 grafana/grafana

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

連線配置重點

1.Custom HTTP Headers

​​​​Authorization

​​​​Token ghJlyrG0lzTPcrRxkBoaK2LWoWeWV93gyxl-CAoE2uVv71lY6CGORArJEa5T6BApvtaQX8Xy85cXpjBXVsN8QQ==

​​​​(influxdb的api token)

2.URL

要打INFLUXDB的容器名稱 不能打LOCALHOST 因為在GRAFANA的容器(宇宙)裡面 沒有LOCALHOST

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

完成畫面


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

這個紅框可以選擇直接使用TSQL語法來查詢