{"id":415169,"date":"2024-06-30T00:12:27","date_gmt":"2024-06-30T00:12:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=415169"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=415169","title":{"rendered":"<span>\u0421\u0435\u043a\u0440\u0435\u0442\u044b observability. \u0427\u0430\u0441\u0442\u044c 2: \u0430\u043b\u0435\u0440\u0442\u044b<\/span>"},"content":{"rendered":"<div><!--[--><img loading=\"lazy\" decoding=\"async\" height=\"1\" src=\"https:\/\/www.facebook.com\/tr?id=971720443354181&amp;ev=PageView&amp;noscript=1\" style=\"display:none;\" width=\"1\"><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/7o\/fw\/zs\/7ofwzs-ospwrxdzmumx6hmdvhnc.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/7o\/fw\/zs\/7ofwzs-ospwrxdzmumx6hmdvhnc.jpeg\" data-blurred=\"true\"\/><br \/>  <em>\u0424\u043e\u0442\u043e Ricardo Gomez Angel, Unsplash.com<\/em><\/p>\n<p>  <\/p>\n<h4 id=\"ispolzuem-metriki-dlya-otpravki-uvedomleniy-cherez-slack\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 Slack<\/h4>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/company\/southbridge\/blog\/569860\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0437\u0430\u0434\u0435\u043f\u043b\u043e\u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 Prometheus \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e helm-\u0447\u0430\u0440\u0442\u0430 \u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 prom-client \u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u044b. \u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0446\u0435\u043b\u044c observability (\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0441\u0442\u0438) \u2014 \u0443\u0437\u043d\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u044b\u0435 \u043b\u044e\u0434\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u0437\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u043b\u0435\u0440\u0442\u044b.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u0432 Prometheus \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439. \u0412 \u0441\u0430\u043c\u043e\u043c Prometheus \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c <strong>\u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0430\u043b\u0435\u0440\u0442\u043e\u0432<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0430\u043b\u0435\u0440\u0442\u043e\u0432. \u041a\u043e\u0433\u0434\u0430 \u0430\u043b\u0435\u0440\u0442\u044b \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442, Prometheus \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 AlertManager, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u0445 \u043f\u043e\u0434\u0430\u0432\u043b\u044f\u0442\u044c, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u0432\u0438\u043b \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435 \u0447\u0435\u0440\u0435\u0437 Slack. \u0412\u0441\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/jonathanbc92\/observability-quickstart\/tree\/master\/part2\">\u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>.<\/p>\n<p>  <\/p>\n<h3 id=\"pravila-alertov\">\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0430\u043b\u0435\u0440\u0442\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 Prometheus, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 PrometheusRule. \u0412 PrometheusRule \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<p><strong>Groups:<\/strong> \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0430\u043b\u0435\u0440\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  <\/p>\n<p><strong>Rules:<\/strong> \u0438\u043c\u044f, \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f, \u043f\u0435\u0440\u0438\u043e\u0434 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u043c\u0435\u0442\u043a\u0438 \u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0430\u043b\u0435\u0440\u0442\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 Prometheus. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Prometheus expression builder, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0430 \u043f\u0440\u0430\u0432\u0438\u043b database.rules \u0441 \u043e\u0434\u043d\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 mysql_up <strong>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0443\u043c 1 \u043c\u0438\u043d\u0443\u0442\u0443<\/strong>.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">apiVersion: monitoring.coreos.com\/v1 kind: PrometheusRule metadata:   creationTimestamp: null   namespace: observability   labels:     prometheus: example     role: alert-rules     release: prometheus     app: kube-prometheus-stack   name: prometheus-example-rules spec:   groups:   - name: database.rules     rules:     - alert: \"MysqlDown\"       expr: (absent(mysql_up)) == 1       for: 1m       labels:         severity: critical         namespace: observability       annotations:         description: MySQL has been down for more than a minute<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>kubectl apply -f alertrules.yml<\/code> \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 Alerts \u0432 Prometheus.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/o9\/-h\/es\/o9-hes1tvay0dl9gpz32sad66us.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/o9\/-h\/es\/o9-hes1tvay0dl9gpz32sad66us.png\"\/><br \/>  <em>\u0410\u043b\u0435\u0440\u0442 Prometheus MysqlDown<\/em><\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043b\u0438\u043a \u0434\u0435\u043f\u043b\u043e\u044f MySQL:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">kubectl scale deployment\/mysql --replicas=0 -n applications<\/code><\/pre>\n<p>  <\/p>\n<p>\u0413\u0434\u0435-\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u043d\u0443\u0442\u0443 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043b\u0435\u0440\u0442:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/y8\/43\/7u\/y8437uupzsvzvbkluq6ko5bpk_y.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/y8\/43\/7u\/y8437uupzsvzvbkluq6ko5bpk_y.png\"\/><br \/>  <em>\u0421\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0439 \u0430\u043b\u0435\u0440\u0442 Prometheus MysqlDown<\/em><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0430\u043c\u0438\u043c \u2014 \u0432 helm-\u0447\u0430\u0440\u0442\u0435 Kube Prometheus \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u0434\u043b\u044f \u043c\u0435\u0442\u0440\u0438\u043a Kubernetes. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u0438\u0445 \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/fz\/cj\/yg\/fzcjyg5jihxvrs_kmu5vw6nw_go.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/fz\/cj\/yg\/fzcjyg5jihxvrs_kmu5vw6nw_go.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0439 \u0441\u0431\u043e\u0439? \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043e\u0434\u043d\u043e \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c, \u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0430\u043b \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c AlertManager, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u0430\u043b\u0435\u0440\u0442\u044b \u0432 \u043e\u0434\u043d\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0441\u043e\u0437\u0434\u0430\u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0435\u0440\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u0435\u0441\u043b\u0438 \u0443 \u0434\u0435\u043f\u043b\u043e\u044f \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0432\u0443\u0445 \u0440\u0435\u043f\u043b\u0438\u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c Slack.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">apiVersion: monitoring.coreos.com\/v1 kind: PrometheusRule metadata:   creationTimestamp: null   namespace: observability   labels:     prometheus: example     role: alert-rules     release: prometheus     app: kube-prometheus-stack   name: prometheus-example-rules-services spec:   groups:   - name: services.rules     rules:     - alert: \"NotEnoughContainerReplicas\"       expr: count by (namespace,container,job) (up{container=~\".*-service\"}) &lt; 2       for: 30s       labels:         severity: warning         namespace: observability       annotations:         description: \"{{ $labels.job }}: {{ $labels.container }} container doesn't have enough replicas for more than 30 seconds.\"<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"podgotovka-slack\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 Slack<\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c\u0441\u044f \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0435 \u0430\u043b\u0435\u0440\u0442\u044b \u0432 Slack. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u043d\u0430\u043b Slack.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/bk\/9o\/ku\/bk9okugtwe54olvzysmnjxqs5h8.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/bk\/9o\/ku\/bk9okugtwe54olvzysmnjxqs5h8.png\"\/><br \/>  <em>\u041e\u043a\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0432 Slack<\/em><\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c <a href=\"https:\/\/api.slack.com\/apps\">\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/a> \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c Incoming Webhooks (\u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432\u0435\u0431\u0445\u0443\u043a\u0438) \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0432\u0435\u0431\u0445\u0443\u043a \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c URL \u0432\u0435\u0431\u0445\u0443\u043a\u0430 \u2014 \u043e\u043d \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ap\/j6\/3w\/apj63w4pw-qugsf2ivs8ujdhvkw.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/ap\/j6\/3w\/apj63w4pw-qugsf2ivs8ujdhvkw.png\"\/><br \/>  <em>\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432\u0435\u0431\u0445\u0443\u043a\u043e\u0432 \u0432 Slack<\/em><\/p>\n<p>  <\/p>\n<h3 id=\"nastroyka-alertmanager\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 AlertManager<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c AlertManager, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c AlertmanagerConfig. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d receiver (\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f) \u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043a\u043e \u0432\u0441\u0435\u043c receiver-\u0430\u043c.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><strong>groupBy<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 AlertManager \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435.<\/li>\n<li><strong>groupWait<\/strong> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0434\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/li>\n<li><strong>groupInterval<\/strong> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0434\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/li>\n<li><strong>repeatInterval<\/strong> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0434\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0423 Receiver-\u0430 Slack \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u0441\u043c. <a href=\"https:\/\/prometheus.io\/docs\/alerting\/latest\/configuration\/#slack_config\">\u0437\u0434\u0435\u0441\u044c<\/a>).<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0414\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Slack \u043d\u0443\u0436\u0435\u043d URL \u0432\u0435\u0431\u0445\u0443\u043a\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u0430. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0441\u0435\u043a\u0440\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>apiURL<\/strong>.<\/li>\n<li><strong>channel<\/strong> \u2014 \u043a\u0430\u043d\u0430\u043b Slack, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439.<\/li>\n<li><strong>SendResolved<\/strong> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 AlertManager, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0430\u043b\u0435\u0440\u0442\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f.<\/li>\n<li><strong>Title<\/strong> \u0438 <strong>Text<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f Slack. \u041e\u0431\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <a href=\"https:\/\/jonbc.medium.com\/hacking-your-way-to-observability-part-2-c38baaee6b92#ad1e\">\u0448\u0430\u0431\u043b\u043e\u043d<\/a>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435 \u0432\u0441\u0435 \u0430\u043b\u0435\u0440\u0442\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c, \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0435 \u0437\u0430 30 \u0441\u0435\u043a\u0443\u043d\u0434, \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u043e\u0434\u043d\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 Slack.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">apiVersion: monitoring.coreos.com\/v1alpha1 kind: AlertmanagerConfig metadata:   name: slack-alertmanager   labels:     alertmanagerConfig: slack   namespace: observability spec:   route:     groupBy: ['alertname']     groupWait: 30s     groupInterval: 5m     repeatInterval: 12h     receiver: 'slack'   receivers:   - name: 'slack'     slackConfigs:     - sendResolved: true       apiURL:         name: slack-secret         key: url       channel: '#alerts'       title: '{{ template \"alert_title\" . }}'       text: '{{ template \"alert_description\" . }}'<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 AlertmanagerConfig<\/em><\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>kubectl apply -f alertmanagerconfig.yml<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 AlertManager \u0438 \u0432\u0438\u0434\u0438\u043c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b. \u041c\u0430\u0440\u0448\u0440\u0443\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438, \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u2014 \u0443 \u043d\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u0438\u043c\u044f \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 match. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>match<\/strong> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u0430\u043b\u0435\u0440\u0442\u0443, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 receiver. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043a\u0430\u0436\u0434\u044b\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d \u2014 \u0432 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043c\u0435\u0442\u043a\u0430 \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u0430 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 match, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043a\u0438.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/x6\/8t\/16\/x68t16atm2adbpvk4jxs3wkjheu.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/x6\/8t\/16\/x68t16atm2adbpvk4jxs3wkjheu.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0430\u043b\u0435\u0440\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 receiver, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/prometheus.io\/webtools\/alerting\/routing-tree-editor\/\">routing tree editor<\/a>. \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e AlertManager \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043a\u0438 \u0430\u043b\u0435\u0440\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/3a\/lr\/de\/3alrde7v_rvj6ylrwvaegeri6j8.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/3a\/lr\/de\/3alrde7v_rvj6ylrwvaegeri6j8.png\"\/><br \/>  <em>Routing Tree Editor<\/em><\/p>\n<p>  <\/p>\n<h3 id=\"shablony\">\u0428\u0430\u0431\u043b\u043e\u043d\u044b<\/h3>\n<p>  <\/p>\n<p>Prometheus \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0434\u043b\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0430\u043b\u0435\u0440\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0448\u0430\u0431\u043b\u043e\u043d\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">{{ define \"__title\" }}{{ range .Alerts.Firing }}{{ .Labels.alertname }}{{ end }}{{ range .Alerts.Resolved }}{{ .Labels.alertname }}{{ end }}{{ end }} {{ define \"alert_title\" }}[{{ .Status | toUpper }}{{ if eq .Status \"firing\" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ if or (and (eq (len .Alerts.Firing) 1) (eq (len .Alerts.Resolved) 0)) (and (eq (len .Alerts.Firing) 0) (eq (len .Alerts.Resolved) 1)) }}{{ template \"__title\" . }}{{ end }}{{ end }} {{ define \"alert_description\"}} {{ if or (and (eq (len .Alerts.Firing) 1) (eq (len .Alerts.Resolved) 0)) (and (eq (len .Alerts.Firing) 0) (eq (len .Alerts.Resolved) 1)) }} {{ range .Alerts.Firing }}{{ .Annotations.description }} *{{ .Labels.severity | toUpper }}* :chart_with_upwards_trend: *&lt;{{ .GeneratorURL }}|Graph>*{{ end }} {{ range .Alerts.Resolved }}{{ .Annotations.description }} :chart_with_upwards_trend: *&lt;{{ .GeneratorURL }}|Graph>*{{ end }} {{ else }} {{ if gt (len .Alerts.Firing) 0 }}*Alerts Firing:* {{ range .Alerts.Firing }}- {{ .Annotations.description }} | *{{ .Labels.severity | toUpper }}* :chart_with_upwards_trend: *&lt;{{ .GeneratorURL }}|Graph>* {{ end }}{{ end }} {{ if gt (len .Alerts.Resolved) 0 }} *Resolved:* {{ range .Alerts.Resolved }}- {{ .Annotations.description }} :chart_with_upwards_trend: *&lt;{{ .GeneratorURL }}|Graph>* {{ end }}{{ end }} {{ end }} {{ end }}<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 Prometheus<\/em><\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <em>define<\/em> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430. \u0412 \u043a\u043e\u0434\u0435 \u0442\u0440\u0438 \u043c\u043d\u043e\u0433\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0445 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430: __title, alert_title \u0438 alert_description.<\/p>\n<p>  <\/p>\n<p><strong>__title<\/strong> \u2014 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0435 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u0435\u0440\u0442\u044b \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u043c\u044f \u0430\u043b\u0435\u0440\u0442\u0430.<\/p>\n<p>  <\/p>\n<p><strong>alert_title<\/strong> \u2014 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0445 \u0430\u043b\u0435\u0440\u0442\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 __title, \u0435\u0441\u043b\u0438 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0438\u0439 \u0438\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0439 \u0430\u043b\u0435\u0440\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d.<\/p>\n<p>  <\/p>\n<p><strong>alert_description<\/strong> \u2014 \u0435\u0441\u043b\u0438 \u0430\u043b\u0435\u0440\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d, \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0441\u0442\u0438 \u0430\u043b\u0435\u0440\u0442\u0430, \u0430 \u0435\u0449\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 URL \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0432 Prometheus. \u0415\u0441\u043b\u0438 \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u0445 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0432 Prometheus \u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c, \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 AlertManager. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <a href=\"https:\/\/github.com\/prometheus-community\/helm-charts\/blob\/main\/charts\/kube-prometheus-stack\/values.yaml\">\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/a> \u0432 helm-\u0447\u0430\u0440\u0442. \u0420\u0430\u0437 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>  <\/p>\n<pre><code class=\"go\">alertmanager:   templateFiles:     template_1.tmpl: |-         {{ define \"__title\" }}{{ range .Alerts.Firing }}{{ .Labels.alertname }}{{ end }}{{ range .Alerts.Resolved }}{{ .Labels.alertname }}{{ end }}{{ end }}         {{ define \"alert_title\" }}[{{ .Status | toUpper }}{{ if eq .Status \"firing\" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ if or (and (eq (len .Alerts.Firing) 1) (eq (len .Alerts.Resolved) 0)) (and (eq (len .Alerts.Firing) 0) (eq (len .Alerts.Resolved) 1)) }}{{ template \"__title\" . }}{{ end }}{{ end }}         {{ define \"alert_description\"}}         {{ if or (and (eq (len .Alerts.Firing) 1) (eq (len .Alerts.Resolved) 0)) (and (eq (len .Alerts.Firing) 0) (eq (len .Alerts.Resolved) 1)) }}         {{ range .Alerts.Firing }}{{ .Annotations.description }} *{{ .Labels.severity | toUpper }}* :chart_with_upwards_trend: *&lt;{{ .GeneratorURL }}|Graph>*{{ end }}         {{ range .Alerts.Resolved }}{{ .Annotations.description }} :chart_with_upwards_trend: *&lt;{{ .GeneratorURL }}|Graph>*{{ end }}         {{ else }}         {{ if gt (len .Alerts.Firing) 0 }}*Alerts Firing:*         {{ range .Alerts.Firing }}- {{ .Annotations.description }} | *{{ .Labels.severity | toUpper }}* :chart_with_upwards_trend: *&lt;{{ .GeneratorURL }}|Graph>*         {{ end }}{{ end }}         {{ if gt (len .Alerts.Resolved) 0 }}         *Resolved:*         {{ range .Alerts.Resolved }}- {{ .Annotations.description }} :chart_with_upwards_trend: *&lt;{{ .GeneratorURL }}|Graph>*         {{ end }}{{ end }}         {{ end }}         {{ end }}<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0435\u043f\u043b\u043e\u0439\u043c\u0435\u043d\u0442 helm \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">helm upgrade --reuse-values prometheus prometheus-community\/kube-prometheus-stack -n observability -f values.yml<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"testirovanie-uvedomleniy\">\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 Slack, \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0430\u043b\u0435\u0440\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043b\u0438\u043a MySQL, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0430\u043b\u0435\u0440\u0442\u0443:<\/p>\n<p>  <\/p>\n<p>\u0423\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043b\u0438\u043a MySQL: <code>kubectl scale deployment\/mysql --replicas=0 -n applications<\/code><\/p>\n<p>  <\/p>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c: <code>kubectl scale deployment\/mysql --replicas=1 -n applications<\/code><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043a\u0430\u043d\u0430\u043b Slack, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zc\/9z\/w-\/zc9zw-bhonocmcaziu3dixpogak.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/zc\/9z\/w-\/zc9zw-bhonocmcaziu3dixpogak.png\"\/><br \/>  <em>\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f Prometheus \u0432 Slack<\/em><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435.<br \/>  \u0423\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043b\u0438\u043a Node.js:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">kubectl scale deployment\/format-service-depl --replicas=1 -n applications kubectl scale deployment\/hello-service-depl --replicas=1 -n applications kubectl scale deployment\/people-service-depl --replicas=1 -n applications<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">kubectl scale deployment\/format-service-depl --replicas=2 -n applications kubectl scale deployment\/hello-service-depl --replicas=2 -n applications kubectl scale deployment\/people-service-depl --replicas=2 -n applications <\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 Slack \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/62\/j0\/o-\/62j0o-5tem_lu1ybojhtktbupao.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/62\/j0\/o-\/62j0o-5tem_lu1ybojhtktbupao.png\"\/><br \/>  <em>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u0435\u0440\u0442\u044b Prometheus \u0432 Slack<\/em><\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0430\u043b\u0435\u0440\u0442\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u043e\u0434\u043d\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0438 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u043e\u0434\u043d\u0443 \u0433\u0440\u0443\u043f\u043f\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043d\u0438\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0438\u043c\u044f. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0433\u0440\u0443\u043f\u043f\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/4b\/sy\/f0\/4bsyf0vk3cjhnwukxglo1mv8igm.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/4b\/sy\/f0\/4bsyf0vk3cjhnwukxglo1mv8igm.png\"\/><br \/>  <em>\u0410\u043b\u0435\u0440\u0442\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c<\/em><\/p>\n<p>  <\/p>\n<h3 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u2014 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0430\u043b\u0435\u0440\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u0442\u0430\u0442\u044c \u043e\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/572792\/\"> https:\/\/habr.com\/ru\/articles\/572792\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><img loading=\"lazy\" decoding=\"async\" height=\"1\" src=\"https:\/\/www.facebook.com\/tr?id=971720443354181&amp;ev=PageView&amp;noscript=1\" style=\"display:none;\" width=\"1\"><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/7o\/fw\/zs\/7ofwzs-ospwrxdzmumx6hmdvhnc.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/7o\/fw\/zs\/7ofwzs-ospwrxdzmumx6hmdvhnc.jpeg\" data-blurred=\"true\"\/><br \/>  <em>\u0424\u043e\u0442\u043e Ricardo Gomez Angel, Unsplash.com<\/em><\/p>\n<p>  <\/p>\n<h4 id=\"ispolzuem-metriki-dlya-otpravki-uvedomleniy-cherez-slack\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 Slack<\/h4>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/company\/southbridge\/blog\/569860\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0437\u0430\u0434\u0435\u043f\u043b\u043e\u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 Prometheus \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e helm-\u0447\u0430\u0440\u0442\u0430 \u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 prom-client \u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u044b. \u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0446\u0435\u043b\u044c observability (\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0441\u0442\u0438) \u2014 \u0443\u0437\u043d\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u044b\u0435 \u043b\u044e\u0434\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u0437\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0435\u043b\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u043b\u0435\u0440\u0442\u044b.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-415169","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=415169"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415169\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=415169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=415169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=415169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}