干擾素 (Interferon)

通知您關於基礎設施或應用程式的問題
227
作者Igor Serebryany

此儲存庫包含干擾素 gem。這個 gem 讓您能以程式碼的形式儲存您的警報設定。您應該建立自己的儲存庫,並使用一個匯入干擾素 gem 的 Gemfile。如需此類儲存庫的範例,以及範例設定和警報檔案,請參閱 https://www.github.com/airbnb/alerts_example

執行此 Gem

這個 gem 提供一個單一可執行檔,稱為 interferon

您應該像這樣調用它

$ bundle exec interferon --config /path/to/config_file

其他選項

  • -h, --help -- 列印使用資訊
  • -n, --dry-run -- 執行 interferon,但不對警報目的地進行任何變更

設定檔

設定檔以 YAML 格式撰寫。

它接受以下參數

  • verbose_logging -- 是否列印更多輸出
  • alerts_repo_path -- 您的警報儲存庫的位置,包含您的 interferon DSL 檔案
  • group_sources -- 一個可以回傳要警報的人員群組的來源列表
  • host_sources -- 一個可以讀取庫存系統並回傳要監控的主機列表的來源列表
  • destinations -- 一個警報提供者的列表,它可以監控指標並根據您的警報 dsl 檔案中指定的內容發送警報

如需更多資訊,請參閱此儲存庫中的 config.example.yaml 檔案。

運作部件

這個儲存庫知道四種物件

  • host_sources:這些會查詢各種庫存系統,並回傳要警報的主機或實體列表
  • destinations:這些是度量系統,可以監控指標並警報工程師
  • groups:這些是在發生問題時可以被警報的實際工程師群組
  • alerts:這些是 ruby DSL 檔案,用於指定何時以及如何透過目的地警報關於主機的工程師和群組

主機來源

  • optica:可以從 optica 讀取 AWS 執行個體列表
  • optica_services:回傳從 optica 解析的 smartstack 服務資訊
  • aws_rds:列出 RDS 執行個體
  • aws_dynamo:列出 dynamo-db 資料表
  • aws_elasticache:列出 elasticache 節點和叢集

目的地

Datadog

目前 Datadog 是我們唯一的警報目的地。Datadog 的警報語法規則在此: http://docs.datadoghq.com/api/#alerts 這是一張說明 datadog 指標語法的圖表 (透過 asciiflow 產生)

    +---------+ alert condition +-------------------------------------------------+
    |                                                                             |
    |              +-----+ metric to alert on                                     |
    |              |                                                              |
    |              |    tags to slice the metric by +------+                      |
    |              |                                       |                      |
    v              v                                       v                      v
  |----------| |-------------------------||--------------------------|          |---|
  max(last_5m):avg:haproxy_count_by_status{role:<%= role %>,status:up} by {host} > 0
  ^      ^      ^                                                          ^
  |      |      |                                                          |
  |      | +----|------------------------------+                           |
  |      | | math on the metric over all tags  |                           |
  |      | |-----------------------------------|            +------------------------------------+
  |      | | * max, min, avg, sum              |            |trigger a separate alert for each   |
  |      + +-----------------------------------+            |different value of these tags the   |
  | +----|----------------------------------------------+   |entire `by {}` clause can be ommited|
  | | the interval to look at; always starts with last_ |   +------------------------------------+
  | |---------------------------------------------------|
  | | * 5m, 10m, 15m, 30m                               |
  | | * 1h, 2h, 4h                                      |
  + +---------------------------------------------------+
 +-------------------------------------------------------------------------------------------------+
 | metric condition, can be one of:                                                                |
 |-------------------------------------------------------------------------------------------------|
 | * max: the metric gets this high at least once during the interval                              |
 | * avg: the metric is this on average during the interval                                        |
 | * min: the metric is this small at least once during the interval                               |
 | * change: the metric changes this much between a value N minutes ago and now (raw difference).  |
 | * pct_change: the metric changes this much between a value N minutes ago and now (percentage).  |
 +-------------------------------------------------------------------------------------------------+

群組

群組實際上來自 group_sources。我們目前只有一個群組來源,它可以從檔案系統讀取 YAML 檔案中的群組。但是,我們希望新增額外的群組來源,例如基於 LDAP 的來源。

連結