{"id":355819,"date":"2024-05-20T23:16:45","date_gmt":"2024-05-20T23:16:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=355819"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T23:16:45","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=355819","title":{"rendered":"<span>\u0411\u0443\u0434\u044c \u0432\u0441\u0435\u0433\u0434\u0430 \u0432 \u043a\u0443\u0440\u0441\u0435: \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Prometheus \u0438 Telegram<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432? \u0412\u044b\u0434\u0430\u043d \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u2013 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u0435\u0433\u043e \u0441\u0440\u043e\u043a\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u041c\u043d\u043e\u0433\u0438\u0435 \u043f\u043e \u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0438, \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f, \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u043c\u0435\u0442\u043a\u0438. \u041d\u043e \u0440\u0443\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0435\u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b, \u0432\u0435\u0434\u044c \u043b\u044e\u0434\u0438 \u043e\u0448\u0438\u0431\u0430\u044e\u0442\u0441\u044f, \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442 \u0438 \u0442\u0435\u0440\u044f\u044e\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. <\/p>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u043d\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u0442\u043e \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0438\u0437-\u0437\u0430 \u043f\u0440\u043e\u0442\u0443\u0445\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443. <\/p>\n<h2>\u0413\u043b\u0443\u0431\u0436\u0435 \u0432 \u0442\u0435\u0445\u043d\u0438\u043a\u0443: Grafana, Prometheus \u0438 \u043d\u0430\u0448\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u044b<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c Grafana \u0438 Prometheus &#8212; \u044d\u0442\u043e \u043d\u0430\u0448\u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430. \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u0431\u043e\u043b\u0442\u0430\u0435\u043c \u043e\u0431 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u0430\u0445 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u0440\u0443\u0442\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c\u043a\u0443 \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u043c\u0438. \u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043d\u0430\u0443\u0447\u0438\u043c Alertmanager \u0441\u043b\u0430\u0442\u044c \u043d\u0430\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 Telegram.<\/p>\n<h4>1. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u0441\u043d\u043e\u0432: Grafana + Prometheus \u0438 Docker Compose<\/h4>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0432 \u0442\u0435\u043c\u0435 \u0438 \u0443\u0436\u0435 \u0442\u044b\u0441\u044f\u0447\u0443 \u0440\u0430\u0437 <a href=\"https:\/\/github.com\/docker\/awesome-compose\/tree\/master\/prometheus-grafana\" rel=\"noopener noreferrer nofollow\">\u0441\u043b\u044b\u0448\u0430\u043b \u043e awesome-compose\/prometheus-grafana<\/a>, \u0448\u0430\u0433 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 &#8212; \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f <code>compose.yml<\/code> \u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"yaml\">services:   prometheus:     image: prom\/prometheus     container_name: prometheus     command:       - \"--config.file=\/etc\/prometheus\/prometheus_config.yml\"     ports:       - 9090:9090     restart: unless-stopped     volumes:       - .\/prometheus:\/etc\/prometheus       - prom_data:\/prometheus   grafana:     image: grafana\/grafana     container_name: grafana     ports:       - 3000:3000     restart: unless-stopped     env_file: .env     environment:       - GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER}       - GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD}     volumes:       - .\/grafana:\/etc\/grafana\/provisioning\/datasources volumes:   prom_data:<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <code>prometheus<\/code> \u0441 \u0444\u0430\u0439\u043b\u043e\u043c <code>prometheus_config.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">global:   scrape_interval: 15s   scrape_timeout: 10s   evaluation_interval: 15s<\/code><\/pre>\n<p>\u0418 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>grafana<\/code> \u0438 \u0444\u0430\u0439\u043b\u0430 <code>datasource.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">apiVersion: 1  datasources:   - name: Prometheus     type: prometheus     url: http:\/\/prometheus:9090     isDefault: true     access: proxy     editable: true<\/code><\/pre>\n<blockquote>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u0432 \u0444\u0430\u0439\u043b\u0435: <code>.env<\/code>. \u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u0442\u0430\u043a \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0448\u0438\u0444\u0440\u0443\u0439\u0442\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e.<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>.env<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>\u0418\u041c\u042f_\u041f\u041e\u041b\u042c\u0417\u041e\u0412\u0410\u0422\u0415\u041b\u042f_GRAFANA<\/code> \u0438 <code>\u041f\u0410\u0420\u041e\u041b\u042c_\u041f\u041e\u041b\u042c\u0417\u041e\u0412\u0410\u0422\u0415\u041b\u042f_GRAFANA<\/code>:<\/p>\n<pre><code>GF_SECURITY_ADMIN_USER=&lt;\u0418\u041c\u042f_\u041f\u041e\u041b\u042c\u0417\u041e\u0412\u0410\u0422\u0415\u041b\u042f_GRAFANA> GF_SECURITY_ADMIN_PASSWORD=&lt;\u041f\u0410\u0420\u041e\u041b\u042c_\u041f\u041e\u041b\u042c\u0417\u041e\u0412\u0410\u0422\u0415\u041b\u042f_GRAFANA><\/code><\/pre>\n<p>\u041f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u0432\u0441\u044e \u044d\u0442\u0443 \u043a\u0440\u0430\u0441\u043e\u0442\u0443:<\/p>\n<pre><code class=\"bash\">docker-compose up -d<\/code><\/pre>\n<p>\u0422\u0430\u043a, \u043c\u0430\u0433\u0438\u044f Docker \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430, \u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c <a href=\"https:\/\/http:localhost:3000\" rel=\"noopener noreferrer nofollow\">Grafana \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 3000<\/a> \u0438 <a href=\"http:\/\/localhost:9090\" rel=\"noopener noreferrer nofollow\">Prometheus \u043d\u0430 9090<\/a>. \u041f\u0440\u043e\u0441\u0442\u043e? \u041f\u0440\u043e\u0441\u0442\u043e!<\/p>\n<h4>2. \u041f\u043e\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u0441\u044f \u0432 \u043c\u0438\u0440 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u043e\u0432: \u0432\u044b\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430<\/h4>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b. \u0412\u0435\u0434\u044c \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u043a\u0430\u0436\u0434\u0430\u044f \u043a\u0438\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0430 <br \/>\u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u0445\u043e\u043b\u0441\u0442\u0435. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043b\u044f \u0432\u0430\u0441:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\" rel=\"noopener noreferrer nofollow\">ssl_exporter: \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0438 \u0442\u043e\u043b\u044c\u043a\u043e<\/a>. \u0414\u0430\u0435\u0442 \u0431\u043e\u0433\u0430\u0442\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u0445: \u0434\u0430\u0442\u044b \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438: TCP, HTTPS, SMTP \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041d\u043e \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 SSL\/TLS, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/prometheus\/blackbox_exporter\" rel=\"noopener noreferrer nofollow\">blackbox_exporter: \u0443\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0435<\/a>, \u043e\u043d \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b. \u0415\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\" rel=\"noopener noreferrer nofollow\">ssl_exporter<\/a>, \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0430\u0431\u0435\u0435. \u0418\u0437\u0431\u044b\u0442\u043e\u0447\u0435\u043d, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432, \u043d\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/amimof\/node-cert-exporter\" rel=\"noopener noreferrer nofollow\">node-cert-exporter: \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u043d\u0430 \u0434\u0438\u0441\u043a\u0435<\/a>, \u044d\u0442\u043e \u0432\u0430\u0448 \u0432\u044b\u0431\u043e\u0440. \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439. <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/enix\/x509-certificate-exporter\" rel=\"noopener noreferrer nofollow\">x509-certificate-exporter: \u0434\u0430\u0435\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u0445<\/a>. \u0413\u0438\u0431\u043a\u0438\u0439, \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u043b\u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 Kubernetes. \u0421\u043b\u043e\u0436\u043d\u0435\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/joe-elliott\/cert-exporter\" rel=\"noopener noreferrer nofollow\">cert_exporter: \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432<\/a>, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, Kubernetes \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u0412\u0435\u0441\u044c\u043c\u0430 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c? \u0412\u044b\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u2013 \u044d\u0442\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u043e, \u0438, \u043a\u0430\u043a \u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435, \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0438 \u0438 \u043d\u044e\u0430\u043d\u0441\u044b. \u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0430\u0448\u0438\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044f\u043c \u0438 \u043d\u0435 \u0431\u043e\u0439\u0442\u0435\u0441\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h4>3. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 ssl_exporter<\/h4>\n<p>\u041c\u044b \u0443\u0436\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 ssl_exporter. \u0421\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u0445\u043e\u0440\u043e\u0448\u043e <br \/>\u0438 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 <code>compose.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">ssl_exporter:   image: ribbybibby\/ssl-exporter   ports:     - \"9219:9219\"<\/code><\/pre>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430\u0448\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u0431\u0443\u0434\u0435\u0442 <code>prometheus.io<\/code>. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <code>scrape_configs<\/code> \u0432 <code>prometheus_config.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">scrape_configs:   - job_name: \"ssl-exporter\"     metrics_path: \/probe     static_configs:       - targets:           - prometheus.io:443     relabel_configs:       - source_labels: [__address__]         target_label: __param_target       - source_labels: [__param_target]         target_label: instance       - target_label: __address__         replacement: ssl_exporter:9219<\/code><\/pre>\n<p>\u0422\u0430\u043a, \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 <code>compose.yml<\/code>:<\/p>\n<pre><code class=\"bash\">docker-compose restart<\/code><\/pre>\n<p>\u0412 <a href=\"http:\/\/localhost:9090\/graph?g0.expr=ssl_probe_success&amp;g0.tab=1&amp;g0.stacked=0&amp;g0.show_exemplars=0&amp;g0.range_input=1h\" rel=\"noopener noreferrer nofollow\">Prometheus \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c PromQL \u0437\u0430\u043f\u0440\u043e\u0441<\/a> \u2013 <code>ssl_probe_success<\/code> \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435, \u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0432\u0441\u0435 \u0432\u0435\u0440\u043d\u043e:<\/p>\n<pre><code>ssl_probe_success{instance=\"prometheus.io:443\",\u00a0job=\"ssl-exporter\"}<\/code><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 TCP-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0446\u0435\u043b\u044c\u044e. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u044d\u0442\u043e\u0433\u043e \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 http, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u043e\u0434\u0443\u043b\u044c <code>https<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>file<\/code> \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435:<\/p>\n<pre><code class=\"yaml\">scrape_configs:   - job_name: \"ssl-files\"     metrics_path: \/probe     params:       module: [\"file\"]       target: [\"\/etc\/ssl\/cert.pem\"]     kubernetes_sd_configs:       - role: node     relabel_configs:       - source_labels: [__address__]         regex: ^(.*):(.*)$         target_label: __address__         replacement: ${1}:9219<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043b\u043e\u0431-\u043f\u043e\u0438\u0441\u043a, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code class=\"yaml\">scrape_configs:   - job_name: \"ssl-files\"     metrics_path: \/probe     params:       module: [\"file\"]       target: [\"\/etc\/ssl\/**\/*.pem\"]     kubernetes_sd_configs:       - role: node     relabel_configs:       - source_labels: [__address__]         regex: ^(.*):(.*)$         target_label: __address__         replacement: ${1}:9219<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 Kubernetes, \u0432 <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\/tree\/master#configuration-file\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<h4>4. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u043d\u0435\u043b\u044c \u0432 Grafana<\/h4>\n<p>\u0412\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\/blob\/master\/contrib\/grafana\/dashboard.json\" rel=\"noopener noreferrer nofollow\">\u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f ssl_exporter<\/a>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d4b\/1b9\/83d\/d4b1b983dfca171b7a85610fe2498de5.png\" alt=\"\u0412 \u043f\u0430\u043d\u0435\u043b\u0438 SSL Certificates \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435: \u0435\u0433\u043e \u0438\u043c\u044f, \u0438\u043d\u0441\u0442\u0430\u043d\u0441, \u0438\u043c\u044f \u044d\u043c\u0438\u0442\u0435\u043d\u0442\u0430, \u0432\u044b\u0434\u0430\u0432\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0438 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438. \u042d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043c\u0435\u0442\u0440\u0438\u043a, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u043d\u0435\u043b\u044c \u043f\u043e\u0434 \u043b\u044e\u0431\u044b\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438.\" title=\"\u0412 \u043f\u0430\u043d\u0435\u043b\u0438 SSL Certificates \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435: \u0435\u0433\u043e \u0438\u043c\u044f, \u0438\u043d\u0441\u0442\u0430\u043d\u0441, \u0438\u043c\u044f \u044d\u043c\u0438\u0442\u0435\u043d\u0442\u0430, \u0432\u044b\u0434\u0430\u0432\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0438 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438. \u042d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043c\u0435\u0442\u0440\u0438\u043a, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u043d\u0435\u043b\u044c \u043f\u043e\u0434 \u043b\u044e\u0431\u044b\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438.\" width=\"1626\" height=\"841\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d4b\/1b9\/83d\/d4b1b983dfca171b7a85610fe2498de5.png\"\/><\/p>\n<div><figcaption>\u0412 \u043f\u0430\u043d\u0435\u043b\u0438 <em>SSL Certificates<\/em> \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435: \u0435\u0433\u043e \u0438\u043c\u044f, \u0438\u043d\u0441\u0442\u0430\u043d\u0441, \u0438\u043c\u044f \u044d\u043c\u0438\u0442\u0435\u043d\u0442\u0430, \u0432\u044b\u0434\u0430\u0432\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0438 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438. \u042d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\/tree\/master#metrics\" rel=\"noopener noreferrer nofollow\">\u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043c\u0435\u0442\u0440\u0438\u043a<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u043d\u0435\u043b\u044c \u043f\u043e\u0434 \u043b\u044e\u0431\u044b\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438.<\/figcaption><\/div>\n<\/figure>\n<h2>\u041a\u0430\u043a \u043d\u0435 \u043f\u0440\u043e\u0441\u043f\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>\u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u043f\u043b\u0430\u043d\u0430\u0445? \u041f\u043e\u0434\u043d\u0438\u043c\u0435\u043c \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0430 Flask&#8217;\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0432\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e\u0442 Alertmanager \u0438 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u0442\u044c \u0438\u0445 \u0432 Telegram. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u043e\u0442 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c Alertmanager \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439.<\/p>\n<h4>1. \u0412\u0437\u043b\u0435\u0442\u0430\u0435\u043c \u0441 Flask<\/h4>\n<p>\u041b\u0430\u0434\u043d\u043e, \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043c\u0435\u043b\u043e\u0447\u0438\u0442\u044c\u0441\u044f, \u0437\u0430\u0432\u043e\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <code>telegram<\/code> \u0438 \u043a\u0438\u0434\u0430\u0435\u043c \u0442\u0443\u0434\u0430 \u0444\u0430\u0439\u043b\u0438\u043a <code>app.py<\/code> \u0441 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u043c, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u043c \u0438 \u0432 \u0441\u0442\u0438\u043b\u0435 true pythonista \u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"python\">import os import requests  from flask import Flask, request, jsonify  app = Flask(__name__)  TELEGRAM_TOKEN = os.environ[\"TELEGRAM_TOKEN\"] CHAT_ID = os.environ[\"TELEGRAM_CHAT_ID\"] TELEGRAM_URL = f\"https:\/\/api.telegram.org\/bot{TELEGRAM_TOKEN}\/sendMessage\"   @app.route(\"\/alert\", methods=[\"POST\"]) def webhook():     data = request.json     alertname = data[\"alerts\"][0][\"labels\"][\"alertname\"]     instance = data[\"alerts\"][0][\"labels\"][\"instance\"]     summary = data[\"alerts\"][0][\"annotations\"][\"summary\"]     text = f\"\u26a0\ufe0f Alarm! {alertname} for {instance}. \\n{summary}\"     payload = {\"chat_id\": CHAT_ID, \"text\": text}     response = requests.post(TELEGRAM_URL, data=payload)     return jsonify(status=\"success\"), 200   if __name__ == \"__main__\":     app.run(host=\"0.0.0.0\", port=8000)<\/code><\/pre>\n<p>\u0410 \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f <code>Dockerfile<\/code>:<\/p>\n<pre><code class=\"bash\">FROM python:3.10-alpine WORKDIR \/app COPY . \/app RUN pip3 install -r requirements.txt ENTRYPOINT [\"python3\"] CMD [\"app.py\"]<\/code><\/pre>\n<p>\u041d\u0443 \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u044b\u0439 <code>requirements.txt<\/code>:<\/p>\n<pre><code>flask requests<\/code><\/pre>\n<h4>2. \u041a\u0440\u0430\u0444\u0442\u0438\u043c \u0431\u043e\u0442\u0430:<\/h4>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c <code>@BotFather<\/code> \u0432 Telegram.<\/p>\n<\/li>\n<li>\n<p><code>\/newbot<\/code>, \u0434\u0430\u0435\u043c \u0435\u043c\u0443 \u0438\u043c\u044f \u0438 \u0432\u0443\u0430\u043b\u044f! \u0423 \u0432\u0430\u0441 \u0432 \u0440\u0443\u043a\u0430\u0445: <code>\u0422\u041e\u041a\u0415\u041d_\u0411\u041e\u0422\u0410<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u044f\u0441\u043d\u0438\u043c \u0441\u0432\u043e\u0439 chat_id, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0432 <code>\/start<\/code> \u0441\u0432\u043e\u0435\u043c\u0443 \u0431\u043e\u0442\u0443 \u0438 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 <code>https:\/\/api.telegram.org\/bot&lt;\u0422\u041e\u041a\u0415\u041d_\u0411\u041e\u0422\u0410>\/getUpdates<\/code>. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 <code>result[0]message.chat.id<\/code> \u0438 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0448 <code>\u0412\u0410\u0428_\u0427\u0410\u0422_ID<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432 <code>compose.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">telegram:   build:     context: telegram   stop_signal: SIGINT   env_file: .env   environment:     - TELEGRAM_TOKEN=${TELEGRAM_TOKEN}     - TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID}   ports:     - \"8000:8000\"<\/code><\/pre>\n<p>\u0410 \u0441\u0435\u043a\u0440\u0435\u0442\u044b <code>\u0422\u041e\u041a\u0415\u041d_\u0411\u041e\u0422\u0410<\/code> \u0438 <code>\u0412\u0410\u0428_\u0427\u0410\u0422_ID <\/code>\u0432  <code>.env<\/code> :<\/p>\n<pre><code>TELEGRAM_TOKEN=&lt;\u0422\u041e\u041a\u0415\u041d_\u0411\u041e\u0422\u0410> TELEGRAM_CHAT_ID=&lt;\u0412\u0410\u0428_\u0427\u0410\u0422_ID><\/code><\/pre>\n<h4>3. \u0414\u0440\u0443\u0436\u0438\u043c Alertmanager \u0441 Telegram<\/h4>\n<p>\u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0443\u0434\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u043b\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 Alertmanager <a href=\"https:\/\/prometheus.io\/docs\/alerting\/latest\/configuration\/#receiver-integration-settings\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043a\u0443\u0434\u0430 \u0443\u0433\u043e\u0434\u043d\u043e<\/a>, \u043d\u043e \u043c\u044b-\u0442\u043e \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e <a href=\"https:\/\/prometheus.io\/docs\/alerting\/latest\/configuration\/#telegram_config\" rel=\"noopener noreferrer nofollow\">\u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430\u0448 \u0432\u044b\u0431\u043e\u0440 \u2013 Telegram<\/a>.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u0430\u043b\u043e\u0433\u043e. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 90 \u0434\u043d\u0435\u0439 \u0436\u0438\u0437\u043d\u0438. \u0414\u043b\u044f \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f &#8212; \u0432 <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\/tree\/master#example-queries\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0440\u0430\u0437\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b<\/a>. \u0412 <code>prometheus<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <code>alert.rules.yml<\/code> \u0438 \u043f\u0438\u0448\u0435\u043c \u0442\u0443\u0434\u0430:<\/p>\n<pre><code class=\"yaml\">groups:   - name: ssl-alerts     rules:       - alert: Expiry Soon         expr: ssl_cert_not_after - time() &lt; 86400 * 90         for: 1m         labels:           severity: critical         annotations:           summary: \"SSL certificate is expiring soon (less than 90 days)\"<\/code><\/pre>\n<p>\u0414\u043e\u043f\u0438\u0448\u0435\u043c \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 <code>prometheus_config.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">rule_files:   - \"\/etc\/prometheus\/alert.rules.yml\" alerting:   alertmanagers:     - static_configs:         - targets:             - \"alertmanager:9093\"<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>alertmanager<\/code> \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0432 \u043d\u0435\u0435 \u0444\u0430\u0439\u043b <code>alertmanager_config.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">route:   group_by: [\"instance\"]   repeat_interval: 3h   receiver: \"telegram-webhook\"  receivers:   - name: \"telegram-webhook\"     webhook_configs:       - url: \"http:\/\/telegram:8000\/alert\"<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0436, \u043d\u0430\u0448 <code>compose.yml<\/code> \u0442\u043e\u0436\u0435 \u0445\u043e\u0447\u0435\u0442 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 <code>alertmanager<\/code>:<\/p>\n<pre><code class=\"yaml\">alertmanager:   image: quay.io\/prometheus\/alertmanager   container_name: alertmanager   command:     - \"--config.file=\/etc\/alertmanager\/alertmanager_config.yml\"   ports:     - \"9093:9093\"   volumes:     - .\/alertmanager:\/etc\/alertmanager<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u2014 \u043c\u0430\u0433\u0438\u044f:<\/p>\n<pre><code class=\"bash\">docker-compose down; docker-compose up -d<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 <a href=\"http:\/\/localhost:9093\/#\/alerts\" rel=\"noopener noreferrer nofollow\">Alertmanager \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0435\u0431\u044f \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u043e<\/a>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8d6\/e9c\/75c\/8d6e9c75c3170400c7e67dca5ad0a8f8.png\" alt=\"\" title=\"\" width=\"1626\" height=\"609\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8d6\/e9c\/75c\/8d6e9c75c3170400c7e67dca5ad0a8f8.png\"\/><\/figure>\n<p>\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432 <a href=\"http:\/\/localhost:9090\/alerts?search=\" rel=\"noopener noreferrer nofollow\">Prometheus \u0437\u0430\u043d\u044f\u043b\u043e \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e<\/a>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/65d\/373\/6da\/65d3736dad6947f4b8fd6d1bf041687c.png\" width=\"1626\" height=\"546\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/65d\/373\/6da\/65d3736dad6947f4b8fd6d1bf041687c.png\"\/><\/figure>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u043d\u0443\u0442\u0443 Prometheus \u043f\u043e\u0439\u043c\u0435\u0442, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e6a\/3f8\/5e0\/e6a3f85e0a78c2ee204022fb5a9bde13.png\" width=\"1626\" height=\"546\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e6a\/3f8\/5e0\/e6a3f85e0a78c2ee204022fb5a9bde13.png\"\/><\/figure>\n<p>\u0418 \u0435\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0447\u0435\u0440\u0435\u0437 30 \u0441\u0435\u043a\u0443\u043d\u0434 Alertmanager \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0432 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/011\/dee\/b84\/011deeb8449e18f2d68b49b0144fa400.png\" width=\"1050\" height=\"165\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/011\/dee\/b84\/011deeb8449e18f2d68b49b0144fa400.png\"\/><\/figure>\n<p>\u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0448\u043b\u0435\u0442 \u0435\u0433\u043e \u043a \u0432\u0430\u043c \u0432 Telegram:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/842\/9cf\/1d2\/8429cf1d22605d46f8592cb0b74a7530.png\" width=\"627\" height=\"625\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/842\/9cf\/1d2\/8429cf1d22605d46f8592cb0b74a7530.png\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451! \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0430\u0441 \u0432 \u0430\u0440\u0441\u0435\u043d\u0430\u043b\u0435 \u0435\u0441\u0442\u044c \u0431\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0443\u043a\u0443 \u043d\u0430 \u043f\u0443\u043b\u044c\u0441\u0435 \u0432\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0435\u0433\u043e, \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u0431\u044c\u0435\u0442 \u0442\u0440\u0435\u0432\u043e\u0433\u0443! \u041d\u0443 \u0447\u0442\u043e, \u0432\u044b \u0432\u0435\u0434\u044c \u0442\u043e\u0436\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0435 \u044d\u0442\u043e\u0442 \u0430\u0440\u043e\u043c\u0430\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439?<\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043c\u0430\u043d\u0438\u044f, \u044d\u0442\u043e \u0437\u0430\u0431\u043e\u0442\u0430. \u041d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0439\u0442\u0435\u0441\u044c \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043e\u043c, \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0440\u0430\u0441\u0442\u0435\u043d\u0438\u044f \u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b.<\/p>\n<\/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\/763390\/\"> https:\/\/habr.com\/ru\/articles\/763390\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432? \u0412\u044b\u0434\u0430\u043d \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u2013 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u0435\u0433\u043e \u0441\u0440\u043e\u043a\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u041c\u043d\u043e\u0433\u0438\u0435 \u043f\u043e \u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0438, \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f, \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u043c\u0435\u0442\u043a\u0438. \u041d\u043e \u0440\u0443\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0435\u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b, \u0432\u0435\u0434\u044c \u043b\u044e\u0434\u0438 \u043e\u0448\u0438\u0431\u0430\u044e\u0442\u0441\u044f, \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442 \u0438 \u0442\u0435\u0440\u044f\u044e\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. <\/p>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u043d\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u0442\u043e \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0438\u0437-\u0437\u0430 \u043f\u0440\u043e\u0442\u0443\u0445\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443. <\/p>\n<h2>\u0413\u043b\u0443\u0431\u0436\u0435 \u0432 \u0442\u0435\u0445\u043d\u0438\u043a\u0443: Grafana, Prometheus \u0438 \u043d\u0430\u0448\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u044b<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c Grafana \u0438 Prometheus &#8212; \u044d\u0442\u043e \u043d\u0430\u0448\u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430. \u0417\u0430\u0442\u0435\u043c \u043f\u043e\u0431\u043e\u043b\u0442\u0430\u0435\u043c \u043e\u0431 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u0430\u0445 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u0440\u0443\u0442\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c\u043a\u0443 \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u043c\u0438. \u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043d\u0430\u0443\u0447\u0438\u043c Alertmanager \u0441\u043b\u0430\u0442\u044c \u043d\u0430\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 Telegram.<\/p>\n<h4>1. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u0441\u043d\u043e\u0432: Grafana + Prometheus \u0438 Docker Compose<\/h4>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0432 \u0442\u0435\u043c\u0435 \u0438 \u0443\u0436\u0435 \u0442\u044b\u0441\u044f\u0447\u0443 \u0440\u0430\u0437 <a href=\"https:\/\/github.com\/docker\/awesome-compose\/tree\/master\/prometheus-grafana\" rel=\"noopener noreferrer nofollow\">\u0441\u043b\u044b\u0448\u0430\u043b \u043e awesome-compose\/prometheus-grafana<\/a>, \u0448\u0430\u0433 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 &#8212; \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f <code>compose.yml<\/code> \u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"yaml\">services:   prometheus:     image: prom\/prometheus     container_name: prometheus     command:       - \"--config.file=\/etc\/prometheus\/prometheus_config.yml\"     ports:       - 9090:9090     restart: unless-stopped     volumes:       - .\/prometheus:\/etc\/prometheus       - prom_data:\/prometheus   grafana:     image: grafana\/grafana     container_name: grafana     ports:       - 3000:3000     restart: unless-stopped     env_file: .env     environment:       - GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER}       - GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD}     volumes:       - .\/grafana:\/etc\/grafana\/provisioning\/datasources volumes:   prom_data:<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <code>prometheus<\/code> \u0441 \u0444\u0430\u0439\u043b\u043e\u043c <code>prometheus_config.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">global:   scrape_interval: 15s   scrape_timeout: 10s   evaluation_interval: 15s<\/code><\/pre>\n<p>\u0418 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>grafana<\/code> \u0438 \u0444\u0430\u0439\u043b\u0430 <code>datasource.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">apiVersion: 1  datasources:   - name: Prometheus     type: prometheus     url: http:\/\/prometheus:9090     isDefault: true     access: proxy     editable: true<\/code><\/pre>\n<blockquote>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442\u044b \u0432 \u0444\u0430\u0439\u043b\u0435: <code>.env<\/code>. \u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u0442\u0430\u043a \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0448\u0438\u0444\u0440\u0443\u0439\u0442\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e.<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>.env<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>\u0418\u041c\u042f_\u041f\u041e\u041b\u042c\u0417\u041e\u0412\u0410\u0422\u0415\u041b\u042f_GRAFANA<\/code> \u0438 <code>\u041f\u0410\u0420\u041e\u041b\u042c_\u041f\u041e\u041b\u042c\u0417\u041e\u0412\u0410\u0422\u0415\u041b\u042f_GRAFANA<\/code>:<\/p>\n<pre><code>GF_SECURITY_ADMIN_USER=&lt;\u0418\u041c\u042f_\u041f\u041e\u041b\u042c\u0417\u041e\u0412\u0410\u0422\u0415\u041b\u042f_GRAFANA> GF_SECURITY_ADMIN_PASSWORD=&lt;\u041f\u0410\u0420\u041e\u041b\u042c_\u041f\u041e\u041b\u042c\u0417\u041e\u0412\u0410\u0422\u0415\u041b\u042f_GRAFANA><\/code><\/pre>\n<p>\u041f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u0432\u0441\u044e \u044d\u0442\u0443 \u043a\u0440\u0430\u0441\u043e\u0442\u0443:<\/p>\n<pre><code class=\"bash\">docker-compose up -d<\/code><\/pre>\n<p>\u0422\u0430\u043a, \u043c\u0430\u0433\u0438\u044f Docker \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430, \u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c <a href=\"https:\/\/http:localhost:3000\" rel=\"noopener noreferrer nofollow\">Grafana \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 3000<\/a> \u0438 <a href=\"http:\/\/localhost:9090\" rel=\"noopener noreferrer nofollow\">Prometheus \u043d\u0430 9090<\/a>. \u041f\u0440\u043e\u0441\u0442\u043e? \u041f\u0440\u043e\u0441\u0442\u043e!<\/p>\n<h4>2. \u041f\u043e\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u0441\u044f \u0432 \u043c\u0438\u0440 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u043e\u0432: \u0432\u044b\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430<\/h4>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b. \u0412\u0435\u0434\u044c \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u043a\u0430\u0436\u0434\u0430\u044f \u043a\u0438\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0430 <br \/>\u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u0445\u043e\u043b\u0441\u0442\u0435. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043b\u044f \u0432\u0430\u0441:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\" rel=\"noopener noreferrer nofollow\">ssl_exporter: \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0438 \u0442\u043e\u043b\u044c\u043a\u043e<\/a>. \u0414\u0430\u0435\u0442 \u0431\u043e\u0433\u0430\u0442\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u0445: \u0434\u0430\u0442\u044b \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438: TCP, HTTPS, SMTP \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041d\u043e \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 SSL\/TLS, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/prometheus\/blackbox_exporter\" rel=\"noopener noreferrer nofollow\">blackbox_exporter: \u0443\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0435<\/a>, \u043e\u043d \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b. \u0415\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\" rel=\"noopener noreferrer nofollow\">ssl_exporter<\/a>, \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0430\u0431\u0435\u0435. \u0418\u0437\u0431\u044b\u0442\u043e\u0447\u0435\u043d, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432, \u043d\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/amimof\/node-cert-exporter\" rel=\"noopener noreferrer nofollow\">node-cert-exporter: \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u043d\u0430 \u0434\u0438\u0441\u043a\u0435<\/a>, \u044d\u0442\u043e \u0432\u0430\u0448 \u0432\u044b\u0431\u043e\u0440. \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439. <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/enix\/x509-certificate-exporter\" rel=\"noopener noreferrer nofollow\">x509-certificate-exporter: \u0434\u0430\u0435\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u0445<\/a>. \u0413\u0438\u0431\u043a\u0438\u0439, \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u043b\u0438 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432 Kubernetes. \u0421\u043b\u043e\u0436\u043d\u0435\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/joe-elliott\/cert-exporter\" rel=\"noopener noreferrer nofollow\">cert_exporter: \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432<\/a>, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, Kubernetes \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u0412\u0435\u0441\u044c\u043c\u0430 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c? \u0412\u044b\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u2013 \u044d\u0442\u043e \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u043e, \u0438, \u043a\u0430\u043a \u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435, \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0438 \u0438 \u043d\u044e\u0430\u043d\u0441\u044b. \u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0430\u0448\u0438\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044f\u043c \u0438 \u043d\u0435 \u0431\u043e\u0439\u0442\u0435\u0441\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h4>3. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 ssl_exporter<\/h4>\n<p>\u041c\u044b \u0443\u0436\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 ssl_exporter. \u0421\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u0445\u043e\u0440\u043e\u0448\u043e <br \/>\u0438 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 <code>compose.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">ssl_exporter:   image: ribbybibby\/ssl-exporter   ports:     - \"9219:9219\"<\/code><\/pre>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430\u0448\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u0431\u0443\u0434\u0435\u0442 <code>prometheus.io<\/code>. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <code>scrape_configs<\/code> \u0432 <code>prometheus_config.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">scrape_configs:   - job_name: \"ssl-exporter\"     metrics_path: \/probe     static_configs:       - targets:           - prometheus.io:443     relabel_configs:       - source_labels: [__address__]         target_label: __param_target       - source_labels: [__param_target]         target_label: instance       - target_label: __address__         replacement: ssl_exporter:9219<\/code><\/pre>\n<p>\u0422\u0430\u043a, \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 <code>compose.yml<\/code>:<\/p>\n<pre><code class=\"bash\">docker-compose restart<\/code><\/pre>\n<p>\u0412 <a href=\"http:\/\/localhost:9090\/graph?g0.expr=ssl_probe_success&amp;g0.tab=1&amp;g0.stacked=0&amp;g0.show_exemplars=0&amp;g0.range_input=1h\" rel=\"noopener noreferrer nofollow\">Prometheus \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c PromQL \u0437\u0430\u043f\u0440\u043e\u0441<\/a> \u2013 <code>ssl_probe_success<\/code> \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435, \u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0432\u0441\u0435 \u0432\u0435\u0440\u043d\u043e:<\/p>\n<pre><code>ssl_probe_success{instance=\"prometheus.io:443\",\u00a0job=\"ssl-exporter\"}<\/code><\/pre>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 TCP-\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0446\u0435\u043b\u044c\u044e. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u044d\u0442\u043e\u0433\u043e \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 http, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u043e\u0434\u0443\u043b\u044c <code>https<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>file<\/code> \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435:<\/p>\n<pre><code class=\"yaml\">scrape_configs:   - job_name: \"ssl-files\"     metrics_path: \/probe     params:       module: [\"file\"]       target: [\"\/etc\/ssl\/cert.pem\"]     kubernetes_sd_configs:       - role: node     relabel_configs:       - source_labels: [__address__]         regex: ^(.*):(.*)$         target_label: __address__         replacement: ${1}:9219<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043b\u043e\u0431-\u043f\u043e\u0438\u0441\u043a, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code class=\"yaml\">scrape_configs:   - job_name: \"ssl-files\"     metrics_path: \/probe     params:       module: [\"file\"]       target: [\"\/etc\/ssl\/**\/*.pem\"]     kubernetes_sd_configs:       - role: node     relabel_configs:       - source_labels: [__address__]         regex: ^(.*):(.*)$         target_label: __address__         replacement: ${1}:9219<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 Kubernetes, \u0432 <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\/tree\/master#configuration-file\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<h4>4. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u043d\u0435\u043b\u044c \u0432 Grafana<\/h4>\n<p>\u0412\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\/blob\/master\/contrib\/grafana\/dashboard.json\" rel=\"noopener noreferrer nofollow\">\u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043f\u0430\u043d\u0435\u043b\u044c \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f ssl_exporter<\/a>:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0412 \u043f\u0430\u043d\u0435\u043b\u0438 <em>SSL Certificates<\/em> \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435: \u0435\u0433\u043e \u0438\u043c\u044f, \u0438\u043d\u0441\u0442\u0430\u043d\u0441, \u0438\u043c\u044f \u044d\u043c\u0438\u0442\u0435\u043d\u0442\u0430, \u0432\u044b\u0434\u0430\u0432\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0438 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438. \u042d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\/tree\/master#metrics\" rel=\"noopener noreferrer nofollow\">\u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043c\u0435\u0442\u0440\u0438\u043a<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u043d\u0435\u043b\u044c \u043f\u043e\u0434 \u043b\u044e\u0431\u044b\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438.<\/figcaption><\/div>\n<\/figure>\n<h2>\u041a\u0430\u043a \u043d\u0435 \u043f\u0440\u043e\u0441\u043f\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>\u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u043f\u043b\u0430\u043d\u0430\u0445? \u041f\u043e\u0434\u043d\u0438\u043c\u0435\u043c \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0430 Flask&#8217;\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0432\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e\u0442 Alertmanager \u0438 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u0442\u044c \u0438\u0445 \u0432 Telegram. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u043e\u0442 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c Alertmanager \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439.<\/p>\n<h4>1. \u0412\u0437\u043b\u0435\u0442\u0430\u0435\u043c \u0441 Flask<\/h4>\n<p>\u041b\u0430\u0434\u043d\u043e, \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043c\u0435\u043b\u043e\u0447\u0438\u0442\u044c\u0441\u044f, \u0437\u0430\u0432\u043e\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <code>telegram<\/code> \u0438 \u043a\u0438\u0434\u0430\u0435\u043c \u0442\u0443\u0434\u0430 \u0444\u0430\u0439\u043b\u0438\u043a <code>app.py<\/code> \u0441 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u043c, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u043c \u0438 \u0432 \u0441\u0442\u0438\u043b\u0435 true pythonista \u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"python\">import os import requests  from flask import Flask, request, jsonify  app = Flask(__name__)  TELEGRAM_TOKEN = os.environ[\"TELEGRAM_TOKEN\"] CHAT_ID = os.environ[\"TELEGRAM_CHAT_ID\"] TELEGRAM_URL = f\"https:\/\/api.telegram.org\/bot{TELEGRAM_TOKEN}\/sendMessage\"   @app.route(\"\/alert\", methods=[\"POST\"]) def webhook():     data = request.json     alertname = data[\"alerts\"][0][\"labels\"][\"alertname\"]     instance = data[\"alerts\"][0][\"labels\"][\"instance\"]     summary = data[\"alerts\"][0][\"annotations\"][\"summary\"]     text = f\"\u26a0\ufe0f Alarm! {alertname} for {instance}. \\n{summary}\"     payload = {\"chat_id\": CHAT_ID, \"text\": text}     response = requests.post(TELEGRAM_URL, data=payload)     return jsonify(status=\"success\"), 200   if __name__ == \"__main__\":     app.run(host=\"0.0.0.0\", port=8000)<\/code><\/pre>\n<p>\u0410 \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f <code>Dockerfile<\/code>:<\/p>\n<pre><code class=\"bash\">FROM python:3.10-alpine WORKDIR \/app COPY . \/app RUN pip3 install -r requirements.txt ENTRYPOINT [\"python3\"] CMD [\"app.py\"]<\/code><\/pre>\n<p>\u041d\u0443 \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u044b\u0439 <code>requirements.txt<\/code>:<\/p>\n<pre><code>flask requests<\/code><\/pre>\n<h4>2. \u041a\u0440\u0430\u0444\u0442\u0438\u043c \u0431\u043e\u0442\u0430:<\/h4>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c <code>@BotFather<\/code> \u0432 Telegram.<\/p>\n<\/li>\n<li>\n<p><code>\/newbot<\/code>, \u0434\u0430\u0435\u043c \u0435\u043c\u0443 \u0438\u043c\u044f \u0438 \u0432\u0443\u0430\u043b\u044f! \u0423 \u0432\u0430\u0441 \u0432 \u0440\u0443\u043a\u0430\u0445: <code>\u0422\u041e\u041a\u0415\u041d_\u0411\u041e\u0422\u0410<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u044f\u0441\u043d\u0438\u043c \u0441\u0432\u043e\u0439 chat_id, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0432 <code>\/start<\/code> \u0441\u0432\u043e\u0435\u043c\u0443 \u0431\u043e\u0442\u0443 \u0438 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 <code>https:\/\/api.telegram.org\/bot&lt;\u0422\u041e\u041a\u0415\u041d_\u0411\u041e\u0422\u0410>\/getUpdates<\/code>. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 <code>result[0]message.chat.id<\/code> \u0438 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0448 <code>\u0412\u0410\u0428_\u0427\u0410\u0422_ID<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432 <code>compose.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">telegram:   build:     context: telegram   stop_signal: SIGINT   env_file: .env   environment:     - TELEGRAM_TOKEN=${TELEGRAM_TOKEN}     - TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID}   ports:     - \"8000:8000\"<\/code><\/pre>\n<p>\u0410 \u0441\u0435\u043a\u0440\u0435\u0442\u044b <code>\u0422\u041e\u041a\u0415\u041d_\u0411\u041e\u0422\u0410<\/code> \u0438 <code>\u0412\u0410\u0428_\u0427\u0410\u0422_ID <\/code>\u0432  <code>.env<\/code> :<\/p>\n<pre><code>TELEGRAM_TOKEN=&lt;\u0422\u041e\u041a\u0415\u041d_\u0411\u041e\u0422\u0410> TELEGRAM_CHAT_ID=&lt;\u0412\u0410\u0428_\u0427\u0410\u0422_ID><\/code><\/pre>\n<h4>3. \u0414\u0440\u0443\u0436\u0438\u043c Alertmanager \u0441 Telegram<\/h4>\n<p>\u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0443\u0434\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u043b\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 Alertmanager <a href=\"https:\/\/prometheus.io\/docs\/alerting\/latest\/configuration\/#receiver-integration-settings\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043a\u0443\u0434\u0430 \u0443\u0433\u043e\u0434\u043d\u043e<\/a>, \u043d\u043e \u043c\u044b-\u0442\u043e \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e <a href=\"https:\/\/prometheus.io\/docs\/alerting\/latest\/configuration\/#telegram_config\" rel=\"noopener noreferrer nofollow\">\u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0430\u0448 \u0432\u044b\u0431\u043e\u0440 \u2013 Telegram<\/a>.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u0430\u043b\u043e\u0433\u043e. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 90 \u0434\u043d\u0435\u0439 \u0436\u0438\u0437\u043d\u0438. \u0414\u043b\u044f \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f &#8212; \u0432 <a href=\"https:\/\/github.com\/ribbybibby\/ssl_exporter\/tree\/master#example-queries\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0440\u0430\u0437\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b<\/a>. \u0412 <code>prometheus<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <code>alert.rules.yml<\/code> \u0438 \u043f\u0438\u0448\u0435\u043c \u0442\u0443\u0434\u0430:<\/p>\n<pre><code class=\"yaml\">groups:   - name: ssl-alerts     rules:       - alert: Expiry Soon         expr: ssl_cert_not_after - time() &lt; 86400 * 90         for: 1m         labels:           severity: critical         annotations:           summary: \"SSL certificate is expiring soon (less than 90 days)\"<\/code><\/pre>\n<p>\u0414\u043e\u043f\u0438\u0448\u0435\u043c \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u043e\u043a \u0432 <code>prometheus_config.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">rule_files:   - \"\/etc\/prometheus\/alert.rules.yml\" alerting:   alertmanagers:     - static_configs:         - targets:             - \"alertmanager:9093\"<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>alertmanager<\/code> \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0432 \u043d\u0435\u0435 \u0444\u0430\u0439\u043b <code>alertmanager_config.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">route:   group_by: [\"instance\"]   repeat_interval: 3h   receiver: \"telegram-webhook\"  receivers:   - name: \"telegram-webhook\"     webhook_configs:       - url: \"http:\/\/telegram:8000\/alert\"<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0436, \u043d\u0430\u0448 <code>compose.yml<\/code> \u0442\u043e\u0436\u0435 \u0445\u043e\u0447\u0435\u0442 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 <code>alertmanager<\/code>:<\/p>\n<pre><code class=\"yaml\">alertmanager:   image: quay.io\/prometheus\/alertmanager   container_name: alertmanager   command:     -<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-355819","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355819","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=355819"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355819\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}