{"id":306166,"date":"2020-06-30T09:00:38","date_gmt":"2020-06-30T09:00:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=306166"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=306166","title":{"rendered":"\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c grok exporter \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a prometheus \u0438\u0437 \u043d\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432"},"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\/post\/508870\/\">\n<p>\u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 2 \u043f\u043e\u0441\u0442\u043e\u0432 \u043f\u0440\u043e grok exporter.<\/p>\n<p>  <\/p>\n<h1 id=\"pervyy-perevod-kak-ispolzovat-grok-exporter-dlya-sozdaniya-metrik-prometheus-iz-nestrukturirovannyh-zhurnalov\">\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: \u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c grok exporter \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a prometheus \u0438\u0437 \u043d\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432<\/h1>\n<p>  <\/p>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e grok exporter. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/fstab\/grok_exporter\" rel=\"nofollow\">grok exporter<\/a> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a prometheus \u0438\u0437 \u043d\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c51\/7f5\/a13\/c517f5a13e658ed78088faa34daee74c.png\"><\/p>\n<p>  <\/p>\n<p>Grok \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u043e\u0432\u043e\u043c ELK \u0441\u0442\u0435\u043a\u0435 (ElasticSearch, Logstash, Kibana) \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <a href=\"https:\/\/github.com\/fstab\" rel=\"nofollow\">Fabian St\u00e4ber<\/a> \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <strong>grok exporter<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f grok exporter =&gt; <a href=\"https:\/\/github.com\/fstab\/grok_exporter\" rel=\"nofollow\">https:\/\/github.com\/fstab\/grok_exporter<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"shag-1-ustanovite-grok-exporter\">\u0428\u0430\u0433 1: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 Grok exporter<\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 zip \u0444\u0430\u0439\u043b grok exporter \u043e\u0442 <a href=\"https:\/\/github.com\/fstab\/grok_exporter\/releases\" rel=\"nofollow\">https:\/\/github.com\/fstab\/grok_exporter\/releases<\/a>.<\/p>\n<p>  <\/p>\n<ol>\n<li>\u200b \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b \u0440\u0435\u043b\u0438\u0437\u044b (releases) \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e (\u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e v0.2.7).<\/li>\n<li>\u200b \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 zip-\u0444\u0430\u0439\u043b, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0432\u0430\u0448\u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u041c\u043e\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u2014 \u044d\u0442\u043e 64-\u0431\u0438\u0442\u043d\u044b\u0439 Linux. \u0422\u0430\u043a\u043e\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"plaintext\">wget https:\/\/github.com\/fstab\/grok_exporter\/releases\/download\/v0.2.7\/grok_exporter-0.2.7.linux-amd64.zip<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u200b \u0420\u0430\u0441\u043f\u0430\u043a\u0443\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433.<\/li>\n<li>\u200b \u0417\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043d\u0438\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c grok exporter.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[root@localhost grok_exporter-0.2.7.linux-amd64]# .\/grok_exporter -config .\/config.yml Starting server on http:\/\/localhost.localdomain:9144\/metrics<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u0435\u0442\u0440\u0438\u043a \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost.localdomain:9144\/metrics\" rel=\"nofollow\">http:\/\/localhost.localdomain:9144\/metrics<\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"shag-2-davayte-obrabotaem-nekotorye-polzovatelskie-zhurnaly\"><strong>\u0428\u0430\u0433 2: \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0436\u0443\u0440\u043d\u0430\u043b\u044b<\/strong><\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u0441 Grok exporter. \u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0445 \u043c\u043d\u043e\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">30.07.2016 04:33:03 10.3.4.1 user=Nijil message=&quot;logged in&quot; 30.07.2016 06:47:03 10.3.4.2 user=Alex message=&quot;logged failed&quot; 30.07.2016 06:55:03 10.3.4.2 user=Alex message=&quot;logged in&quot; 30.07.2016 07:03:03 10.3.4.3 user=Alan message=&quot;logged in&quot; 30.07.2016 07:37:03 10.3.4.1 user=Nijil message=&quot;logged out&quot; 30.07.2016 08:47:03 10.3.4.2 user=Alex message=&quot;logged out&quot; 30.07.2016 14:34:03 10.3.4.3 user=Alan message=&quot;logged out&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u043c\u043e\u0433\u043b\u0438 \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0436\u0443\u0440\u043d\u0430\u043b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u043e\u043b\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0443 Prometheus \u0438\u0437 \u044d\u0442\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0428\u0430\u0433\u0435 1 \u0432\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043f\u0443\u0442\u044c config.xml, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 grok exporter. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">global:     config_version: 2 input:     type: file     path: .\/example\/nijil.log  # Specify the location of the your log     readall: true              # This should be True if you want to read whole log and False if you want to read only new lines. grok:     patterns_dir: .\/patterns     metrics:     - type: counter       name: user_activity       help: Counter metric example with labels.       match: &quot;%{DATE} %{TIME} %{HOSTNAME:instance} user=%{USER:user} message=\\&quot;%{GREEDYDATA:data}\\&quot;&quot;       labels:           user    : '{{.user}}'  server:     port: 9144<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u0432\u043d\u0438\u0437\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">global:     # Config version input:     # How to read log lines (file or stdin). grok:     # Available Grok patterns. metrics:     # How to map Grok fields to Prometheus metrics. server:     # How to expose the metrics via HTTP(S).<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"shag-3-nastroyka-serdca-grok-exporter\"><strong>\u0428\u0430\u0433 3: \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0435\u0440\u0434\u0446\u0430 Grok exporter<\/strong><\/h2>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u043c \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0433\u0434\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u043a\u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0441 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438 Prometheus.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">metrics:     - type: counter       name: user_activity       help: Counter metric example with labels.       match: &quot;%{DATE} %{TIME} %{HOSTNAME:instance} user=%{USER:user} message=\\&quot;%{GREEDYDATA:data}\\&quot;&quot;       labels:           user    : '{{.user}}'<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 grok \u2013 \u044d\u0442\u043e <code>%{SYNTAX:SEMANTIC}<\/code>, \u0433\u0434\u0435 <code>SYNTAX<\/code> \u2014 \u044d\u0442\u043e \u0438\u043c\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b\u0443, \u0430 <code>SEMANTIC<\/code> \u2013 \u044d\u0442\u043e \u0438\u043c\u044f \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0436\u0443\u0440\u043d\u0430\u043b\u0443. \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 <code>%{HOSTNAME:instance}<\/code>, <code>HOSTNAME<\/code> \u2013 \u044d\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d grok, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u0430\u043b\u044f\u0435\u0442 IP-\u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u0436\u0443\u0440\u043d\u0430\u043b\u0430, \u0438 \u044d\u0442\u0430 <code>IP-\u0447\u0430\u0441\u0442\u044c<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 (\u0437\u0434\u0435\u0441\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0438\u043c\u044f), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0436\u0435. \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 <code>SYNTAX<\/code> \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0446\u0435\u043b\u044c, \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0435 \u0441 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u0434\u0430\u0442\u044b. \u0418 \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, <code>DATE<\/code>, <code>TIME<\/code>, <code>HOSTNAME<\/code>, <code>USER<\/code> \u0438 <code>GREEDYDATA<\/code> \u043e\u0431\u0440\u044b\u0432\u043a\u0438 \u0434\u0430\u0442\u044b, \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438\u043c\u0435\u043d\u0438 \u0445\u043e\u0441\u0442\u0430 \u0438 &quot;\u043b\u044e\u0431\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f&quot; \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u0418\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0443 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 (SEMANTIC of the SYNTAX) \u0434\u043b\u044f \u043c\u0435\u0442\u043a\u0438. \u0414\u043b\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u043e\u0441\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u043e\u0441\u044c. \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u041a\u0430\u043a \u0438 \u0421\u0447\u0435\u0442\u0447\u0438\u043a (Counter), \u0443 grok exporter \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0438\u043f\u044b, \u0443\u0437\u043d\u0430\u0439\u0442\u0435 \u043e \u043d\u0438\u0445 \u0438\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0438\u0442\u0435\u0441\u044c grok exporter <code>.\/grok_exporter -config .\/config.yml<\/code> \u0438 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>user_activity<\/code>, \u043a\u0430\u043a \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># TYPE user_activity counter user_activity{user=&quot;Alan&quot;} 2 user_activity{user=&quot;Alex&quot;} 3 user_activity{user=&quot;Nijil&quot;} 2<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0432 Prometheus \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u041d\u043e \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0432\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 prometheus, \u0447\u0442\u043e\u0431\u044b Prometheus \u043c\u043e\u0433 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u041c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u0434\u043b\u044f \u0432\u0430\u0441.<\/p>\n<p>  <\/p>\n<h1 id=\"vtoroy-perevod-poluchenie-metrik-iz-zhurnalov-apache-s-pomoschyu-grok-exporter\">\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a \u0438\u0437 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 Apache \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e grok exporter<\/h1>\n<p>  <\/p>\n<p>\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b <a href=\"https:\/\/www.robustperception.io\/getting-metrics-from-apache-logs-using-the-grok-exporter\" rel=\"nofollow\">https:\/\/www.robustperception.io\/getting-metrics-from-apache-logs-using-the-grok-exporter<\/a><\/p>\n<p>  <\/p>\n<p>\u041d\u0435 \u0432\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0436\u0443\u0440\u043d\u0430\u043b\u044b.<\/p>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a, \u043e\u0434\u043d\u0430\u043a\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u0438\u043c\u0435\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0430\u0445. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/fstab\/grok_exporter\" rel=\"nofollow\">\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 grok<\/a>. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 Apache, \u0432\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u0438\u0437 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e <em>access.log<\/em>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">x.x.x.x - - [20\/Jan\/2020:06:25:24 +0000] &quot;GET \/ HTTP\/1.1&quot; 200 62316 &quot;http:\/\/178.62.121.216&quot; &quot;Go-http-client\/1.1&quot; x.x.x.x - - [20\/Jan\/2020:06:25:25 +0000] &quot;GET \/ HTTP\/1.1&quot; 200 16061 &quot;-&quot; &quot;Go-http-client\/1.1&quot; x.x.x.x - - [20\/Jan\/2020:06:25:25 +0000] &quot;GET \/ HTTP\/1.1&quot; 200 16064 &quot;-&quot; &quot;Go-http-client\/1.1&quot; x.x.x.x - - [20\/Jan\/2020:06:25:25 +0000] &quot;GET \/blog\/rss HTTP\/1.1&quot; 301 3478 &quot;-&quot; &quot;Tiny Tiny RSS\/19.2 (adc2a51) (http:\/\/tt-rss.org\/)&quot; x.x.x.x - - [20\/Jan\/2020:06:25:26 +0000] &quot;GET \/ HTTP\/1.1&quot; 200 16065 &quot;-&quot; &quot;Go-http-client\/1.1&quot; x.x.x.x - - [20\/Jan\/2020:06:25:26 +0000] &quot;GET \/blog\/feed HTTP\/1.1&quot; 200 3413 &quot;-&quot; &quot;Tiny Tiny RSS\/19.2 (adc2a51) (http:\/\/tt-rss.org\/)&quot; x.x.x.x - - [20\/Jan\/2020:06:25:27 +0000] &quot;GET \/feed HTTP\/1.1&quot; 200 6496 &quot;-&quot; &quot;Emacs Elfeed 3.2.0&quot; x.x.x.x - - [20\/Jan\/2020:06:25:27 +0000] &quot;GET \/ HTTP\/1.1&quot; 200 62316 &quot;http:\/\/178.62.121.216&quot; &quot;Go-http-client\/1.1&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">wget https:\/\/github.com\/fstab\/grok_exporter\/releases\/download\/v1.0.0.RC2\/grok_exporter-1.0.0.RC2.linux-amd64.zip<\/code><\/pre>\n<p>  <\/p>\n<p>\u0440\u0430\u0441\u043f\u0430\u043a\u0443\u0439\u0442\u0435<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">unzip grok_exporter-*.zip cd grok_exporter*amd64<\/code><\/pre>\n<p>  <\/p>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">cat &lt;&lt; 'EOF' &gt; config.yml global:     config_version: 2 input:     type: file     path: access.log     readall: true grok:     patterns_dir: .\/patterns metrics:     - type: counter       name: apache_http_response_codes_total       help: HTTP requests to Apache       match: '%{COMBINEDAPACHELOG}'       labels:           method: '{{.verb}}'           path: '{{.request}}'           code: '{{.response}}' server:     port: 9144 EOF<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 grok exporter:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">.\/grok_exporter -config config.yml<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435 \u043d\u0430\u0441 <a href=\"http:\/\/localhost:9144\/metrics\" rel=\"nofollow\">http:\/\/localhost:9144\/metrics<\/a> \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># HELP apache_http_response_codes_total HTTP requests to Apache # TYPE apache_http_response_codes_total counter apache_http_response_codes_total{code=&quot;200&quot;,method=&quot;GET&quot;,path=&quot;\/&quot;} 5 apache_http_response_codes_total{code=&quot;200&quot;,method=&quot;GET&quot;,path=&quot;\/blog\/feed&quot;} 1 apache_http_response_codes_total{code=&quot;200&quot;,method=&quot;GET&quot;,path=&quot;\/feed&quot;} 1 apache_http_response_codes_total{code=&quot;301&quot;,method=&quot;GET&quot;,path=&quot;\/blog\/rss&quot;} 1<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e <strong>readall<\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u0443 \u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430, \u0430 \u043d\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0436\u0443\u0440\u043d\u0430\u043b\u0430.<\/p>\n<p>  <\/p>\n<p>Grok \u2013 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.elastic.co\/guide\/en\/logstash\/7.5\/plugins-filters-grok.html\" rel=\"nofollow\">\u0441\u0442\u0440\u043e\u043a\u0438 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u0432 Logstash<\/a> (Logstash \u2014 \u044d\u0442\u043e L \u0432 \u0441\u0442\u0435\u043a\u0435 ELK). \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0431\u044b\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f Apache. \u042d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 Grok \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438\u0437 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432. <code>COMMMONAPACHELOG<\/code> \u043d\u0430\u0432\u0435\u0440\u0445\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">COMMONAPACHELOG %{IPORHOST:clientip} %{HTTPDUSER:ident} %{USER:auth} \\[%{HTTPDATE:timestamp}\\] &quot;(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP\/%{NUMBER:httpversion})?|%{DATA:rawrequest})&quot; %{NUMBER:response} (?:%{NUMBER:bytes}|-)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0447\u0442\u043e \u0441\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0430\u0434\u044b, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u043c\u0443 \u0441 \u043d\u0443\u043b\u044f. \u041f\u043e\u043b\u044f \u043c\u0435\u0442\u043e\u043a \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0432\u0430\u043c \u0448\u0430\u0431\u043b\u043e\u043d Go (\u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 Prometheus alerting \u0438 notification) \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044d\u0442\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0441\u0442\u0440\u043e\u043a \u0436\u0443\u0440\u043d\u0430\u043b\u0430, \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 Grok \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0432\u0430\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u043e\u0442\u0432\u0435\u0442\u0430\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">    - type: summary       name: apache_http_response_bytes       help: Size of HTTP responses       match: '%{COMMONAPACHELOG}'       value: '{{.bytes}}'<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043b\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u0431\u044b\u043b \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">    - type: gauge        name: apache_http_last_request_seconds       help: Timestamp of the last HTTP request       match: '%{COMMONAPACHELOG}'       value: '{{timestamp &quot;02\/Jan\/2006:15:04:05 -0700&quot; .timestamp}}'<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u0435\u0442\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (<strong>timestamp<\/strong>) grok exporter, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/golang.org\/pkg\/time\/#Parse\" rel=\"nofollow\">time.Parse<\/a> \u0438\u0437 Golang. \u0415\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f (<strong>divide<\/strong>), \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440\u043e\u043c Grok. \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438. <\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0447\u0430\u0442 \u043f\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c <a href=\"https:\/\/t.me\/metrics_ru\" rel=\"nofollow\">https:\/\/t.me\/metrics_ru<\/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\/post\/508870\/\"> https:\/\/habr.com\/ru\/post\/508870\/<\/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\/post\/508870\/\">\n<p>\u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 2 \u043f\u043e\u0441\u0442\u043e\u0432 \u043f\u0440\u043e grok exporter.<\/p>\n<p>  <\/p>\n<h1 id=\"pervyy-perevod-kak-ispolzovat-grok-exporter-dlya-sozdaniya-metrik-prometheus-iz-nestrukturirovannyh-zhurnalov\">\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: \u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c grok exporter \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a prometheus \u0438\u0437 \u043d\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432<\/h1>\n<p>  <\/p>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e grok exporter. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/fstab\/grok_exporter\" rel=\"nofollow\">grok exporter<\/a> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a prometheus \u0438\u0437 \u043d\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432.<\/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-306166","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/306166","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=306166"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/306166\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=306166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=306166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=306166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}