天天看點

grafana郵箱報警

安裝grafana:

sudo apt-get install -y adduser libfontconfig1

wget https://dl.grafana.com/oss/release/grafana_6.6.1_amd64.deb

sudo dpkg -i grafana_6.6.1_amd64.deb

配置Grafana告警郵箱:

cd /etc/grafana/

vi grafana.ini

/smtp找到smtp的配置

#################################### SMTP /Emailing ##########################

[smtp]

enabled = true

host = smtp.163.com:25

user = 你的郵箱@163.com

# If the password contains # or ; you have towrap it with trippel quotes. Ex """#password;"""

password = 你的郵箱密碼 //注意需要輸入的是你郵箱的授權密碼  如何開啟授權 請看下方

;cert_file =

;key_file =

skip_verify = true

from_address = 你的郵箱@163.com

from_name = Grafana Alert

# EHLO identity in SMTP dialog (defaults toinstance_name)

;ehlo_identity = dashboard.example.com

重新開機服務:

service  grafana-server restart

如何開啟郵箱授權:

解決:(網易)進入設定==》用戶端授權密碼==》點選開啟

grafana郵箱報警
grafana郵箱報警

開啟了就可以

注意注意:設定了授權碼之後就要去改代碼

代碼裡需要我們填寫的密碼是授權碼!!授權碼!!授權碼!!不是郵箱密碼

是以沒有改成授權碼的就會報一下的錯誤

550 User has no permission 密碼錯誤,應該是授權碼

Grafana使用及配置:

登入http://localhost:3000,預設使用者名admin,密碼admin。

grafana郵箱報警

進入後,首先選擇Data Sources,添加需要的資料源,如下圖所示。

grafana郵箱報警

然後進入dashboard頁面,建立儀表盤。我們可以通過通路https://grafana.com/dashboards來檢視已經由其他使用者共享的儀表盤,選取合适的使用,縮短上手時間。在這裡,作者選取的是https://grafana.com/dashboards/1443這個儀表盤,該儀表盤内已經基本涵蓋一個系統需要監控的相關參數。其telegraf相關配置如下:

[[inputs.net]]

#   ##By default, telegraf gathers stats from any up interface (excluding loopback)

#   ##Setting interfaces will tell it to gather these explicit interfaces,

#   ##regardless of status.

#   ##

interfaces = ["eth0,eth1,lo"]

[[inputs.cpu]]

  ##Whether to report per-cpu stats or not

 percpu = true

  ##Whether to report total system cpu stats or not

 totalcpu = true

  ## Iftrue, collect raw CPU time metrics.

 collect_cpu_time = false

# Read metrics about disk usage by mountpoint

[[inputs.disk]]

  ## Bydefault, telegraf gather stats for all mountpoints.

  ##Setting mountpoints will restrict the stats to the specified mountpoints.

  #mount_points = ["/"]

  ##Ignore some mountpoints by filesystem type. For example (dev)tmpfs (usually

  ##present on /run, /var/run, /dev/shm or /dev).

 ignore_fs = ["tmpfs", "devtmpfs"]

設定報警接受郵箱:

點選菜單進入Alerting 的 Notification channels 添加郵箱

grafana郵箱報警
grafana郵箱報警

點選send Test

若發送成功。會提示

grafana郵箱報警

目标郵箱會接受到

grafana郵箱報警

設定報警:

在Dashboards中選擇我們需要的資料源,點選edit

grafana郵箱報警
grafana郵箱報警

會報錯誤

Template variables are not supported in alert queries

是因為我們在查詢的時候使用了模闆變量,

grafana郵箱報警

解決方法為:建立一個不帶模闆變量的查詢

grafana郵箱報警
grafana郵箱報警

現在就不會報錯了

繼續閱讀