{"id":305904,"date":"2020-06-25T15:00:44","date_gmt":"2020-06-25T15:00:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305904"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305904","title":{"rendered":"\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043b\u043e\u0433\u0438 \u0441 Loki"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/badoo\/blog\/507718\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lc\/bs\/qs\/lcbsqsjngxf_myysrox0z1gbidc.jpeg\"><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0432 Badoo \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043c \u0441\u0432\u0435\u0436\u0438\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u041e\u043d\u043e \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043e Loki \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>Loki \u2014 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043b\u043e\u0433\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u044d\u0442\u043e\u0442 \u0441\u0442\u0435\u043a \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u0438\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Prometheus. \u0412 \u043c\u0430\u0435 \u0432\u044b\u0448\u043b\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438. \u041d\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e, \u0447\u0442\u043e \u0443\u043c\u0435\u0435\u0442 Loki, \u043a\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438 \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b ELK \u2014 \u0441\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0435\u0439\u0447\u0430\u0441.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h3 id=\"chto-takoe-loki\">\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Loki<\/h3>\n<p>  <\/p>\n<p>Grafana Loki \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043b\u043e\u0433\u0430\u043c\u0438. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c Loki \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0438\u0434\u0435\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u043e\u0433\u043e\u0432 \u2014 labels (\u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 Prometheus), a \u0441\u0430\u043c\u0438 \u043b\u043e\u0433\u0438 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0440\u044f\u0434\u043e\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0430\u043d\u043a\u0438. <\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/grafana.com\/oss\/loki\/#about\">\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/a>, <a href=\"https:\/\/github.com\/grafana\/loki\">GitHub<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Loki, \u0445\u043e\u0447\u0443 \u043f\u043e\u044f\u0441\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u00ab\u0438\u0434\u0435\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435\u00bb. \u0421\u0440\u0430\u0432\u043d\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434 Loki \u0438 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a Elasticsearch, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u043b\u043e\u0433\u0430 nginx:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">172.19.0.4 - - [01\/Jun\/2020:12:05:03 +0000] &quot;GET \/purchase?user_id=75146478&amp;amp;item_id=34234 HTTP\/1.1&quot; 500 8102 &quot;-&quot; &quot;Stub_Bot\/3.0&quot; &quot;0.001&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0430\u0440\u0441\u044f\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u043e\u043b\u044f \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 user_id \u0438 item_id, \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0432\u0441\u0451 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u044b\u0441\u0442\u0440\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u2014 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435. \u041d\u043e \u0437\u0430 \u044d\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c, \u0447\u0442\u043e \u0432\u044b\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043f\u0430\u043c\u044f\u0442\u0438. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043b\u043e\u0433\u043e\u0432 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441 \u0441\u0430\u043c\u0438\u043c\u0438 \u043b\u043e\u0433\u0430\u043c\u0438. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u043d\u0435\u043c\u0443 \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0441\u043a\u0430\u0442\u044c, \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u0418 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043b\u043e\u0433\u043e\u0432, \u0442\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438\u043d\u0434\u0435\u043a\u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u043d \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434 Loki \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u044b\u043b\u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0432\u0435\u043b\u0438\u043a\u043e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u044f \u0438\u0445 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043f\u043e \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044f\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u043b\u0438 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c, \u043d\u043e Loki \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u0435\u0439 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0440\u0434\u043e\u0432 \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043d\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f; \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0437\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u043c\u0435\u0436\u0434\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043b\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u043e\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 Loki \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0415\u0451 \u043c\u043e\u0436\u043d\u043e \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>Loki-\u0441\u0442\u0435\u043a \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0451\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432: Promtail, Loki, Grafana. Promtail \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043b\u043e\u0433\u0438, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 Loki. Loki \u0438\u0445 \u0445\u0440\u0430\u043d\u0438\u0442. \u0410 Grafana \u0443\u043c\u0435\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 Loki \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0445. \u0412\u043e\u043e\u0431\u0449\u0435 Loki \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432 \u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043d\u0438\u043c. \u0412\u0435\u0441\u044c \u0441\u0442\u0435\u043a \u0434\u0430\u0451\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Prometheus way.<br \/>  \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/grafana\/loki\/blob\/master\/docs\/installation\/README.md\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>  <\/p>\n<h3 id=\"poisk-po-logam\">\u041f\u043e\u0438\u0441\u043a \u043f\u043e \u043b\u043e\u0433\u0430\u043c<\/h3>\n<p>  <\/p>\n<p>\u0418\u0441\u043a\u0430\u0442\u044c \u043f\u043e \u043b\u043e\u0433\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 Grafana \u2014 Explorer. \u0414\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u044f\u0437\u044b\u043a LogQL, \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043d\u0430 PromQL, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u0432 Prometheus. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 grep.<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/is\/tz\/m2\/istzm2f0owktc2lru_sejisqjyg.png\"><\/p>\n<p>  <\/p>\n<p>\u0421\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: selector \u0438 filter. Selector \u2014 \u044d\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u043c (\u043b\u0435\u0439\u0431\u043b\u0430\u043c), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b \u043b\u043e\u0433\u0430\u043c, \u0430 filter \u2014 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u043b\u0438 \u0440\u0435\u0433\u044d\u043a\u0441\u043f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u043c. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435: \u0412 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u2014 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440, \u0432\u0441\u0435 \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u2014 \u0444\u0438\u043b\u044c\u0442\u0440.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">{image_name=&quot;nginx.promtail.test&quot;} |= &quot;index&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0437-\u0437\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Loki \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0435\u0437 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430, \u043d\u043e \u043b\u0435\u0439\u0431\u043b\u044b \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c \u0443\u0433\u043e\u0434\u043d\u043e \u043e\u0431\u0449\u0438\u043c\u0438. <\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u2014 \u044d\u0442\u043e key-value \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445. \u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u044b \u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b =, != \u0438\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f: <\/p>\n<p>  <\/p>\n<pre><code class=\"json\">{instance=~&quot;kafka-[23]&quot;,name!=&quot;kafka-dev&quot;}  \/\/ \u041d\u0430\u0439\u0434\u0451\u0442 \u043b\u043e\u0433\u0438 \u0441 \u043b\u0435\u0439\u0431\u043b\u043e\u043c instance, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 kafka-2, kafka-3, \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442 dev <\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u0438\u043b\u044c\u0442\u0440 \u2014 \u044d\u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u0438\u043b\u0438 \u0440\u0435\u0433\u044d\u043a\u0441\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f ad-hoc-\u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 metrics. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043b\u043e\u0433\u0430\u0445 nginx \u0437\u0430\u043f\u0438\u0441\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0443 index:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mu\/gj\/n_\/mugjn_anxzkkkga_w4t5jqqwlhe.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/github.com\/grafana\/loki\/blob\/master\/docs\/logql.md\">LogQL<\/a>.<\/p>\n<p>  <\/p>\n<h3 id=\"parsing-logov\">\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u043b\u043e\u0433\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043b\u043e\u0433\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Promtail, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0441\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u043b\u043e\u0433\u043e\u0432.<\/li>\n<li>\u041d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 \u0434\u043e\u043a\u0435\u0440-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/github.com\/grafana\/loki\/tree\/master\/cmd\/docker-driver\">Loki Docker Logging Driver.<\/a> <\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Fluentd \u0438\u043b\u0438 Fluent Bit, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043c\u0435\u044e\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 Loki. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Promtail \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043f\u0430\u0440\u0441\u0435\u0440\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u043b\u043e\u0433\u0430 \u0438 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441 multiline-\u043b\u043e\u0433\u0430\u043c\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 Promtail. \u041e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0440\u0438 \u0432\u0435\u0449\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041d\u0430\u0445\u043e\u0434\u0438\u0442 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<li>\u041f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u0442 \u043a \u043d\u0438\u043c \u043b\u0435\u0439\u0431\u043b\u044b.<\/li>\n<li>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 Loki.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 Promtail \u043c\u043e\u0436\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0441 systemd journal. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043b\u043e\u0433\u0438.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 Kubernetes: Promtail \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 Kubernetes REST API \u0443\u0437\u043d\u0430\u0451\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043b\u043e\u0433\u0438 \u0441 \u043d\u043e\u0434\u044b, \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438\u043b\u0438 \u043f\u043e\u0434\u0430, \u0441\u0440\u0430\u0437\u0443 \u0440\u0430\u0437\u0432\u0435\u0448\u0438\u0432\u0430\u044f \u043b\u0435\u0439\u0431\u043b\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 Kubernetes (\u0438\u043c\u044f \u043f\u043e\u0434\u0430, \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0438 \u0442. \u0434.).<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u043b\u0435\u0439\u0431\u043b\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043b\u043e\u0433\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Pipeline. Pipeline Promtail \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u0442\u0438\u043f\u043e\u0432 \u0441\u0442\u0430\u0434\u0438\u0439. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u2014 \u0432 <a href=\"https:\/\/github.com\/grafana\/loki\/tree\/master\/docs\/clients\/promtail\/stages\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>, \u0442\u0443\u0442 \u0436\u0435 \u043e\u0442\u043c\u0435\u0447\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b.<\/p>\n<p>  <\/p>\n<ol>\n<li><strong>Parsing stages<\/strong>. \u042d\u0442\u043e \u0441\u0442\u0430\u0434\u0438\u044f RegEx \u0438 JSON. \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043b\u043e\u0433\u043e\u0432 \u0432 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e extracted map. \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0437 JSON, \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043b\u044f \u0432 extracted map, \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f (RegEx), \u0433\u0434\u0435 \u0432 extracted map \u201c\u043c\u0430\u043f\u044f\u0442\u0441\u044f\u201d named groups. Extracted map \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 key-value \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u0433\u0434\u0435 key \u2014 \u0438\u043c\u044f \u043f\u043e\u043b\u044f, \u0430 value \u2014 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043b\u043e\u0433\u043e\u0432. <\/li>\n<li><strong>Transform stages<\/strong>. \u0423 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u043e\u043f\u0446\u0438\u0438: transform, \u0433\u0434\u0435 \u043c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0438 source \u2014 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 extracted map. \u0415\u0441\u043b\u0438 \u0432 extracted map \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043d\u0435\u0442, \u0442\u043e \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u0435\u0439\u0431\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 extracted map. \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 extracted map, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 <a href=\"https:\/\/golang.org\/pkg\/text\/template\/\">Golang Template<\/a>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u0434\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e extracted map \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0435, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043d\u0435\u0439: \u201c{{if .tag}tag value exists{end}}\u201d. Template \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0446\u0438\u043a\u043b\u044b \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a Replace \u0438 Trim. <\/li>\n<li><strong>Action stages<\/strong>. \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0441 \u0438\u0437\u0432\u043b\u0435\u0447\u0451\u043d\u043d\u044b\u043c:<br \/> \n<ul>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u0435\u0439\u0431\u043b \u0438\u0437 extracted data, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f Loki.<\/li>\n<li>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437 \u043b\u043e\u0433\u0430. <\/li>\n<li>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 (\u0442\u0435\u043a\u0441\u0442 \u043b\u043e\u0433\u0430), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0439\u0434\u0443\u0442 \u0432 Loki.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Filtering stages<\/strong>. \u0421\u0442\u0430\u0434\u0438\u044f match, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 \/dev\/null \u0437\u0430\u043f\u0438\u0441\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u043b\u0438\u0431\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 nginx-\u043b\u043e\u0433\u043e\u0432, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u043b\u043e\u0433\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Promtail. <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 nginx-proxy \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 nginx jwilder\/nginx-proxy:alpine \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0434\u0435\u043c\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u0435\u0442 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0441\u0430\u043c \u0441\u0435\u0431\u044f \u043f\u043e HTTP. \u0423 \u0434\u0435\u043c\u043e\u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u0432, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 HTTP-\u0441\u0442\u0430\u0442\u0443\u0441\u0430\u043c\u0438 \u0438 \u0441 \u0440\u0430\u0437\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439. <\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u0431\u0443\u0434\u0435\u043c \u0441 \u0434\u043e\u043a\u0435\u0440-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u043f\u0443\u0442\u0438 \/var\/lib\/docker\/containers\/&lt;container_id&gt;\/&lt;container_id&gt;-json.log<\/p>\n<p>  <\/p>\n<p>\u0412 docker-compose.yml \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Promtail \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0430: <\/p>\n<p>  <\/p>\n<pre><code class=\"json\">promtail:   image: grafana\/promtail:1.4.1  \/\/ ...  volumes:    - \/var\/lib\/docker\/containers:\/var\/lib\/docker\/containers:ro    - promtail-data:\/var\/lib\/promtail\/positions    - ${PWD}\/promtail\/docker.yml:\/etc\/promtail\/promtail.yml  command:    - '-config.file=\/etc\/promtail\/promtail.yml'  \/\/ ... <\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 promtail.yml \u043f\u0443\u0442\u044c \u0434\u043e \u043b\u043e\u0433\u043e\u0432 (\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0435\u0441\u0442\u044c \u043e\u043f\u0446\u0438\u044f &quot;docker&quot;, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439, \u043d\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435 \u0442\u0430\u043a \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">scrape_configs:  - job_name: containers     static_configs:        labels:          job: containerlogs          __path__: \/var\/lib\/docker\/containers\/*\/*log  # for linux only<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432 Loki \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u0441\u043e \u0432\u0441\u0435\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e nginx \u0432 docker-compose.yml \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435 tag:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">proxy:  image: nginx.test.v3 \/\/\u2026  logging:    driver: &quot;json-file&quot;    options:      tag: &quot;{{.ImageName}}|{{.Name}}&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043c promtail.yml \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Pipeline. \u041d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043b\u043e\u0433\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">{&quot;log&quot;:&quot;\\u001b[0;33;1mnginx.1    | \\u001b[0mnginx.test 172.28.0.3 - - [13\/Jun\/2020:23:25:50 +0000] \\&quot;GET \/api\/index HTTP\/1.1\\&quot; 200 0 \\&quot;-\\&quot; \\&quot;Stub_Bot\/0.1\\&quot; \\&quot;0.096\\&quot;\\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;attrs&quot;:{&quot;tag&quot;:&quot;nginx.promtail.test|proxy.prober&quot;},&quot;time&quot;:&quot;2020-06-13T23:25:50.66740443Z&quot;} {&quot;log&quot;:&quot;\\u001b[0;33;1mnginx.1    | \\u001b[0mnginx.test 172.28.0.3 - - [13\/Jun\/2020:23:25:50 +0000] \\&quot;GET \/200 HTTP\/1.1\\&quot; 200 0 \\&quot;-\\&quot; \\&quot;Stub_Bot\/0.1\\&quot; \\&quot;0.000\\&quot;\\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;attrs&quot;:{&quot;tag&quot;:&quot;nginx.promtail.test|proxy.prober&quot;},&quot;time&quot;:&quot;2020-06-13T23:25:50.702925272Z&quot;}<\/code><\/pre>\n<p>  <\/p>\n<p>Pipeline stage:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\"> - json:      expressions:        stream: stream        attrs: attrs        tag: attrs.tag<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u0437 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e JSON \u043f\u043e\u043b\u044f stream, attrs, attrs.tag (\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c) \u0438 \u043a\u043b\u0430\u0434\u0451\u043c \u0438\u0445 \u0432 extracted map. <\/p>\n<p>  <\/p>\n<pre><code class=\"json\"> - regex:      expression: ^(?P&lt;image_name&gt;([^|]+))\\|(?P&lt;container_name&gt;([^|]+))$      source: &quot;tag&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u043e\u043b\u0435 tag \u0432 extracted map, \u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u0435\u0433\u044d\u043a\u0441\u043f\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u043c\u0435\u043d\u0430 \u043e\u0431\u0440\u0430\u0437\u0430 \u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\"> - labels:      image_name:      container_name:<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043b\u0435\u0439\u0431\u043b\u044b. \u0415\u0441\u043b\u0438 \u0432 extracted data \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b \u043a\u043b\u044e\u0447\u0438 image_name \u0438 container_name, \u0442\u043e \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0441\u0442\u0443\u044e\u0449\u0438\u043c \u043b\u0435\u0439\u0431\u043b\u0430\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\"> - match:      selector: '{job=&quot;docker&quot;,container_name=&quot;&quot;,image_name=&quot;&quot;}'      action: drop<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043b\u043e\u0433\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 labels image_name \u0438 container_name.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">  - match:      selector: '{image_name=&quot;nginx.promtail.test&quot;}'      stages:        - json:            expressions:              row: log<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u043b\u043e\u0433\u043e\u0432, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 image_name \u0440\u0430\u0432\u0435\u043d nginx.promtail.test, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043b\u043e\u0433\u0430 \u043f\u043e\u043b\u0435 log \u0438 \u043a\u043b\u0430\u0434\u0451\u043c \u0435\u0433\u043e \u0432 extracted map \u0441 \u043a\u043b\u044e\u0447\u043e\u043c row.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">  - regex:          # suppress forego colors          expression: .+nginx.+\\|.+\\[0m(?P&lt;virtual_host&gt;[a-z_\\.-]+) +(?P&lt;nginxlog&gt;.+)          source: logrow<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0447\u0438\u0449\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c nginx virtual host \u0438 \u0441\u0442\u0440\u043e\u043a\u0443 \u043b\u043e\u0433\u0430 nginx.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">     - regex:          source: nginxlog          expression: ^(?P&lt;ip&gt;[\\w\\.]+) - (?P&lt;user&gt;[^ ]*) \\[(?P&lt;timestamp&gt;[^ ]+).*\\] &quot;(?P&lt;method&gt;[^ ]*) (?P&lt;request_url&gt;[^ ]*) (?P&lt;request_http_protocol&gt;[^ ]*)&quot; (?P&lt;status&gt;[\\d]+) (?P&lt;bytes_out&gt;[\\d]+) &quot;(?P&lt;http_referer&gt;[^&quot;]*)&quot; &quot;(?P&lt;user_agent&gt;[^&quot;]*)&quot;( &quot;(?P&lt;response_time&gt;[\\d\\.]+)&quot;)?<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0430\u0440\u0441\u0438\u043c nginx-\u043b\u043e\u0433 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438. <\/p>\n<p>  <\/p>\n<pre><code class=\"json\">    - regex:            source: request_url            expression: ^.+\\.(?P&lt;static_type&gt;jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$      - regex:            source: request_url            expression: ^\/photo\/(?P&lt;photo&gt;[^\/\\?\\.]+).*$        - regex:            source: request_url            expression: ^\/api\/(?P&lt;api_request&gt;[^\/\\?\\.]+).*$<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c request_url. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u044d\u043a\u0441\u043f\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430: \u043a \u0441\u0442\u0430\u0442\u0438\u043a\u0435, \u043a \u0444\u043e\u0442\u043a\u0430\u043c, \u043a API \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432 extracted map \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u044e\u0447.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">       - template:            source: request_type            template: &quot;{{if .photo}}photo{{else if .static_type}}static{{else if .api_request}}api{{else}}other{{end}}&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0432 Template \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0432 extracted map \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u043b\u044f \u043f\u043e\u043b\u044f request_type \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f: photo, static, API. \u041d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c other, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c. \u0422\u0435\u043f\u0435\u0440\u044c request_type \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">       - labels:            api_request:            virtual_host:            request_type:            status:<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u0435\u0439\u0431\u043b\u044b api_request, virtual_host, request_type \u0438 \u0441\u0442\u0430\u0442\u0443\u0441 (HTTP status) \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 extracted map. <\/p>\n<p>  <\/p>\n<pre><code class=\"json\">       - output:            source: nginx_log_row<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u0435\u043d\u044f\u0435\u043c output. \u0422\u0435\u043f\u0435\u0440\u044c \u0432 Loki \u0443\u0445\u043e\u0434\u0438\u0442 \u043e\u0447\u0438\u0449\u0435\u043d\u043d\u044b\u0439 nginx-\u043b\u043e\u0433 \u0438\u0437 extracted map.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-v\/vc\/wp\/-vvcwp0ugejaiwmfncngv-kpzoe.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b \u043c\u0435\u0442\u043a\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043b\u043e\u0433\u0430.<\/p>\n<p>  <\/p>\n<p>\u041d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u043a \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (cardinality) \u043c\u043e\u0436\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 Loki. \u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u0438\u043d\u0434\u0435\u043a\u0441, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, user_id. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u201c<a href=\"https:\/\/grafana.com\/blog\/2020\/04\/21\/how-labels-in-loki-can-make-log-queries-faster-and-easier\/\">How labels in Loki can make log queries faster and easier<\/a>\u201d. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e user_id \u0431\u0435\u0437 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u041d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u0440\u0438 \u043f\u043e\u0438\u0441\u043a\u0435 (\u00ab\u0433\u0440\u0435\u043f\u0430\u0442\u044c\u00bb \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c), \u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u0437\u0434\u0435\u0441\u044c \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043a\u0430\u043a \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<p>  <\/p>\n<h3 id=\"vizualizaciya-logov\">\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u043e\u0433\u043e\u0432<\/h3>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/x5\/w0\/ch\/x5w0chytnejcfkunlzuttuv23x0.png\"><\/p>\n<p>  <\/p>\n<p>Loki \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0432 \u0440\u043e\u043b\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 Grafana, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f LogQL. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>rate \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443;<\/li>\n<li>count over time \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435. <\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0449\u0451 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Sum, Avg \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u041c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0433\u0440\u0430\u0444\u0438\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 HTTP-\u043e\u0448\u0438\u0431\u043e\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wa\/la\/dd\/waladd8c9dikmf_niai5gz9jne4.png\"><\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 data source Loki \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u0435\u0437\u0430\u043d \u043f\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 data source Prometheus (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043b\u0435\u0433\u0435\u043d\u0434\u0443), \u043d\u043e Loki \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u0430\u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441 \u0442\u0438\u043f\u043e\u043c Prometheus. \u042f \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u044d\u0442\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043d\u043e, \u0441\u0443\u0434\u044f \u043f\u043e \u043e\u0442\u0432\u0435\u0442\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u201c<a href=\"https:\/\/github.com\/grafana\/loki\/issues\/1222\">How to configure Loki as Prometheus datasource? \u00b7 Issue #1222 \u00b7 grafana\/loki<\/a>\u201d, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0437\u0430\u043a\u043e\u043d\u043d\u043e, \u0438 Loki \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u0441 PromQL.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Loki \u043a\u0430\u043a data source \u0441 \u0442\u0438\u043f\u043e\u043c Prometheus \u0438 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c URL \/loki:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ya\/qa\/tf\/yaqatfjs-szotpgew82l9vqoaks.png\"><\/p>\n<p>  <\/p>\n<p>\u0418 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043a\u0430\u043a \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438 \u0438\u0437 Prometheus:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/5r\/hd\/hw\/5rhdhwpv14uhoug0govithsdjoe.png\"><\/p>\n<p>  <\/p>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u044f\u0442.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/q7\/oe\/he\/q7oehe-zylqalmf-ugglhuht79u.png\"><\/p>\n<p>  <\/p>\n<h3 id=\"metriki\">\u041c\u0435\u0442\u0440\u0438\u043a\u0438<\/h3>\n<p>  <\/p>\n<p>\u0412 Loki \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0438\u0437 \u043b\u043e\u0433\u043e\u0432 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0438\u0445 \u0432 Prometheus. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043b\u043e\u0433\u0435 nginx \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u043d\u0430 \u043e\u0442\u0432\u0435\u0442, \u0430 \u0442\u0430\u043a\u0436\u0435, \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043b\u043e\u0433\u0430, \u0438 \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u043e\u0442\u0432\u0435\u0442. \u042d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 Prometheus.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u0441\u0435\u043a\u0446\u0438\u044e \u0432 promtail.yml:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">- match:    selector: '{request_type=&quot;api&quot;}'    stages:      - metrics:          http_nginx_response_time:            type: Histogram            description: &quot;response time ms&quot;            source: response_time            config:              buckets: [0.010,0.050,0.100,0.200,0.500,1.0] - match:    selector: '{request_type=~&quot;static|photo&quot;}'    stages:      - metrics:          http_nginx_response_bytes_sum:            type: Counter            description: &quot;response bytes sum&quot;            source: bytes_out            config:              action: add          http_nginx_response_bytes_count:            type: Counter            description: &quot;response bytes count&quot;            source: bytes_out            config:              action: inc<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 extracted map. \u042d\u0442\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 Loki \u2014 \u043e\u043d\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 Promtail \/metrics endpoint. Prometheus \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0434\u0438\u0438. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u043b\u044f request_type=\u201capi\u201d \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0443-\u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0421 \u044d\u0442\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043c\u0435\u0442\u0440\u0438\u043a \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043f\u0435\u0440\u0446\u0435\u043d\u0442\u0438\u043b\u0438. \u0414\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u043a\u0438 \u0438 \u0444\u043e\u0442\u043e \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u0431\u0430\u0439\u0442\u043e\u0432 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u0430\u0439\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u0445 \u0447\u0438\u0442\u0430\u0439\u0442\u0435 <a href=\"https:\/\/github.com\/grafana\/loki\/blob\/master\/docs\/clients\/promtail\/stages\/metrics.md\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0440\u0442 \u043d\u0430 Promtail:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">promtail:      image: grafana\/promtail:1.4.1      container_name: monitoring.promtail      expose:        - 9080      ports:        - &quot;9080:9080&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c promtail_custom \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ex\/1d\/s1\/ex1ds1gpvvrzm3yvyslzjx0r7vu.png\"><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c Prometheus. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c job promtail:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">- job_name: 'promtail'  scrape_interval: 10s  static_configs:    - targets: ['promtail:9080']<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0440\u0438\u0441\u0443\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/5w\/ug\/uz\/5wuguzq0kfxvfbe95syjr4lfvlq.png\"><\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u0430\u043c\u044b\u0445 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433.<\/p>\n<p>  <\/p>\n<h3 id=\"masshtabirovanie\">\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>Loki \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u0432 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 (single binary mode), \u0442\u0430\u043a \u0438 \u0432 \u0448\u0430\u0440\u0434\u0438\u0440\u0443\u0435\u043c\u043e\u043c (horizontally-scalable mode). \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0431\u043b\u0430\u043a\u043e, \u043f\u0440\u0438\u0447\u0451\u043c \u0447\u0430\u043d\u043a\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0412 \u0432\u0435\u0440\u0441\u0438\u0438 1.5 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kc\/wy\/sr\/kcwysrncfkf_nb3tdkshbsus_au.png\"><\/p>\n<p>  <\/p>\n<p>\u0427\u0430\u043d\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 S3-\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445: Cassandra, BigTable \u0438\u043b\u0438 DynamoDB. \u0414\u0440\u0443\u0433\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 Loki \u2014 Distributors (\u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438) \u0438 Querier (\u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432) \u2014 stateless \u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e. <\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 DevOpsDays Vancouver 2019 \u043e\u0434\u0438\u043d \u0438\u0437 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 Callum Styan \u043e\u0437\u0432\u0443\u0447\u0438\u043b, \u0447\u0442\u043e \u0441 Loki \u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u0438\u043c\u0435\u0435\u0442 \u043f\u0435\u0442\u0430\u0431\u0430\u0439\u0442\u044b \u043b\u043e\u0433\u043e\u0432 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u043c\u0435\u043d\u044c\u0448\u0435 1% \u043e\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430: \u201c<a href=\"https:\/\/grafana.com\/blog\/2019\/05\/06\/how-loki-correlates-metrics-and-logs-and-saves-you-money\/\">How Loki Correlates Metrics and Logs \u2014 And Saves You Money<\/a>\u201d.<\/p>\n<p>  <\/p>\n<h3 id=\"sravnenie-loki-i-elk\">\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 Loki \u0438 ELK<\/h3>\n<p>  <\/p>\n<p><strong>\u0420\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 <\/strong><br \/>  \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044f \u0432\u0437\u044f\u043b \u043b\u043e\u0433\u0438 \u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 nginx, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u0441\u044f Pipeline, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435. \u0424\u0430\u0439\u043b \u0441 \u043b\u043e\u0433\u0430\u043c\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b 406 624 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u044b\u043c \u043e\u0431\u044a\u0451\u043c\u043e\u043c 109 \u041c\u0431. \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043b\u043e\u0433\u0438 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0430, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e 100 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u043e\u043a \u0438\u0437 \u043b\u043e\u0433\u0430:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/6v\/i2\/pi\/6vi2piyjogw7rcapzltyrvu35ck.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 ELK \u044d\u0442\u043e \u0434\u0430\u043b\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 30,3 \u041c\u0431:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/li\/by\/1i\/liby1iwtwy1tnwqsgnugcmc42oo.png\"><\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 Loki \u044d\u0442\u043e \u0434\u0430\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 128 \u041a\u0431 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 3,8 \u041c\u0431 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0447\u0430\u043d\u043a\u0430\u0445. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043b\u043e\u0433 \u0431\u044b\u043b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u043b\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 gzip \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0434\u043e\u043a\u0435\u0440\u043e\u0432\u0441\u043a\u043e\u043c JSON-\u043b\u043e\u0433\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u0432\u0430\u043b \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044e 95,4%, \u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u0441\u0430\u043c Loki \u043f\u043e\u0441\u044b\u043b\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0447\u0438\u0449\u0435\u043d\u043d\u044b\u0439 nginx-\u043b\u043e\u0433, \u0442\u043e \u0441\u0436\u0430\u0442\u0438\u0435 \u0434\u043e 4 \u041c\u0431 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c\u043e. \u0421\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043b\u0435\u0439\u0431\u043b\u043e\u0432 Loki \u0431\u044b\u043b\u043e 35, \u0447\u0442\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0414\u043b\u044f ELK \u043b\u043e\u0433 \u0442\u0430\u043a\u0436\u0435 \u043e\u0447\u0438\u0449\u0430\u043b\u0441\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, Loki \u0441\u0436\u0430\u043b \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 96%, \u0430 ELK \u2014 \u043d\u0430 70%.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438<\/strong><\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gh\/rj\/ks\/ghrjksy8u0bjv0zwpk28zrx1ghy.png\"><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0441\u0442\u0435\u043a Prometheus \u0438 ELK, \u0442\u043e Loki \u00ab\u0435\u0441\u0442\u00bb \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435. \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0430 Go \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0430 Java, \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 JVM Heap Elasticsearch \u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f Loki \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e Loki \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u0415\u0433\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043f\u043e CPU \u043d\u0435 \u0442\u0430\u043a \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442.<\/p>\n<p>  <\/p>\n<p><strong>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c<\/strong><\/p>\n<p>  <\/p>\n<p>Loki \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u00ab\u043f\u043e\u0436\u0438\u0440\u0430\u0435\u0442\u00bb \u043b\u043e\u0433\u0438. \u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043c\u043d\u043e\u0433\u0438\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u2014 \u0447\u0442\u043e \u0437\u0430 \u043b\u043e\u0433\u0438, \u043a\u0430\u043a \u0438\u0437\u043e\u0449\u0440\u0451\u043d\u043d\u043e \u043c\u044b \u0438\u0445 \u043f\u0430\u0440\u0441\u0438\u043c, \u0441\u0435\u0442\u044c, \u0434\u0438\u0441\u043a \u0438 \u0442. \u0434. \u2014 \u043d\u043e \u043e\u043d\u0430 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0432\u044b\u0448\u0435, \u0447\u0435\u043c \u0443 ELK (\u0432 \u043c\u043e\u0451\u043c \u0442\u0435\u0441\u0442\u0435 \u2014 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430). \u041e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0442\u0435\u043c, \u0447\u0442\u043e Loki \u043a\u043b\u0430\u0434\u0451\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0442\u0440\u0430\u0442\u0438\u0442 \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0421\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f: Loki \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u043f\u0440\u0438\u0442\u043e\u0440\u043c\u0430\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u043e\u0432, \u0443 ELK \u0436\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u0438\u0441\u043a \u043f\u043e \u043b\u043e\u0433\u0430\u043c<\/strong><\/p>\n<p>  <\/p>\n<p>Loki \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0441\u0442\u0443\u043f\u0430\u0435\u0442 ELK \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043b\u043e\u0433\u0430\u043c. Grep \u0441 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u2014 \u044d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u043d\u043e \u043e\u043d \u0443\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432\u0437\u0440\u043e\u0441\u043b\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 range-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043b\u0435\u0439\u0431\u043b\u0430\u043c, \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043a\u0430\u0442\u044c \u0431\u0435\u0437 \u043b\u0435\u0439\u0431\u043b\u043e\u0432 \u2014 \u0432\u0441\u0451 \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0441 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 Loki. \u042d\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Loki \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u0439\u0442\u0438, \u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0444\u043b\u043e\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043b\u043e\u0433\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u0445 Prometheus, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e \u044d\u0442\u0438\u043c \u043b\u0435\u0439\u0431\u043b\u0430\u043c \u0438\u0449\u0435\u0442\u0435, \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432 \u043b\u043e\u0433\u0430\u0445. <\/p>\n<p>  <\/p>\n<p><strong>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/strong><\/p>\n<p>  <\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e (\u0438\u0437\u0432\u0438\u043d\u0438\u0442\u0435, \u043d\u0435 \u043c\u043e\u0433 \u0443\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f). Grafana \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0433\u043b\u0430\u0437\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u043e Kibana \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430. <\/p>\n<p>  <\/p>\n<h3 id=\"plyusy-i-minusy-loki\">\u041f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b Loki<\/h3>\n<p>  <\/p>\n<p>\u0418\u0437 \u043f\u043b\u044e\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e Loki \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 Prometheus, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438 \u0430\u043b\u0435\u0440\u0442\u0438\u043d\u0433 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u041e\u043d \u0443\u0434\u043e\u0431\u0435\u043d \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u043b\u043e\u0433\u043e\u0432 \u0438 \u0438\u0445 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441 Kubernetes Pods, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u043c\u0435\u0435\u0442 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 Prometheus service discovery \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0432\u0435\u0448\u0438\u0432\u0430\u0435\u0442 \u043b\u0435\u0439\u0431\u043b\u044b. <\/p>\n<p>  <\/p>\n<p>\u0418\u0437 \u043c\u0438\u043d\u0443\u0441\u043e\u0432 \u2014 \u0441\u043b\u0430\u0431\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Promtail, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0431\u043b\u0430\u0433\u043e open-source. \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u043c\u0438\u043d\u0443\u0441 \u2014 \u0441\u043b\u0430\u0431\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Loki \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043f\u0430\u0440\u0441\u0438\u0442\u044c multiline-\u043b\u043e\u0433\u0438. \u0422\u0430\u043a\u0436\u0435 \u043a \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0442\u043e, \u0447\u0442\u043e Loki \u2014 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u043b\u043e\u0434\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f (\u0440\u0435\u043b\u0438\u0437 1.0 \u0431\u044b\u043b \u0432 \u043d\u043e\u044f\u0431\u0440\u0435 2019 \u0433\u043e\u0434\u0430).<\/p>\n<p>  <\/p>\n<h3 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>Loki \u2014 \u043d\u0430 100% \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0438 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0440\u0435\u0448\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432, \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043b\u043e\u0433\u0430\u043c, \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043b\u043e\u0433\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Loki \u0432 Badoo, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u043c\u0435\u0435\u043c ELK-\u0441\u0442\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430 \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043e\u0431\u0440\u043e\u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438. \u0414\u043b\u044f \u043d\u0430\u0441 \u043a\u0430\u043c\u043d\u0435\u043c \u043f\u0440\u0435\u0442\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u043b\u043e\u0433\u0430\u043c. \u0418\u043c\u0435\u044f \u043f\u043e\u0447\u0442\u0438 100 \u0413\u0431 \u043b\u043e\u0433\u043e\u0432 \u0432 \u0434\u0435\u043d\u044c, \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u043e \u0443\u043c\u0435\u0442\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0451 \u0438 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e. \u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0442\u043e\u0447\u0435\u043d\u044b \u043f\u043e\u0434 \u043d\u0430\u0448\u0438 \u043d\u0443\u0436\u0434\u044b \u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0423 \u0441\u0442\u0435\u043a\u0430 Loki \u0435\u0441\u0442\u044c \u043e\u0449\u0443\u0442\u0438\u043c\u044b\u0435 \u043f\u043b\u044e\u0441\u044b, \u043d\u043e \u043e\u043d \u043d\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c, \u0438 \u0435\u0433\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u043a\u0440\u043e\u044e\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. <\/p>\n<p>  <\/p>\n<p>\u0418 \u0445\u043e\u0442\u044f \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043c\u044b Loki \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u043c, \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0432 \u0432\u044b\u0431\u043e\u0440\u0435. <\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043a\u043e\u0434\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/github.com\/black-rosary\/loki-nginx\">\u0442\u0443\u0442<\/a>.<\/p>\n<\/div>\n<p> \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\/company\/badoo\/blog\/507718\/\"> https:\/\/habr.com\/ru\/company\/badoo\/blog\/507718\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/badoo\/blog\/507718\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lc\/bs\/qs\/lcbsqsjngxf_myysrox0z1gbidc.jpeg\"><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0432 Badoo \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043c \u0441\u0432\u0435\u0436\u0438\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u041e\u043d\u043e \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043e Loki \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>Loki \u2014 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043b\u043e\u0433\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u044d\u0442\u043e\u0442 \u0441\u0442\u0435\u043a \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u0438\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Prometheus. \u0412 \u043c\u0430\u0435 \u0432\u044b\u0448\u043b\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438. \u041d\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e, \u0447\u0442\u043e \u0443\u043c\u0435\u0435\u0442 Loki, \u043a\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438 \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b ELK \u2014 \u0441\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0435\u0439\u0447\u0430\u0441.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-305904","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305904","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=305904"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305904\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}