{"id":369080,"date":"2024-05-21T03:55:59","date_gmt":"2024-05-21T03:55:59","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=369080"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=369080","title":{"rendered":"<span>Ansible + Grafana Loki: \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0432 \u0447\u0430\u0442 \u043f\u043e\u0441\u043b\u0435 \u043b\u043e\u0433\u0438\u043d\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e SSH<\/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<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043b\u0438 \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0430\u0434 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0445\u043e\u0434\u0435 \u043d\u0430 \u0432\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430? \u041c\u0435\u043d\u044f \u043e\u0445\u0432\u0430\u0442\u0438\u043b\u0430 \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043f\u0430\u0440\u0430\u043d\u043e\u0439\u044f: \u0430 \u0432\u0434\u0440\u0443\u0433, \u043a\u043e\u0433\u0434\u0430 \u044f \u0441\u043f\u043b\u044e, \u043d\u0430 \u043c\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u043c\u043e\u0432\u043e\u0439 \u0438 \u0442\u0432\u043e\u0440\u0438\u0442 \u0442\u0430\u043c \u0443\u0436\u0430\u0441\u044b? \u0425\u043e\u0442\u044f \u043b\u043e\u0433\u0438\u043d \u043d\u0430 \u043d\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e, \u0430 SSH-\u043a\u043b\u044e\u0447\u0438 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043c\u0435\u043d\u044f, \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u043f\u0430\u0441\u0435\u043d\u0438\u044f. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0435\u043c \u0447\u0435\u0440\u0435\u0437 Terraform \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0432 Yandex.Cloud, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Ansible \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0441\u043e\u0444\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0423 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442 Loki (\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432) \u0438 Grafana (\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445), \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d Promtail (\u0430\u0433\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043b\u043e\u0433\u043e\u0432). \u041c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 \u0447\u0430\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Grafana \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0432 \u043a \u0432\u0430\u0448\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c Node-Exporter(-s)+Prometheus \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432.<\/p>\n<blockquote>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442 &#171;\u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b&#187;, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0439 \u0432\u0430\u043c \u0448\u0430\u0433.<\/p>\n<\/blockquote>\n<h3>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h3>\n<ul>\n<li>\n<p><a href=\"#p1\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0437\u0432\u043e\u0440\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p2\" rel=\"noopener noreferrer nofollow\">\u0414\u0435\u043f\u043b\u043e\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0447\u0435\u0440\u0435\u0437 Ansible<\/a><\/p>\n<ul>\n<li>\n<p><a href=\"#p3\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Ansible \u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p4\" rel=\"noopener noreferrer nofollow\">\u0414\u0435\u043f\u043b\u043e\u0438\u043c Loki<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p5\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c Grafana<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p6\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Firewall<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p7\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c Promtail<\/a><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"#p8\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438<\/a><\/p>\n<ul>\n<li>\n<p><a href=\"#p9\" rel=\"noopener noreferrer nofollow\">\/var\/log\/auth.log<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p10\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Telegram<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p11\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 Grafana Alerting<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p12\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c Loki query<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p13\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0430\u043b\u0435\u0440\u0442\u044b<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p14\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u043b\u0435\u0440\u0442\u044b<\/a><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"#p15\" rel=\"noopener noreferrer nofollow\">\u041e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434<\/a><\/p>\n<\/li>\n<\/ul>\n<p><a class=\"anchor\" name=\"p1\" id=\"p1\"><\/a><\/p>\n<h2>\u0420\u0430\u0437\u0432\u043e\u0440\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443<\/h2>\n<p>\u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0430\u0434\u043e \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u0421 \u044d\u0442\u0438\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 Terraform. <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 \u0441 \u0440\u043e\u043b\u044c\u044e <code>admin<\/code> \u043d\u0430 \u0432\u0441\u0451 \u043e\u0431\u043b\u0430\u043a\u043e:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/df1\/d97\/2d0\/df1d972d0244ff351ca9b1621819ec73.png\" width=\"900\" height=\"431\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/df1\/d97\/2d0\/df1d972d0244ff351ca9b1621819ec73.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u0447\u0442\u043e\u0431\u044b Terraform \u043c\u043e\u0433 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e82\/fa1\/054\/e82fa1054bbdee2d8e1510270b08e68c.png\" width=\"1532\" height=\"750\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e82\/fa1\/054\/e82fa1054bbdee2d8e1510270b08e68c.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0441\u043a\u0430\u0447\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON.<\/p>\n<p>\u0417\u0430\u0439\u0434\u0435\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u043b\u0430\u043a\u0443 \u0432 yc. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u044c. \u041f\u0440\u043e\u0444\u0438\u043b\u0438 \u0441\u043b\u0443\u0436\u0430\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u043b\u0430\u043a\u0430\u043c \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0438\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e:<\/p>\n<pre><code class=\"bash\">$ yc config profiles create yc-compute-logs Profile 'yc-compute-logs' created and activated<\/code><\/pre>\n<p>\u041d\u0430\u0437\u043d\u0430\u0447\u0438\u043c service-account-key (\u043f\u0443\u0442\u044c \u0434\u043e authorized-key.json, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435), cloud-id \u0438 folder-id:<\/p>\n<pre><code class=\"bash\">$ yc config set cloud-id &lt;your_cloud_id> $ yc config set folder-id &lt;your_folder_id> $ yc config set service-account-key &lt;your_path_to_authorized_key><\/code><\/pre>\n<p>\u0423\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u043b\u0430\u043a\u0443 \u0432 yc \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"bash\">$ yc iam service-account list +----------------------+-----------+ |          ID          |   NAME    | +----------------------+-----------+ | ajevk0p06h138i651oje | terraform | +----------------------+-----------+ <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e SSH \u043a\u043b\u044e\u0447\u0435\u0439 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0438\u043c:<\/p>\n<pre><code class=\"bash\">ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" -f ~\/.ssh\/habr-logs\/grafana ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" -f ~\/.ssh\/habr-logs\/node1 ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" -f ~\/.ssh\/habr-logs\/node2 ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" -f ~\/.ssh\/habr-logs\/node3<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <code>terraform<\/code>, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c set_env.sh \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c terraform plan:<\/p>\n<pre><code class=\"bash\">$ git clone git@github.com:AzamatKomaev\/habr-terraform-ansible-logs.git $ cd .\/habr-terraform-ansible-logs\/terraform $ . .\/set_env.sh You are using yc-compute-logs! Profile 'yc-compute-logs' activated $ Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:   + create  Terraform will perform the following actions: &lt;output was hidden> Plan: 12 to add, 0 to change, 0 to destroy.  Changes to Outputs:   + grafana_ip_address = (known after apply)   + node1_ip_address   = (known after apply)   + node2_ip_address   = (known after apply)   + node3_ip_address   = (known after apply)<\/code><\/pre>\n<p>Terraform \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0430\u043c \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b terraform apply. \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u0421\u0435\u0442\u044c default, \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0432 \u0437\u043e\u043d\u0435 ru-central1-a<\/p>\n<\/li>\n<li>\n<p>4 \u0434\u0438\u0441\u043a\u0430 (10\u0413\u0411, SSD)<\/p>\n<\/li>\n<li>\n<p>4 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d (5% CPU code fraction, 2 CPU cores, 2 RAM)<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c terraform apply. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043e\u0431\u043b\u0430\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/acc\/7f3\/22b\/acc7f322b4798d9a215cc7f87d17f34f.png\" width=\"1848\" height=\"497\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/acc\/7f3\/22b\/acc7f322b4798d9a215cc7f87d17f34f.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c\u0441\u044f IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432:<\/p>\n<pre><code class=\"bash\">Apply complete! Resources: 12 added, 0 changed, 0 destroyed.  Outputs:  grafana_ip_address = \"158.160.43.15\" node1_ip_address = \"51.250.71.111\" node2_ip_address = \"158.160.110.84\" node3_ip_address = \"158.160.100.121\"<\/code><\/pre>\n<p>\u041e\u043d\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<\/p>\n<p><a class=\"anchor\" name=\"p2\" id=\"p2\"><\/a><\/p>\n<h2>\u0414\u0435\u043f\u043b\u043e\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0447\u0435\u0440\u0435\u0437 Ansible<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u044d\u0441\u0442\u0430\u0444\u0435\u0442\u0443 Ansible. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445. \u041c\u0435\u043d\u044c\u0448\u0435 \u0441\u043b\u043e\u0432, \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438: \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044e Grafana \u0438 Loki!<\/p>\n<p>Grafana &#8212; \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Grafana \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u044b \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439, \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 \u0447\u0430\u0442 \u0438\u043b\u0438 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443.  Loki &#8212; \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f Grafana. \u041e\u0431\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3b1\/d2d\/672\/3b1d2d672dbc6df5ad8b0016e03abac1.png\" width=\"1200\" height=\"372\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3b1\/d2d\/672\/3b1d2d672dbc6df5ad8b0016e03abac1.png\"\/><\/figure>\n<p>\u0420\u043e\u043b\u044c \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c Promtail, \u0435\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 node1, node2 \u0438 node3. Promtail \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0432 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 Loki. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043b\u043e\u0433\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Grafana. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0443 Grafana \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0430\u043b\u0435\u0440\u0442\u044b \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e?<\/p>\n<p><a class=\"anchor\" name=\"p3\" id=\"p3\"><\/a><\/p>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Ansible \u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Ansible \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438, \u044f \u0432\u044b\u0431\u0440\u0430\u043b pip:<\/p>\n<pre><code class=\"bash\">$ python3 -m pip install --user ansible<\/code><\/pre>\n<blockquote>\n<p>\u0425\u043e\u0442\u044f Ansible \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f &#171;agentless&#187; (\u0432\u0430\u043c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0430\u0433\u0435\u043d\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0412\u041c), \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 python \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435. <\/p>\n<\/blockquote>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438\u0437 GitHub, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0448\u0430\u0433 \u0441 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0412\u041c \u0432 Yandex.Cloud, \u0442\u043e \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0439\u0442\u0435 \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e ansible:<\/p>\n<pre><code>$ git clone git@github.com:AzamatKomaev\/habr-terraform-ansible-logs.git $ cd .\/habr-terraform-ansible-logs\/ansible<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 <em>inventory.ini<\/em>. \u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 Ansible \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0430\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0414\u043b\u044f \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e. \u0412 \u0444\u0430\u0439\u043b\u0435 \u044f \u0443\u043a\u0430\u0437\u0430\u043b IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u043c\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0438\u0445 \u043d\u0430 \u0432\u0430\u0448\u0438:<\/p>\n<details class=\"spoiler\">\n<summary>inventory.ini<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>[grafana] 158.160.43.15    ansible_user=admin   [nodes] 51.250.71.111    ansible_user=admin logging_label=node1 158.160.110.84   ansible_user=admin logging_label=node2 158.160.100.121  ansible_user=admin logging_label=node3<\/code><\/pre>\n<p><em>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ansible_user \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/em><\/p>\n<p><em>logging_level  <\/em>\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043e\u043d\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c. \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c ping:<\/p>\n<pre><code class=\"bash\">$ ansible -m ping all -i .\/inventory.ini<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Output<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">158.160.43.15 | SUCCESS => {     \"ansible_facts\": {         \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"     },     \"changed\": false,     \"ping\": \"pong\" } 51.250.71.111 | SUCCESS => {     \"ansible_facts\": {         \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"     },     \"changed\": false,     \"ping\": \"pong\" } 158.160.100.121 | SUCCESS => {     \"ansible_facts\": {         \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"     },     \"changed\": false,     \"ping\": \"pong\" } 158.160.110.84 | SUCCESS => {     \"ansible_facts\": {         \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"     },     \"changed\": false,     \"ping\": \"pong\" }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0451 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435! \u0418\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435&#8230;<\/p>\n<p>\u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 ansible \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e YAML \u0444\u0430\u0439\u043b\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 Ansible Playbook &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Ansible \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0451\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.  <\/p>\n<p>\u041e\u0434\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u043e\u0434\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0414\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f. \u041c\u043e\u0434\u0443\u043b\u044c &#8212; \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0430\u044f\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/index_module.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Ansible<\/a>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 ansible.builtin.*, \u0438\u0445 \u0445\u0432\u0430\u0442\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0430\u043b\u0438\u0441\u0430\u0441\u044b.<\/p>\n<p><a class=\"anchor\" name=\"p4\" id=\"p4\"><\/a><\/p>\n<h4>\u0414\u0435\u043f\u043b\u043e\u0438\u043c Loki<\/h4>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Loki. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>loki-installation-playbook.yml<\/code> \u0441 Ansible Playbook, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0437\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a Loki. Loki \u0438 Grafana \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0435\u0440. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u0441\u0435\u0445 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043a \u043d\u0438\u043c \u0431\u0443\u0434\u0443\u0442 \u0441\u043f\u0440\u044f\u0442\u0430\u043d\u044b \u0432 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>loki-installation-playbook.yml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">- name: Install Loki   hosts: grafana    tasks:   - name: Install unzip for unpacking archives      apt:       name: unzip     become: true    - name: Install loki using wget and unzip it     shell:       chdir: \/home\/admin       cmd: |         wget https:\/\/github.com\/grafana\/loki\/releases\/download\/v2.9.4\/loki-linux-amd64.zip         unzip \"loki-linux-amd64.zip\"           chmod a+x \"loki-linux-amd64\"         sudo mv .\/loki-linux-amd64 \/usr\/local\/bin\/loki    - name: Install default loki configuration yaml     shell:       chdir: \/home\/admin       cmd: wget https:\/\/raw.githubusercontent.com\/grafana\/loki\/main\/cmd\/loki\/loki-local-config.yaml    - name: Copy loki.service (unit for systemd) to \/etc\/systemd\/system folder     copy:       src: .\/resources\/loki.service       dest: \/etc\/systemd\/system     become: true    - name: Load loki unit and start it     systemd:       name: loki       state: started       daemon_reload: true       enabled: true      become: true <\/code><\/pre>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 Playbook, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0445\u043e\u0441\u0442\u043e\u0432 \u0438\u0437 inventory.ini \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0438. \u0417\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447. <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u043b\u0435 become \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c true: <em>become: true<\/em><\/p>\n<p><strong>Install unzip for unpacking archives<\/strong>: \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c unzip \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0430\u0440\u0445\u0438\u0432\u0430 \u0441 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u043c loki. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/ansible\/builtin\/apt_module.html#ansible-collections-ansible-builtin-apt-module\" rel=\"noopener noreferrer nofollow\">ansible.builtin.apt<\/a>.<\/p>\n<p><strong>Install loki using wget and unzip it<\/strong>: \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0430\u0440\u0445\u0438\u0432 \u0441 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u043c loki, \u0440\u0430\u0441\u043f\u043e\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0438\u0437 $PATH. \u0422\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/ansible\/builtin\/shell_module.html#ansible-collections-ansible-builtin-shell-module\" rel=\"noopener noreferrer nofollow\">ansible.builtin.shell<\/a>, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u0439 bash \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p><strong>Install default loki configuration yaml: <\/strong>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 loki, \u043d\u0430\u043c \u0445\u0432\u0430\u0442\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p><strong>Copy loki.service (unit for systemd) to \/etc\/systemd\/system folder: <\/strong>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 loki \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f systemd. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>loki.service<\/code> \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u044e\u043d\u0438\u0442\u0430\u043c\u0438. \u0414\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/ansible\/builtin\/copy_module.html#ansible-collections-ansible-builtin-copy-module\" rel=\"noopener noreferrer nofollow\">ansible.builtin.copy<\/a>.<\/p>\n<p><strong>Load loki unit and start it: <\/strong>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044e\u043d\u0438\u0442\u0430 systemd, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e. \u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 systemd \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/ansible\/builtin\/systemd_service_module.html#ansible-collections-ansible-builtin-systemd-service-module\" rel=\"noopener noreferrer nofollow\">ansible.builtin.systemd_service<\/a>.<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c Playbook. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>ansible_playbook<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u0434\u043e inventory.ini, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e \u0441\u0430\u043c\u043e\u0433\u043e playbook:<\/p>\n<pre><code class=\"bash\">$ ansible-playbook -i .\/inventory.ini .\/loki-installation-playbook.yml<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Output<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">PLAY [Install Loki] ***********************************************************************************************************************  TASK [Gathering Facts] ******************************************************************************************************************** ok: [158.160.43.15]  TASK [Install unzip for unpacking archives] *********************************************************************************************** changed: [158.160.43.15]  TASK [Install loki using wget and unzip it] *********************************************************************************************** changed: [158.160.43.15]  TASK [Install default loki configuration yaml] ******************************************************************************************** changed: [158.160.43.15]  TASK [Copy loki.service (unit for systemd) to \/etc\/systemd\/system folder] ***************************************************************** changed: [158.160.43.15]  TASK [Load loki unit and start it] ******************************************************************************************************** changed: [158.160.43.15]  PLAY RECAP ******************************************************************************************************************************** 158.160.43.15              : ok=6    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0440\u043e\u0448\u043b\u043e \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a, \u0442\u043e \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443<code>http:\/\/&lt;grafana_ip_address>:3100\/metrics<\/code>. \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u0440\u0438\u043a:<\/p>\n<pre><code class=\"bash\">$ curl http:\/\/158.160.43.15:3100\/metrics | head -n 10               <\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Output<\/summary>\n<div class=\"spoiler__content\">\n<pre><code># HELP cortex_consul_request_duration_seconds Time spent on consul requests. 0 # TYPE cortex_consul_request_duration_seconds histogram cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.005\"} 2436 cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.01\"} 2436 cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.025\"} 2436 cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.05\"} 2436 cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.1\"} 2436 cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.25\"} 2436 cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.5\"} 2436 cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"1\"} 2436<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>Loki \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e! <\/p>\n<p><a class=\"anchor\" name=\"p5\" id=\"p5\"><\/a><\/p>\n<h3>\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c Grafana<\/h3>\n<p>\u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f Grafana. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0451 deb \u043f\u0430\u043a\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0437 \u0420\u043e\u0441\u0441\u0438\u0438, \u0447\u0435\u043c Loki&#8230; \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f &lt;<span class=\"habrahidden\">\u0414\u044f\u0434\u044f \u041c\u0430\u0439\u043e\u0440, \u043d\u0435 \u043d\u0430\u0434\u043e<\/span>> \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 .deb \u0444\u0430\u0439\u043b \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e resources. \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 GitHub \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 100\u041c\u0411 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0435\u0433\u043e \u0432 .gitignore.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 grafana-installation-playbook.yml:<\/p>\n<details class=\"spoiler\">\n<summary>grafana-installation-playbook.yml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">- name: Install Grafana   hosts: grafana    tasks:   - name: Install musl     apt:       name: musl      become: true    - name: Copy grafana deb package from local     copy:       src: .\/resources\/grafana-enterprise_10.3.3_amd64.deb       dest: \/home\/admin\/    - name: Install Grafana     apt:       deb: \/home\/admin\/grafana-enterprise_10.3.3_amd64.deb     become: true     - name: Make sure a grafana-server is running     systemd_service:       state: started       name: grafana-server     become: true  <\/code><\/pre>\n<p><strong>Install musl: <\/strong>\u0443\u0441\u0442\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f Grafana.<\/p>\n<p><strong>Copy grafana deb package from local: <\/strong>\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c deb \u043f\u0430\u043a\u0435\u0442 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \/home\/admin \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p><strong>Install Grafana: <\/strong>\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 deb \u043f\u0430\u043a\u0435\u0442.<\/p>\n<p><strong>Make sure a grafana-server is running: <\/strong>\u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c systemd \u044e\u043d\u0438\u0442.  <\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Playbook!<\/p>\n<pre><code class=\"bash\">$ ansible-playbook -i .\/inventory.ini .\/grafana-installation-playbook.yml<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Output<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>PLAY [Install Grafana] ********************************************************************************************************************  TASK [Gathering Facts] ******************************************************************************************************************** ok: [158.160.43.15]  TASK [Install musl] *********************************************************************************************************************** changed: [158.160.43.15]  TASK [Copy grafana deb package from local] ************************************************************************************************ changed: [158.160.43.15]  TASK [Install Grafana] ******************************************************************************************************************** changed: [158.160.43.15]  TASK [Make sure a grafana-server is running] ********************************************************************************************** changed: [158.160.43.15]  PLAY RECAP ******************************************************************************************************************************** 158.160.43.15              : ok=5    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443<code>http:\/\/&lt;grafana_ip_address>:3000<\/code>. \u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043f\u043e\u043b\u0435 \u0441 \u043b\u043e\u0433\u0438\u043d\u043e\u043c \u0438 \u043f\u0430\u0440\u043e\u043b\u0435\u043c <code>admin<\/code>. \u0417\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 Connections, \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 Loki \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0435\u0433\u043e:<\/p>\n<details class=\"spoiler\">\n<summary>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 Loki \u0432 Grafana (\u043c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043d\u043e\u0432)<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bb2\/749\/159\/bb27491598796447a4be2de26d6066a3.png\" width=\"988\" height=\"807\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bb2\/749\/159\/bb27491598796447a4be2de26d6066a3.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a58\/053\/c76\/a58053c766fc6edc2aee47daa27e74d4.png\" width=\"682\" height=\"508\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a58\/053\/c76\/a58053c766fc6edc2aee47daa27e74d4.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d65\/ae0\/164\/d65ae01645b091e212811c9f0e7ad985.png\" alt=\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e localhost!\" title=\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e localhost!\" width=\"1908\" height=\"682\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d65\/ae0\/164\/d65ae01645b091e212811c9f0e7ad985.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e localhost!<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d32\/145\/e84\/d32145e849f5d695e933822970b4600d.png\" width=\"1510\" height=\"367\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d32\/145\/e84\/d32145e849f5d695e933822970b4600d.png\"\/><\/figure>\n<p>\u0417\u0430\u0439\u0434\u0435\u043c \u0432 Explore, \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 loki \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/68b\/b86\/da7\/68bb86da74c6b0335d3380353cb2ca11.png\" width=\"730\" height=\"404\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/68b\/b86\/da7\/68bb86da74c6b0335d3380353cb2ca11.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435, \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u0435\u0442\u043e\u043a \u043f\u0443\u0441\u0442. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e Loki \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u043b\u043e\u0433\u0438. \u041f\u043e\u0440\u0430 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0430\u0433\u0435\u043d\u0442\u044b \u043d\u0430 node1, node2 \u0438 node3 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043b\u043e\u0433\u043e\u0432. \u0420\u043e\u043b\u044c \u0430\u0433\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0433\u0440\u0430\u0442\u044c Promtail.<\/p>\n<p><a class=\"anchor\" name=\"p6\" id=\"p6\"><\/a><\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Firewall<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0432 Loki \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043b\u043e\u0433\u0438 \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0441\u0435\u0431\u0435 \u0437\u0430\u0442\u0435\u044f. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f ufw &#8212; \u0431\u0440\u0430\u043d\u0434\u043c\u0430\u0443\u044d\u0440\u043e\u043c \u043d\u0430 Linux. \u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u0441\u0435 \u043f\u043e\u0440\u0442\u044b \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c\u0438. \u041e\u0442\u043a\u0440\u043e\u0435\u043c 22 \u043f\u043e\u0440\u0442 \u0434\u043b\u044f SSH \u0438 3000 \u043f\u043e\u0440\u0442 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a Grafana. \u0420\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a 3100 \u043f\u043e\u0440\u0442\u0443 (Loki) \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0430\u0432\u0438\u043b ufw \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 Playbook:<\/p>\n<details class=\"spoiler\">\n<summary>firewall-setup-playbook.yml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">- name: Set up firewall for grafana server   hosts: grafana    tasks:   - name: Set up firewall via ufw     shell:       cmd: |         sudo ufw allow 22         sudo ufw allow 3000         sudo ufw allow from 10.0.0.0\/8 to any port 3100         sudo ufw --force enable <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Playbook:<\/p>\n<pre><code class=\"bash\">$ ansible-playbook -i .\/inventory.ini .\/firewall-setup-playbook.yml<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Output<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">PLAY [Set up firewall for grafana server] *************************************************************************************************  TASK [Gathering Facts] ******************************************************************************************************************** ok: [158.160.43.15]  TASK [Set up firewall via ufw] ************************************************************************************************************ changed: [158.160.43.15]  PLAY RECAP ******************************************************************************************************************************** 158.160.43.15              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u043e\u0440\u0442\u044b. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>nmap<\/code>:<\/p>\n<pre><code class=\"bash\">$ nmap -Pn 158.160.43.15 Starting Nmap 7.80 ( https:\/\/nmap.org ) at 2024-02-24 19:17 MSK Nmap scan report for 158.160.43.15 Host is up (0.11s latency). Not shown: 998 filtered ports PORT     STATE SERVICE 22\/tcp   open  ssh 3000\/tcp open  ppp<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435, \u043e\u0442\u043a\u0440\u044b\u0442\u044b \u0434\u0432\u0430 \u043f\u043e\u0440\u0442\u0430. \u0427\u0442\u043e \u043d\u0430\u0441\u0447\u0451\u0442 Loki? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0439\u0434\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 node1 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c curl \u0437\u0430\u043f\u0440\u043e\u0441 \u043a Loki:<\/p>\n<pre><code class=\"bash\">$ curl http:\/\/grafana:3100\/metrics | head -n 3 # TYPE cortex_consul_request_duration_seconds histogram cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.005\"} 7796 cortex_consul_request_duration_seconds_bucket{kv_name=\"ingester-ring\",operation=\"CAS loop\",status_code=\"200\",le=\"0.01\"} 7796<\/code><\/pre>\n<p><a class=\"anchor\" name=\"p7\" id=\"p7\"><\/a><\/p>\n<h3>\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c Promtail<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0433\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u043e\u0433\u0438 \u0432 Loki. \u042d\u0442\u0443 \u0440\u043e\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0433\u0440\u0430\u0442\u044c Promtail. \u0415\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0433\u0434\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438. \u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 Loki, \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f Promtail \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f systemd \u044e\u043d\u0438\u0442. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Playbook. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u043d \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0432 inventory.ini IP-\u0430\u0434\u0440\u0435\u0441\u0430\u0445 \u0441 \u0433\u0440\u0443\u043f\u043e\u0439 <code>nodes<\/code>.<\/p>\n<p>\u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f Promtail. \u0412 \u043d\u0451\u043c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0443\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u043e\u0433\u0438 (clients[0].url), \u0430 \u0442\u0430\u043a\u0436\u0435 scrape_config, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437 \/var\/log\/auth.log \u0444\u0430\u0439\u043b\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0432 Loki. \u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438. \u0414\u043e\u0431\u0430\u0432\u0438\u043c <code>node_name<\/code> \u0438 <code>node_ip<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043c\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432 Grafana \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0442\u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u043b\u0435\u0442\u0435\u043b \u043b\u043e\u0433.<\/p>\n<details class=\"spoiler\">\n<summary>promtail-config.yml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">server:   http_listen_port: 9080   grpc_listen_port: 0  positions:   filename: \/tmp\/positions.yaml  clients:   - url: http:\/\/grafana:3100\/loki\/api\/v1\/push  scrape_configs: - job_name: system   static_configs:   - targets:       - localhost     labels:       __path__: \/var\/log\/auth.log       node_name: $NODE_NAME       node_ip: $NODE_IP<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 Playbook:<\/p>\n<details class=\"spoiler\">\n<summary>promtail-installation-playbook.yml <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">- name: Install Promtail   hosts: nodes    tasks:   - name: Install unzip for unpacking archives      apt:       name: unzip     become: true    - name: Install promtail using wget and unzip it     shell:       chdir: \/home\/admin       cmd: |         wget https:\/\/github.com\/grafana\/loki\/releases\/download\/v2.8.8\/promtail-linux-amd64.zip         unzip \"promtail-linux-amd64.zip\"           chmod a+x \"promtail-linux-amd64\"         sudo mv .\/promtail-linux-amd64 \/usr\/local\/bin\/promtail    - name: Copy promtail configuration     copy:       src: .\/resources\/promtail-config.yml       dest: \/home\/admin\/promtail-config.yml.tmp      - name: Set $NODE_NAME in promtail-config.yml     environment:       NODE_NAME: \"{{ logging_label }}\"       NODE_IP: \"{{ ansible_host }}\"     shell:       chdir: \/home\/admin       cmd: envsubst &lt; promtail-config.yml.tmp > promtail-config.yml          - name: Copy promtail.service (unit for systemd) to \/etc\/systemd\/system folder     copy:       src: .\/resources\/promtail.service       dest: \/etc\/systemd\/system     become: true    - name: Load promtail unit and start it     systemd:       name: promtail       state: started       daemon_reload: true       enabled: true      become: true <\/code><\/pre>\n<p><strong>Set $NODE_NAME in promtail-config.yml: <\/strong>\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u043e $NODE_NAME \u0438 $NODE_IP \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0443\u043a\u0430\u0437\u0430\u043d\u044b\u0445 \u0432 inventory.ini<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"bash\">$ ansible-playbook -i .\/inventory.ini .\/promtail-installation-playbook.yml<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Output<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">PLAY [Install Promtail] *******************************************************************************************************************  TASK [Gathering Facts] ******************************************************************************************************************** ok: [51.250.71.111] ok: [158.160.110.84] ok: [158.160.100.121]  TASK [Install unzip for unpacking archives] *********************************************************************************************** changed: [51.250.71.111] changed: [158.160.100.121] changed: [158.160.110.84]  TASK [Install promtail using wget and unzip it] ******************************************************************************************* changed: [158.160.110.84] changed: [158.160.100.121] changed: [51.250.71.111]  TASK [Copy promtail configuration] ******************************************************************************************************** changed: [51.250.71.111] changed: [158.160.100.121] changed: [158.160.110.84]  TASK [Set $NODE_NAME in promtail-config.yml] ********************************************************************************************** changed: [158.160.110.84] changed: [51.250.71.111] changed: [158.160.100.121]  TASK [Copy promtail.service (unit for systemd) to \/etc\/systemd\/system folder] ************************************************************* changed: [158.160.110.84] changed: [51.250.71.111] changed: [158.160.100.121]  TASK [Load promtail unit and start it] **************************************************************************************************** changed: [158.160.100.121] changed: [158.160.110.84] changed: [51.250.71.111]  PLAY RECAP ******************************************************************************************************************************** 158.160.100.121            : ok=7    changed=6    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    158.160.110.84             : ok=7    changed=6    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    51.250.71.111              : ok=7    changed=6    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u0439\u0434\u0435\u043c \u0432 Grafana \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>Explore<\/code> \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code>{node_name=\"node1\", filename=\"\/var\/log\/auth.log\"}<\/code><\/pre>\n<p>\u0412 \u043b\u043e\u0433\u0430\u0445 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b \u0441\u0430\u043c\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441 \u043a\u0430\u043a\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u043e\u0433\u0438 \u0438 \u043a\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/315\/641\/8ca\/3156418ca4805309fd055fd88ee7f013.png\" width=\"1920\" height=\"884\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/315\/641\/8ca\/3156418ca4805309fd055fd88ee7f013.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u043c\u044b \u043f\u0440\u043e\u0449\u0430\u0435\u043c\u0441\u044f \u0441 Ansible, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0430\u043b\u0435\u0440\u0442\u043e\u0432!<\/p>\n<p><a class=\"anchor\" name=\"p8\" id=\"p8\"><\/a><\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438<\/h2>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d \u0432\u0445\u043e\u0434 \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0445\u043e\u0434\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044b \u043f\u043e SSH, \u0445\u043e\u0442\u044f \u043d\u0438\u043a\u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e.<\/p>\n<p><a class=\"anchor\" name=\"p9\" id=\"p9\"><\/a><\/p>\n<h3>\/var\/log\/auth.log<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 \/var\/log\/auth.log. \u0422\u0443\u0442 \u043f\u043e\u043b\u043d\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043d\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code>2024-02-25 10:16:38.858Feb 25 07:03:47 node1 sshd[1139]: Accepted publickey for admin from &lt;client_ip_addr> port 34638 ssh2: RSA SHA256:&lt;hidden_content><\/code><\/pre>\n<p>\u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u043e\u0439\u0442\u0438 \u043d\u0430 node1 \u043f\u043e \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u043e\u0442 Grafana:<\/p>\n<pre><code>$ ssh -i ~\/.ssh\/habr-logs\/grafana admin@&lt;node1_ip_address> admin@51.250.71.111: Permission denied (publickey).<\/code><\/pre>\n<p>\u0412 \u043b\u043e\u0433\u0438 \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>2024-02-25 10:44:32.126Feb 25 07:44:31 node1 sshd[3054]: Connection closed by authenticating user admin &lt;client_ip_add> port 48444 [preauth]<\/code><\/pre>\n<p>\u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u043e IP-\u0430\u0434\u0440\u0435\u0441 \u0438 \u043f\u043e\u0440\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u043d. \u041d\u043e \u0444\u043e\u0440\u043c\u0430\u0442 \u043b\u043e\u0433\u043e\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0430 \u0430\u043b\u0435\u0440\u0442\u0430: \u043e\u0434\u0438\u043d \u0430\u043b\u0435\u0440\u0442 \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0432, \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; \u0434\u043b\u044f \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0445.<\/p>\n<p><a class=\"anchor\" name=\"p10\" id=\"p10\"><\/a><\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Telegram<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438 \u0432 Telegram: \u043a\u0430\u043a \u043f\u043e \u043c\u043d\u0435 \u044d\u0442\u043e \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u043e\u0442\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u043d\u0430\u0448\u0443 \u0433\u0440\u0443\u043f\u043f\u0443:<\/p>\n<details class=\"spoiler\">\n<summary>\u041c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9ce\/512\/24e\/9ce51224e2f754dc6d609b9531fc83c2.png\" alt=\"\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0442\u043e\u043a\u0435\u043d - \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0435\u043d \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 Contact Point\" title=\"\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0442\u043e\u043a\u0435\u043d - \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0435\u043d \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 Contact Point\" width=\"683\" height=\"879\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ce\/512\/24e\/9ce51224e2f754dc6d609b9531fc83c2.png\"\/><\/p>\n<div><figcaption>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0442\u043e\u043a\u0435\u043d &#8212; \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0435\u043d \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 Contact Point<\/figcaption><\/div>\n<\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/218\/082\/2ff\/2180822ff01a92f0f97b1de1ffe4c7f9.png\" alt=\"\u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0431\u043e\u0442 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\" title=\"\u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0431\u043e\u0442 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\" width=\"507\" height=\"622\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/218\/082\/2ff\/2180822ff01a92f0f97b1de1ffe4c7f9.png\"\/><\/p>\n<div><figcaption>\u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0431\u043e\u0442 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c<\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/details>\n<p><a class=\"anchor\" name=\"p11\" id=\"p11\"><\/a><\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 Grafana Alerting<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9c1\/fc9\/a59\/9c1fc9a59b0ab69dc1a845a71073ced0.png\" width=\"1057\" height=\"224\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c1\/fc9\/a59\/9c1fc9a59b0ab69dc1a845a71073ced0.png\"\/><\/figure>\n<blockquote>\n<p>\u042f \u0431\u0443\u0434\u0443 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0447\u0435\u0440\u0435\u0437 GUI. \u0412 <a href=\"https:\/\/github.com\/AzamatKomaev\/habr-terraform-ansible-logs\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a> \u0435\u0441\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f provisioning, \u0432\u044b \u0435\u0451 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e,  \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0440\u0443\u0447\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439: <a href=\"https:\/\/grafana.com\/docs\/grafana\/latest\/administration\/provisioning\" rel=\"noopener noreferrer nofollow\">\u0442\u044b\u043a<\/a>  <\/p>\n<\/blockquote>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 Contact Point-\u043e\u0432. Grafana \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e Contact Point. \u041e\u043d\u0438 \u0441\u043b\u0443\u0436\u0430\u0442 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u0422\u0430\u043a Grafana \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e Contact Point-\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0441\u0441\u0435\u043d\u0434\u0436\u0435\u0440\u043e\u0432 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432,  \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <code>Telegram<\/code><\/p>\n<p>\u0414\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c BOT API Token \u0438 Chat ID. \u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c Chat ID. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0431\u043e\u0442\u0430 \u0432 \u0432\u0430\u0448\u0443 \u0433\u0440\u0443\u043f\u043f\u0443, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0447\u0430\u0442 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"bash\">$ curl https:\/\/api.telegram.org\/bot&lt;bot_api_token>\/getUpdates | jq '.result[-1].message.chat.id' -1002141029691<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c Contact Point \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Alerting. \u041f\u0440\u0435\u0436\u0434\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438:<\/p>\n<pre><code class=\"go\">{{ if gt (len .Alerts) 0 }} {{ range .Alerts }} {{ if .Labels.node_name }} Alertname: {{ .Labels.alertname }} Status: {{ .Labels.status }} Node name: {{ .Labels.node_name }} From: {{ .Labels.client_ip }}:{{ .Labels.client_port }} To: {{ .Labels.user }}@{{ .Labels.node_ip }} {{ else }} {{ range .Labels.SortedPairs }} The name of the label is {{ .Name }}, and the value is {{ .Value }} {{ end }} {{ end }} {{ end }} {{ end }}  <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043c Loki \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0435\u0442\u043a\u0438 client_ip, client_port, status \u0438 user. \u041c\u0435\u0442\u043a\u0438 node_name \u0438 node_ip \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Promtail \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0415\u0441\u043b\u0438 \u0430\u043b\u0435\u0440\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043a\u0443 <code>node_name<\/code>, \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u0432\u0441\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0418\u043d\u0430\u0447\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u043a.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c Contact Point:<\/p>\n<details class=\"spoiler\">\n<summary>\u041c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c49\/420\/0ee\/c494200ee769474eefe0548d00c92ea2.png\" width=\"656\" height=\"536\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c49\/420\/0ee\/c494200ee769474eefe0548d00c92ea2.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c13\/072\/a00\/c13072a004511ee71244b75e15021f8e.png\" width=\"630\" height=\"775\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c13\/072\/a00\/c13072a004511ee71244b75e15021f8e.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0430\u043b\u0435\u0440\u0442:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/77f\/bba\/7df\/77fbba7dfc8582b2458148a239f1136f.png\" width=\"618\" height=\"95\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/77f\/bba\/7df\/77fbba7dfc8582b2458148a239f1136f.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 Notification policy. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c &#171;\u043c\u043e\u0441\u0442\u043e\u043c&#187; \u043c\u0435\u0436\u0434\u0443 \u0430\u043b\u0435\u0440\u0442\u043e\u043c \u0438 Contact-Point-\u043e\u043c. \u0412 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043a\u0438 \u0438 \u043a\u043e\u043d\u0442\u0430\u043a\u0442 \u043f\u043e\u0438\u043d\u0442:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/05a\/30f\/afb\/05a30fafb1a0a35fd6c67adae6ec9231.png\" width=\"820\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/05a\/30f\/afb\/05a30fafb1a0a35fd6c67adae6ec9231.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p><a class=\"anchor\" name=\"p12\" id=\"p12\"><\/a><\/p>\n<h3>\u0421\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c Loki query<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0439\u0434\u0435\u043c \u0432 Explore \u0438 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043b\u043e\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0445\u043e\u0434\u0435 \u043d\u0430 \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre><code>{filename=\"\/var\/log\/auth.log\"} |= `Accepted publickey`<\/code><\/pre>\n<p>\u041d\u043e \u0442\u0430\u043a \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u043b\u043e\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043d\u0435 \u0434\u0430\u0441\u0442 \u0434\u043b\u044f \u0430\u043b\u0435\u0440\u0442\u043e\u0432&#8230; \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>count_over_time<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u043e\u0433\u043e\u0432 \u0437\u0430 \u043e\u043f\u0440\u0451\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438:<\/p>\n<pre><code>(count_over_time({filename=\"\/var\/log\/auth.log\"} |= `Accepted publickey` [1s]))<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0433\u0440\u0430\u0444\u0438\u043a, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043b-\u0432\u043e \u043b\u043e\u0433\u043e\u0432 \u0437\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434. \u0422\u0430\u043a\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043a\u0438 \u0435\u0441\u0442\u044c \u0443 \u043b\u043e\u0433\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9ab\/456\/d26\/9ab456d26fe611effb3b7f7ac908076f.png\" width=\"745\" height=\"90\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ab\/456\/d26\/9ab456d26fe611effb3b7f7ac908076f.png\"\/><\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043c\u0435\u0442\u043a\u0438 \u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. \u041d\u043e \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442&#8230; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0435! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 <code>pattern<\/code>:<\/p>\n<pre><code>(count_over_time({filename=\"\/var\/log\/auth.log\"} |= `Accepted publickey` | pattern `&lt;_> sshd[&lt;_>]: &lt;status> publickey for &lt;user> from &lt;client_ip> port &lt;client_port> &lt;_>` [1s]))<\/code><\/pre>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043c\u0435\u0442\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aef\/0b5\/5d5\/aef0b55d55618fc640e0b30fcb1a6f7c.png\" width=\"1459\" height=\"110\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aef\/0b5\/5d5\/aef0b55d55618fc640e0b30fcb1a6f7c.png\"\/><\/figure>\n<p>\u041f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u043e \u0443\u0434\u0430\u0447\u043d\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438:<\/p>\n<pre><code>count_over_time({filename=\"\/var\/log\/auth.log\"} |= `Connection closed by authenticating` != `root` | pattern `&lt;_> sshd[&lt;_>]: Connection &lt;status> by authenticating user &lt;user> &lt;client_ip> port &lt;client_port> &lt;_>` [1s])<\/code><\/pre>\n<p><a class=\"anchor\" name=\"p13\" id=\"p13\"><\/a><\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0430\u043b\u0435\u0440\u0442\u044b<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0430\u043b\u0435\u0440\u0442\u0430 \u0441 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 Alerting -> Alert Rules \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043b\u0435\u0440\u0442. \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u043f\u043e\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<details class=\"spoiler\">\n<summary>\u041c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/755\/593\/970\/7555939705faa74205c1e1df44a1a934.png\" width=\"1235\" height=\"602\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/755\/593\/970\/7555939705faa74205c1e1df44a1a934.png\"\/><\/figure>\n<p>\u0423\u043a\u0430\u0436\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u0435\u0440\u0442\u0430. \u0417\u0430\u0442\u0435\u043c \u0443\u043a\u0430\u0436\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Loki Query. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0430\u043b\u0435\u0440\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u043b\u043e\u0433\u043e\u0432 \u043f\u0440\u0438\u043b\u0435\u0442\u0435\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043d\u043e\u043b\u044c. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u043d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 <em>Run queries<\/em>, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0451 \u043e\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/487\/2c1\/918\/4872c1918e6625a3e6cea9bd1d8aee13.png\" width=\"696\" height=\"770\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/487\/2c1\/918\/4872c1918e6625a3e6cea9bd1d8aee13.png\"\/><\/figure>\n<p>\u0418\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u043e\u043b\u0434\u0435\u0440, \u0430 \u0442\u0430\u043a\u0436\u0435 Evaluation group. \u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0432\u044b\u0431\u0435\u0440\u0435\u043c 10s. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e Grafana \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0435 10 \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0442\u043e \u043e\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0430\u0442\u0443\u0441 <code>Pending<\/code>. \u0427\u0435\u0440\u0435\u0437 \u0432\u0440\u0435\u043c\u044f, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 &#171;Pending period&#187; \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0430\u0442\u0443\u0441 <code>Firing<\/code> \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 Telegram\/Email\/\u0434\u0440\u0443\u0433\u043e\u0439 Contact Point.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c4\/d93\/716\/6c4d937161e40822296b297fdd6494c4.png\" alt=\"\" title=\"\" width=\"1203\" height=\"420\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c4\/d93\/716\/6c4d937161e40822296b297fdd6494c4.png\"\/><\/figure>\n<p>Summary \u0438 Description \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b &#8212; \u043c\u043e\u0436\u0435\u043c \u0438\u0445 \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c. \u0412 Labels \u0438 Notifications \u0432\u0430\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438. \u041d\u0430\u0436\u043c\u0451\u043c \u043d\u0430 Preview Routing, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u043c\u0443 Contact Point: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/464\/726\/085\/4647260856c892b100cfd1749a7253ea.png\" alt=\"\" title=\"\" width=\"1202\" height=\"840\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/464\/726\/085\/4647260856c892b100cfd1749a7253ea.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u042d\u0442\u043e \u0430\u043b\u0435\u0440\u0442 \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u0432\u0445\u043e\u0434\u043e\u0432. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0442 \u0434\u043b\u044f \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0432 \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043c Loki Query.<\/p>\n<p><a class=\"anchor\" name=\"p14\" id=\"p14\"><\/a><\/p>\n<h3>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u043b\u0435\u0440\u0442\u044b<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c!<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043d \u043f\u043e SSH \u043d\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0430\u043b\u0435\u0440\u0442 \u043f\u0435\u0440\u0451\u0448\u0435\u043b \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 Pending:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/58a\/cd8\/7c6\/58acd87c6e8e4e0a27188158e44f0c33.png\" width=\"1194\" height=\"186\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/58a\/cd8\/7c6\/58acd87c6e8e4e0a27188158e44f0c33.png\"\/><\/figure>\n<p>\u041e\u0436\u0438\u0434\u0430\u0435\u043c 10 \u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0430\u043b\u0435\u0440\u0442 \u043f\u0435\u0440\u0435\u0448\u0451\u043b \u0432 \u0441\u0442\u0430\u0442\u0443\u0441 Alerting:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cfa\/d3d\/ba3\/cfad3dba37d9332ec96f5fefaef97934.png\" width=\"1225\" height=\"195\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cfa\/d3d\/ba3\/cfad3dba37d9332ec96f5fefaef97934.png\"\/><\/figure>\n<p>\u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0438\u0439\u0442\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 Telegram \u0447\u0430\u0442:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bcf\/6ef\/c76\/bcf6efc762ccda1c2beda8c87f4a013d.png\" width=\"395\" height=\"162\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bcf\/6ef\/c76\/bcf6efc762ccda1c2beda8c87f4a013d.png\"\/><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u043d\u0435\u043a\u0442 \u0441\u0440\u0430\u0437\u0443 \u043a \u0434\u0432\u0443\u043c \u0438\u043b\u0438 \u0442\u0440\u0451\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c. \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442 \u0442\u0430\u043a\u043e\u0439 \u0430\u043b\u0435\u0440\u0442:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1fc\/231\/6ad\/1fc2316adf431527b442109fbfe0c52d.png\" width=\"401\" height=\"346\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1fc\/231\/6ad\/1fc2316adf431527b442109fbfe0c52d.png\"\/><\/figure>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0445\u043e\u0434 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u043e\u043c\u0443 SSH-\u043a\u043b\u044e\u0447\u0443:<\/p>\n<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/64b\/7b4\/5da\/64b7b45da8d3b50954d02b9bad1cc688.png\" width=\"399\" height=\"172\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/64b\/7b4\/5da\/64b7b45da8d3b50954d02b9bad1cc688.png\"\/><\/figure>\n<p>\u0412\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p><a class=\"anchor\" name=\"p15\" id=\"p15\"><\/a><\/p>\n<h2>\u041e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434<\/h2>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f! \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c DevOps-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432: \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0438 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 \u0447\u0435\u0440\u0435\u0437 Terraform, \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b Grafana \u0447\u0435\u0440\u0435\u0437 Ansible, \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 Loki, Promtail \u0438 Grafana \u0438 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 Telegram \u0447\u0430\u0442 \u043f\u043e\u0441\u043b\u0435 \u043b\u043e\u0433\u0438\u043d\u0430 \u043f\u043e SSH!  <\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043b\u0451\u0433\u043a\u0438\u0435 \u043f\u0443\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435. \u041d\u043e \u044f \u043e\u043f\u0438\u0440\u0430\u043b\u0441\u044f \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439&#8230;<\/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\/795855\/\"> https:\/\/habr.com\/ru\/articles\/795855\/<\/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<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043b\u0438 \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0430\u0434 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0445\u043e\u0434\u0435 \u043d\u0430 \u0432\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430? \u041c\u0435\u043d\u044f \u043e\u0445\u0432\u0430\u0442\u0438\u043b\u0430 \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043f\u0430\u0440\u0430\u043d\u043e\u0439\u044f: \u0430 \u0432\u0434\u0440\u0443\u0433, \u043a\u043e\u0433\u0434\u0430 \u044f \u0441\u043f\u043b\u044e, \u043d\u0430 \u043c\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u043c\u043e\u0432\u043e\u0439 \u0438 \u0442\u0432\u043e\u0440\u0438\u0442 \u0442\u0430\u043c \u0443\u0436\u0430\u0441\u044b? \u0425\u043e\u0442\u044f \u043b\u043e\u0433\u0438\u043d \u043d\u0430 \u043d\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e, \u0430 SSH-\u043a\u043b\u044e\u0447\u0438 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043c\u0435\u043d\u044f, \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u043f\u0430\u0441\u0435\u043d\u0438\u044f. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0435\u043c \u0447\u0435\u0440\u0435\u0437 Terraform \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0432 Yandex.Cloud, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Ansible \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0441\u043e\u0444\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0423 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442 Loki (\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432) \u0438 Grafana (\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445), \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d Promtail (\u0430\u0433\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043b\u043e\u0433\u043e\u0432). \u041c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 \u0447\u0430\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Grafana \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0432 \u043a \u0432\u0430\u0448\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c Node-Exporter(-s)+Prometheus \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432.<\/p>\n<blockquote>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442 &#171;\u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b&#187;, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0439 \u0432\u0430\u043c \u0448\u0430\u0433.<\/p>\n<\/blockquote>\n<h3>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h3>\n<ul>\n<li>\n<p><a href=\"#p1\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0437\u0432\u043e\u0440\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p2\" rel=\"noopener noreferrer nofollow\">\u0414\u0435\u043f\u043b\u043e\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0447\u0435\u0440\u0435\u0437 Ansible<\/a><\/p>\n<ul>\n<li>\n<p><a href=\"#p3\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Ansible \u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p4\" rel=\"noopener noreferrer nofollow\">\u0414\u0435\u043f\u043b\u043e\u0438\u043c Loki<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p5\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c Grafana<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p6\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Firewall<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p7\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c Promtail<\/a><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"#p8\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0438<\/a><\/p>\n<ul>\n<li>\n<p><a href=\"#p9\" rel=\"noopener noreferrer nofollow\">\/var\/log\/auth.log<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p10\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Telegram<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p11\" rel=\"noopener noreferrer nofollow\">\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 Grafana Alerting<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p12\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c Loki query<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p13\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0430\u043b\u0435\u0440\u0442\u044b<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#p14\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u043b\u0435\u0440\u0442\u044b<\/a><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"#p15\" rel=\"noopener noreferrer nofollow\">\u041e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434<\/a><\/p>\n<\/li>\n<\/ul>\n<p><a class=\"anchor\" name=\"p1\" id=\"p1\"><\/a><\/p>\n<h2>\u0420\u0430\u0437\u0432\u043e\u0440\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443<\/h2>\n<p>\u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0430\u0434\u043e \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u0421 \u044d\u0442\u0438\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 Terraform. <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 \u0441 \u0440\u043e\u043b\u044c\u044e <code>admin<\/code> \u043d\u0430 \u0432\u0441\u0451 \u043e\u0431\u043b\u0430\u043a\u043e:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u0447\u0442\u043e\u0431\u044b Terraform \u043c\u043e\u0433 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0441\u043a\u0430\u0447\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON.<\/p>\n<p>\u0417\u0430\u0439\u0434\u0435\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u043b\u0430\u043a\u0443 \u0432 yc. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u044c. \u041f\u0440\u043e\u0444\u0438\u043b\u0438 \u0441\u043b\u0443\u0436\u0430\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u043b\u0430\u043a\u0430\u043c \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0438\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e:<\/p>\n<pre><code class=\"bash\">$ yc config profiles create yc-compute-logs Profile 'yc-compute-logs' created and activated<\/code><\/pre>\n<p>\u041d\u0430\u0437\u043d\u0430\u0447\u0438\u043c service-account-key (\u043f\u0443\u0442\u044c \u0434\u043e authorized-key.json, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435), cloud-id \u0438 folder-id:<\/p>\n<pre><code class=\"bash\">$ yc config set cloud-id &lt;your_cloud_id> $ yc config set folder-id &lt;your_folder_id> $ yc config set service-account-key &lt;your_path_to_authorized_key><\/code><\/pre>\n<p>\u0423\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u043b\u0430\u043a\u0443 \u0432 yc \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"bash\">$ yc iam service-account list +----------------------+-----------+ |          ID          |   NAME    | +----------------------+-----------+ | ajevk0p06h138i651oje | terraform | +----------------------+-----------+ <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e SSH \u043a\u043b\u044e\u0447\u0435\u0439 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0438\u043c:<\/p>\n<pre><code class=\"bash\">ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" -f ~\/.ssh\/habr-logs\/grafana ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" -f ~\/.ssh\/habr-logs\/node1 ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" -f ~\/.ssh\/habr-logs\/node2 ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" -f ~\/.ssh\/habr-logs\/node3<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <code>terraform<\/code>, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c set_env.sh \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c terraform plan:<\/p>\n<pre><code class=\"bash\">$ git clone git@github.com:AzamatKomaev\/habr-terraform-ansible-logs.git $ cd .\/habr-terraform-ansible-logs\/terraform $ . .\/set_env.sh You are using yc-compute-logs! Profile 'yc-compute-logs' activated $ Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:   + create  Terraform will perform the following actions: &lt;output was hidden> Plan: 12 to add, 0 to change, 0 to destroy.  Changes to Outputs:   + grafana_ip_address = (known after apply)   + node1_ip_address   = (known after apply)   + node2_ip_address   = (known after apply)   + node3_ip_address   = (known after apply)<\/code><\/pre>\n<p>Terraform \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0430\u043c \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b terraform apply. \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u0421\u0435\u0442\u044c default, \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0432 \u0437\u043e\u043d\u0435 ru-central1-a<\/p>\n<\/li>\n<li>\n<p>4 \u0434\u0438\u0441\u043a\u0430 (10\u0413\u0411, SSD)<\/p>\n<\/li>\n<li>\n<p>4 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d (5% CPU code fraction, 2 CPU cores, 2 RAM)<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c terraform apply. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043e\u0431\u043b\u0430\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>Photo<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c\u0441\u044f IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432:<\/p>\n<pre><code class=\"bash\">Apply complete! Resources: 12 added, 0 changed, 0 destroyed.  Outputs:  grafana_ip_address = \"158.160.43.15\" node1_ip_address = \"51.250.71.111\" node2_ip_address = \"158.160.110.84\" node3_ip_address = \"158.160.100.121\"<\/code><\/pre>\n<p>\u041e\u043d\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<\/p>\n<p><a class=\"anchor\" name=\"p2\" id=\"p2\"><\/a><\/p>\n<h2>\u0414\u0435\u043f\u043b\u043e\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0447\u0435\u0440\u0435\u0437 Ansible<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u044d\u0441\u0442\u0430\u0444\u0435\u0442\u0443 Ansible. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ansible \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445. \u041c\u0435\u043d\u044c\u0448\u0435 \u0441\u043b\u043e\u0432, \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438: \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044e Grafana \u0438 Loki!<\/p>\n<p>Grafana &#8212; \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Grafana \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u044b \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439, \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432 \u0447\u0430\u0442 \u0438\u043b\u0438 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443.  Loki &#8212; \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f Grafana. \u041e\u0431\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0420\u043e\u043b\u044c \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c Promtail, \u0435\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 node1, node2 \u0438 node3. Promtail \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0432 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 Loki. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043b\u043e\u0433\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Grafana. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0443 Grafana \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0430\u043b\u0435\u0440\u0442\u044b \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e?<\/p>\n<p><a class=\"anchor\" name=\"p3\" id=\"p3\"><\/a><\/p>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Ansible \u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Ansible \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438, \u044f \u0432\u044b\u0431\u0440\u0430\u043b pip:<\/p>\n<pre><code class=\"bash\">$ python3 -m pip install --user ansible<\/code><\/pre>\n<blockquote>\n<p>\u0425\u043e\u0442\u044f Ansible \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f &#171;agentless&#187; (\u0432\u0430\u043c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0430\u0433\u0435\u043d\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0412\u041c), \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 python \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435. <\/p>\n<\/blockquote>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438\u0437 GitHub, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0448\u0430\u0433 \u0441 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0412\u041c \u0432 Yandex.Cloud, \u0442\u043e \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0439\u0442\u0435 \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e ansible:<\/p>\n<pre><code>$ git clone git@github.com:AzamatKomaev\/habr-terraform-ansible-logs.git $ cd .\/habr-terraform-ansible-logs\/ansible<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 <em>inventory.ini<\/em>. \u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 Ansible \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0430\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0414\u043b\u044f \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e. \u0412 \u0444\u0430\u0439\u043b\u0435 \u044f \u0443\u043a\u0430\u0437\u0430\u043b IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u043c\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0438\u0445 \u043d\u0430 \u0432\u0430\u0448\u0438:<\/p>\n<details class=\"spoiler\">\n<summary>inventory.ini<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>[grafana] 158.160.43.15    ansible_user=admin   [nodes] 51.250.71.111    ansible_user=admin logging_label=node1 158.160.110.84   ansible_user=admin logging_label=node2 158.160.100.121  ansible_user=admin logging_label=node3<\/code><\/pre>\n<p><em>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ansible_user \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/em><\/p>\n<p><em>logging_level  <\/em>\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043e\u043d\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c. \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c ping:<\/p>\n<pre><code class=\"bash\">$ ansible -m ping all -i .\/inventory.ini<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Output<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">158.160.43.15 | SUCCESS => {     \"ansible_facts\": {         \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"     },     \"changed\": false,     \"ping\": \"pong\" } 51.250.71.111 | SUCCESS => {     \"ansible_facts\": {         \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"     },     \"changed\": false,     \"ping\": \"pong\" } 158.160.100.121 | SUCCESS => {     \"ansible_facts\": {         \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"     },     \"changed\": false,     \"ping\": \"pong\" } 158.160.110.84 | SUCCESS => {     \"ansible_facts\": {         \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"     },     \"changed\": false,     \"ping\": \"pong\" }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0451 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435! \u0418\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435&#8230;<\/p>\n<p>\u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 ansible \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e YAML \u0444\u0430\u0439\u043b\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 Ansible Playbook &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Ansible \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0451\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.  <\/p>\n<p>\u041e\u0434\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u043e\u0434\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0414\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f. \u041c\u043e\u0434\u0443\u043b\u044c &#8212; \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0430\u044f\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/index_module.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Ansible<\/a>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 ansible.builtin.*, \u0438\u0445 \u0445\u0432\u0430\u0442\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0430\u043b\u0438\u0441\u0430\u0441\u044b.<\/p>\n<p><a class=\"anchor\" name=\"p4\" id=\"p4\"><\/a><\/p>\n<h4>\u0414\u0435\u043f\u043b\u043e\u0438\u043c Loki<\/h4>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Loki. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>loki-installation-playbook.yml<\/code> \u0441 Ansible Playbook, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0437\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a Loki. Loki \u0438 Grafana \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0435\u0440. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u0441\u0435\u0445 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043a \u043d\u0438\u043c \u0431\u0443\u0434\u0443\u0442 \u0441\u043f\u0440\u044f\u0442\u0430\u043d\u044b \u0432 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>loki-installation-playbook.yml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">- name: Install Loki   hosts: grafana    tasks:   - name: Install unzip for unpacking archives      apt:       name: unzip     become: true    - name: Install loki using wget and unzip it     shell:       chdir: \/home\/admin       cmd: |         wget https:\/\/github.com\/grafana\/loki\/releases\/download\/v2.9.4\/loki-linux-amd64.zip         unzip \"loki-linux-amd64.zip\"           chmod a+x \"loki-linux-amd64\"         sudo mv .\/loki-linux-amd64 \/usr\/local\/bin\/loki    - name: Install default loki configuration yaml     shell:       chdir: \/home\/admin       cmd: wget https:\/\/raw.githubusercontent.com\/grafana\/loki\/main\/cmd\/loki\/loki-local-config.yaml    - name: Copy loki.service (unit for systemd) to \/etc\/systemd\/system folder     copy:       src: .\/resources\/loki.service       dest: \/etc\/systemd\/system     become: true    - name: Load loki unit and start it     systemd:       name: loki       state: started       daemon_reload: true       enabled: true      become: true <\/code><\/pre>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 Playbook, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0445\u043e\u0441\u0442\u043e\u0432 \u0438\u0437 inventory.ini \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0438. \u0417\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447. <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u043b\u0435 become \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c true: <em>become: true<\/em><\/p>\n<p><strong>Ins<\/strong><\/p>\n<\/div>\n<\/details>\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-369080","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/369080","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=369080"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/369080\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=369080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=369080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=369080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}