Attrations of the volume dir privileges in higher version prometheus. because the base image that use to build prom/prometheus images is changed.
see details from dockerfile in hub.docker.com. as below.node
FROM quay.io/prometheus/busybox:latest MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com> COPY prometheus /bin/prometheus COPY promtool /bin/promtool COPY documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml COPY console_libraries/ /etc/prometheus/ COPY consoles/ /etc/prometheus/ EXPOSE 9090 VOLUME [ "/prometheus" ] WORKDIR /prometheus ENTRYPOINT [ "/bin/prometheus" ] CMD [ "-config.file=/etc/prometheus/prometheus.yml", \ "-storage.local.path=/prometheus", \ "-web.console.libraries=/etc/prometheus/console_libraries", \ "-web.console.templates=/etc/prometheus/consoles" ]
run prometheus v2.4 in docker container.mysql
configure_file=/apps/prometheus/conf prometheus_data=/data/prometheus chown -R nobody:nogroup /data/prometheus chown -R nonody:nogroup /apps/prometheus/conf docker run -d --name prometheus --restart=always -v $(configure_file):/etc/prometheus/ -v $(prometheus_data):/prometheus -p 9090:9090 prom/prometheus:latest --config.file=/etc/prometheus/prometheus.yml
docker run -d --name alertmanager --restart=always -p 10.1.100.231:9093:9093 -v /apps/alertmanager:/etc/alertmanager -v /data/alertmanager:/alertmanager prom/alertmanager:latest --config.file=/etc/alertmanager/config.yml
???git
/-/reload
endpointstatic_configs
or dynamically discovered
?All regular expressions in prometheus use RE2 syntaxgithub
使用prometheus告警時,prometheus會把警告規則發送給AlertManager,而後再由AlertManager管理這些警告,Alertmanager發送通知的方式一般有如下幾種:web
Alertmanager經過命令行參數和配置文件進行配置,命令行參數進行的配置是固定的,配置文件定義了路由通知,通知接受者的信息sql
使用可視化編輯器能夠幫助你構建路由樹docker
使用alertmanager -h
顯示alertmanager可用的命令行參數express
Alertmanager能夠在進程運行的時候從新加載他的配置文件,若是你的配置文件不正確,它將不會被記錄以及應用,只有你對正在運行的進程發送SIGHUP
信號或者經過發送HTTP POST
請求到/-/reload
時纔會被加載api
路由塊定義路由樹中的節點及其子節點。若是未設置,其可選配置參數將從其父節點繼承。每一個警報都在配置的頂級路由中進入路由樹,該路由必須匹配全部警報(即沒有任何已配置的匹配器)。而後它遍歷子節點。若是將continue設置爲false,則在第一個匹配的子項後中止。若是匹配節點上的continue爲true,則警報將繼續與後續兄弟節點匹配。若是警報與節點的任何子節點都不匹配(沒有匹配的子節點,或者不存在),則根據當前節點的配置參數處理警報。app
# The root route with all parameters, which are inherited by the child # routes if they are not overwritten. route: receiver: 'default-receiver' group_wait: 30s group_interval: 5m repeat_interval: 4h group_by: [cluster, alertname] # All alerts that do not match the following child routes # will remain at the root node and be dispatched to 'default-receiver'. routes: # All alerts with service=mysql or service=cassandra # are dispatched to the database pager. - receiver: 'database-pager' group_wait: 10s match_re: service: mysql|cassandra # All alerts with the team=frontend label match this sub-route. # They are grouped by product and environment rather than cluster # and alertname. - receiver: 'frontend-pager' group_by: [product, environment] match: team: frontend
一些receiver的常見配置:https://prometheus.io/docs/alerting/configuration/
免責聲明:Prometheus會自動負責發送由其配置的警報規則生成的警報。強烈建議根據時間序列數據在Prometheus中配置警報規則,而不是實現直接客戶端
prometheus向alertmanager發送警告.alertManager向接受者發送通知的模板是能夠自定義的,也能夠使用Prometheus自身的模板,其自身的模板是基於Go語言的
# 最後五分鐘http請求增加率 rate(http_requests_total{job="api-server"}[5m]) # 返回五分鐘內最近兩次數據點的HTTP請求每秒增加率 irate(http_requests_total{job="api-server"}[5m])
http://192.168.20.161:9090/-/reload