{"id":315,"date":"2025-02-14T00:26:07","date_gmt":"2025-02-13T22:26:07","guid":{"rendered":"https:\/\/olvas.dev\/?p=315"},"modified":"2025-02-14T00:26:08","modified_gmt":"2025-02-13T22:26:08","slug":"%d1%82%d0%b5%d0%ba%d1%81%d1%82%d0%be%d0%b2%d0%b0%d1%8f-%d0%be%d0%b1%d1%80%d0%b0%d0%b1%d0%be%d1%82%d0%ba%d0%b0-%d0%b2-postgresql-grep-sed-awk","status":"publish","type":"post","link":"https:\/\/olvas.dev\/?p=315","title":{"rendered":"\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432 PostgreSQL: grep, sed, awk"},"content":{"rendered":"\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e&nbsp;\u043f\u0438\u0448\u0435\u0442 PostgreSQL \u0432 \/var\/log\/postgresql\/, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c, \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041d\u0435&nbsp;\u043d\u0443\u0436\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e&nbsp;\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u044b \u043b\u043e\u0433\u043e\u0432&nbsp;\u2014 \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441&nbsp;\u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c\u0438 \u0432&nbsp;\u043f\u0430\u0440\u0443 \u043a\u043e\u043c\u0430\u043d\u0434.<\/p>\n\n\n\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code><strong>grep<\/strong><\/code>\u00a0\u2014\u00a0\u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0449\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438, \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0438<\/li>\n\n\n\n<li><code><strong>sed<\/strong><\/code>\u00a0\u2014 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 PostgreSQL, \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/li>\n\n\n\n<li><code><strong>awk<\/strong><\/code>\u00a0\u2014 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u044b\u0440\u044b\u0435 \u043b\u043e\u0433\u0438 \u0432\u00a0\u043e\u0442\u0447\u0451\u0442\u044b<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">grep<\/h2>\n\n\n\n<p>grep&nbsp;\u2014 \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u043e\u043a \u0432&nbsp;\u0444\u0430\u0439\u043b\u0430\u0445 \u043f\u043e&nbsp;\u0448\u0430\u0431\u043b\u043e\u043d\u0443. \u041e\u043d\u0430&nbsp;\u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432&nbsp;\u043b\u043e\u0433\u0430\u0445, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u0445 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445.<\/p>\n\n\n\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep \"\u0448\u0430\u0431\u043b\u043e\u043d\" \u0444\u0430\u0439\u043b<\/code><\/pre>\n\n\n\n<p>\u0415\u0441\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0430\u0439\u0434\u0435\u043d, grep \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0432\u0441\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f.<\/p>\n\n\n\n<p>\u041a\u043e\u0433\u0434\u0430 PostgreSQL \u043f\u0438\u0448\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u043e\u043d\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u043b\u043e\u0432\u0430 ERROR, FATAL \u0438\u043b\u0438&nbsp;PANIC. \u041d\u0430\u0439\u0434\u0451\u043c \u0438\u0445:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep \"ERROR\" \/var\/log\/postgresql\/postgresql.log<\/code><\/pre>\n\n\n\n<p>\u042d\u0442\u043e \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441&nbsp;\u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.<\/p>\n\n\n\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0432&nbsp;\u043b\u043e\u0433\u0430\u0445 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438\u0434\u0443\u0442 \u0432&nbsp;\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u0434\u043e&nbsp;\u0438 \u043f\u043e\u0441\u043b\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -B3 -A3 \"ERROR\" \/var\/log\/postgresql\/postgresql.log<\/code><\/pre>\n\n\n\n<p>\u0417\u0434\u0435\u0441\u044c:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u2011B3\u00a0\u2014 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c 3\u00a0\u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0435\u0440\u0435\u0434 \u043e\u0448\u0438\u0431\u043a\u043e\u0439<\/li>\n\n\n\n<li>\u2011A3\u00a0\u2014 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c 3\u00a0\u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/li>\n<\/ul>\n\n\n\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f: PANIC, FATAL, ERROR. \u041d\u0430\u0439\u0434\u0451\u043c \u0438\u0445 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -E \"PANIC|FATAL|ERROR\" \/var\/log\/postgresql\/postgresql.log<\/code><\/pre>\n\n\n\n<p>\u0424\u043b\u0430\u0433&nbsp;<code>\u2011E<\/code>&nbsp;\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438, \u0430&nbsp;<code>|<\/code>&nbsp;\u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u0438\u043b\u0438\u00bb.<\/p>\n\n\n\n<p>\u0415\u0441\u043b\u0438 \u0432&nbsp;postgresql.conf \u0432\u043a\u043b\u044e\u0447\u0435\u043d&nbsp;<code>log_min_duration_statement<\/code>, PostgreSQL \u043f\u0438\u0448\u0435\u0442 \u0432&nbsp;\u043b\u043e\u0433\u0430\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u0438\u0434\u0430:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LOG: duration: 2500 ms statement: SELECT * FROM users WHERE active = false;<\/code><\/pre>\n\n\n\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0432\u0448\u0438\u0435\u0441\u044f \u0434\u043e\u043b\u044c\u0448\u0435 2&nbsp;\u0441\u0435\u043a\u0443\u043d\u0434:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep \"duration: &#91;2-9]&#91;0-9]&#91;0-9]&#91;0-9] ms\" \/var\/log\/postgresql\/postgresql.log<\/code><\/pre>\n\n\n\n<p>\u0410&nbsp;\u0435\u0441\u043b\u0438 \u0438\u0449\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043e\u043b\u044c\u0448\u0435 5&nbsp;\u0441\u0435\u043a\u0443\u043d\u0434:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -E \"duration: (&#91;5-9]&#91;0-9]{3}|&#91;1-9]&#91;0-9]{4,}) ms\" \/var\/log\/postgresql\/postgresql.log<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u044b\u0435 \u0442\u044f\u0436\u0451\u043b\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">sed<\/h2>\n\n\n\n<p>sed&nbsp;\u2014 \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0435\u043a\u0441\u0442,<\/li>\n\n\n\n<li>\u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438,<\/li>\n\n\n\n<li>\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0431\u0435\u0437\u00a0\u0438\u0445 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f.<\/li>\n<\/ul>\n\n\n\n<p>\u0412\u043e&nbsp;\u043c\u043d\u043e\u0433\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b (#). \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0445 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's\/^#\/\/' \/etc\/postgresql\/14\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u044b.<\/p>\n\n\n\n<p>sed \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's\/^work_mem = .*$\/work_mem = 128MB\/' \/etc\/postgresql\/14\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 128MB \u043d\u0430&nbsp;\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0445\u0435\u0448\u2011\u0434\u0436\u043e\u0438\u043d\u044b, \u0430&nbsp;\u043d\u0435 4MB, \u043a\u0430\u043a&nbsp;\u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e&nbsp;\u0434\u0435\u0444\u043e\u043b\u0442\u0443.<\/p>\n\n\n\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433 \u0447\u0438\u0442\u0430\u0435\u043c\u0435\u0435, \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i '\/^$\/d' \/etc\/postgresql\/14\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0432&nbsp;postgresql.conf \u043c\u043e\u0433\u0443\u0442&nbsp;\u0431\u044b\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u044b \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0434\u0430\u043b\u0438\u043c \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0433\u0434\u0435&nbsp;<code>log_statement =<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i '\/^log_statement =\/d' \/etc\/postgresql\/14\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n<p>\u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0443\u0434\u0430\u043b\u0438\u0442 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430&nbsp;<code>log_statement =<\/code>.<\/p>\n\n\n\n<p>\u0410&nbsp;\u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c&nbsp;<code>max_connections<\/code>&nbsp;\u043d\u0430 200:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's\/^max_connections = .*$\/max_connections = 200\/' \/etc\/postgresql\/14\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c PostgreSQL \u043d\u0435&nbsp;\u0437\u0430\u0434\u043e\u0445\u043d\u0451\u0442\u0441\u044f \u043e\u0442&nbsp;\u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n\n\n\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432&nbsp;\u043a\u043e\u043d\u0444\u0438\u0433\u0435, \u043d\u043e&nbsp;\u043d\u0443\u0436\u043d\u043e \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0435\u0441\u0442\u044c&nbsp;\u043b\u0438&nbsp;<code>log_connections<\/code>, \u0438 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442&nbsp;\u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u043c:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -q '^log_connections' \/etc\/postgresql\/14\/main\/postgresql.conf || echo 'log_connections = on' &gt;&gt; \/etc\/postgresql\/14\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c PostgreSQL \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n\n\n\n<p>\u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432&nbsp;\u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d (#), sed \u0435\u0433\u043e \u043d\u0435&nbsp;\u0438\u0437\u043c\u0435\u043d\u0438\u0442. \u041d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's\/^#*\\(log_duration =\\).*\/\\1 on\/' \/etc\/postgresql\/14\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043a\u043b\u044e\u0447\u0451\u043d \u043b\u043e\u0433 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n\n\n\n<p>\u0415\u0441\u043b\u0438 \u0432&nbsp;postgresql.conf \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i '$!N; \/^\\(.*\\)\\n\\1$\/!P; D' \/etc\/postgresql\/14\/main\/postgresql.conf<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">awk<\/h2>\n\n\n\n<p>awk&nbsp;\u2014 \u044d\u0442\u043e \u043a\u0430\u043a&nbsp;grep, \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0430\u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443.<\/p>\n\n\n\n<p>\u041d\u0430\u0439\u0434\u0451\u043c \u0422\u041e\u041f-10&nbsp;\u0441\u0430\u043c\u044b\u0445 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432&nbsp;\u043b\u043e\u0433\u0430\u0445 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0438\u0434\u0430:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LOG: duration: 3400 ms statement: SELECT * FROM transactions;<\/code><\/pre>\n\n\n\n<p>\u041d\u0430\u0439\u0434\u0451\u043c \u0442\u043e\u043f-10&nbsp;\u0441\u0430\u043c\u044b\u0445 \u0434\u043e\u043b\u0433\u0438\u0445:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>awk '\/duration:\/ {print $3, $6, $8}' \/var\/log\/postgresql\/postgresql.log | sort -nr | head -10<\/code><\/pre>\n\n\n\n<p>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\/duration:\/<\/code>\u00a0\u2014 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u00a0duration:.<\/li>\n\n\n\n<li><code>print $3, $6, $8<\/code>\u00a0\u2014 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 SQL\u2011\u0437\u0430\u043f\u0440\u043e\u0441.<\/li>\n\n\n\n<li><code>sort -nr<\/code>\u00a0\u2014 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u00a0\u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/li>\n\n\n\n<li><code>head -10<\/code>\u00a0\u2014 \u0431\u0435\u0440\u0451\u043c \u0442\u043e\u043f-10\u00a0\u0441\u0430\u043c\u044b\u0445 \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/li>\n<\/ul>\n\n\n\n<p>\u041a\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e?<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>awk '\/ERROR\/ {count&#91;$0]++} END {for (line in count) print count&#91;line], line}' \/var\/log\/postgresql\/postgresql.log | sort -nr | head -10<\/code><\/pre>\n\n\n\n<p>\u0412\u044b\u0432\u0435\u0434\u0435\u0442 \u0422\u041e\u041f-10&nbsp;\u0441\u0430\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c SQL\u2011\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e&nbsp;\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432&nbsp;\u043b\u043e\u0433\u0430\u0445 \u0435\u0441\u0442\u044c:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LOG: duration: 1200 ms statement: UPDATE users SET balance = balance - 100 WHERE id = 42;<\/code><\/pre>\n\n\n\n<p>\u0410&nbsp;\u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043e\u043b\u044c\u0448\u0435 2&nbsp;\u0441\u0435\u043a\u0443\u043d\u0434:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>awk '\/duration:\/ {split($2, t, \" \"); if (t&#91;1] &gt; 2000) print $0}' \/var\/log\/postgresql\/postgresql.log<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043b\u0433\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n\n\n\n<p>\u041f\u043e\u0434\u0441\u0447\u0451\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e&nbsp;\u0442\u0438\u043f\u0443:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>awk '\/statement:\/ {type&#91;$6]++} END {for (t in type) print t, type&#91;t]}' \/var\/log\/postgresql\/postgresql.log<\/code><\/pre>\n\n\n\n<p>\u0412\u044b\u0432\u0435\u0434\u0435\u0442:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT 154\nINSERT 23\nUPDATE 98\nDELETE 17<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442 \u0431\u0430\u0437\u0443.<\/p>\n\n\n\n<p>\u0415\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0451\u043d&nbsp;<code>log_executor_stats<\/code>, \u0442\u043e \u0432&nbsp;\u043b\u043e\u0433\u0430\u0445 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LOG: executor runtime: 450 ms<\/code><\/pre>\n\n\n\n<p>\u0412\u044b\u0442\u0430\u0449\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>awk '\/executor runtime:\/ {sum+=$3; count++} END {if (count&gt;0) print \"\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f CPU:\", sum\/count, \"\u043c\u0441\"}' \/var\/log\/postgresql\/postgresql.log<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043d\u0430&nbsp;\u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u0421\u043a\u0440\u0438\u043f\u0442 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 PostgreSQL<\/h2>\n\n\n\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c<strong>&nbsp;\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433<\/strong>&nbsp;\u043b\u043e\u0433\u043e\u0432 PostgreSQL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430&nbsp;\u0435\u0441\u043b\u0438 \u0447\u0442\u043e\u2011\u0442\u043e \u0438\u0434\u0451\u0442 \u043d\u0435&nbsp;\u0442\u0430\u043a&nbsp;\u2014 \u0441\u0440\u0430\u0437\u0443 \u043f\u0438\u043d\u0430\u0435\u0442 \u0432&nbsp;Telegram.<\/p>\n\n\n\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e&nbsp;PostgreSQL \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u0438\u0448\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u043b\u043e\u0433\u0438. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432&nbsp;postgresql.conf \u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432\u043e\u0442 \u044d\u0442\u043e:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>log_min_duration_statement = 1000  # \u041b\u043e\u0433\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043e\u043b\u044c\u0448\u0435 1 \u0441\u0435\u043a\u0443\u043d\u0434\u044b  <br>log_statement = 'mod'              # \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f (INSERT, UPDATE, DELETE)  <br>log_connections = on                # \u0424\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f  <br>log_disconnections = on             # \u0424\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f  <br>log_executor_stats = on             # \u041b\u043e\u0433\u0438\u0440\u0443\u0435\u043c CPU-\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443  <\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0435&nbsp;\u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart postgresql<\/code><\/pre>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0430\u043c \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445, \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043f-5&nbsp;\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u0438\u043d\u0430\u0442\u044c \u0432&nbsp;Telegram, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e\u2011\u0442\u043e \u0438\u0434\u0451\u0442 \u043d\u0435&nbsp;\u0442\u0430\u043a.<\/p>\n\n\n\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432\u043e\u0442 \u044d\u0442\u043e \u0432&nbsp;<code>\/opt\/postgresql_<\/code><a href=\"http:\/\/monitor.sh\/\" target=\"_blank\" rel=\"noreferrer noopener\"><code>monitor.sh<\/code><\/a>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash<br><br>LOG_FILE=\"\/var\/log\/postgresql\/postgresql.log\"<br>ERROR_LOG=\"\/var\/log\/pg_errors.log\"<br>SLOW_LOG=\"\/var\/log\/pg_slow_queries.log\"<br>TELEGRAM_BOT_TOKEN=\"\u0432\u0430\u0448_\u0442\u043e\u043a\u0435\u043d\"<br>TELEGRAM_CHAT_ID=\"\u0432\u0430\u0448_chat_id\"<br>THRESHOLD_MS=5000  # \u041f\u043e\u0440\u043e\u0433 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (5 \u0441\u0435\u043a\u0443\u043d\u0434)<br><br>echo \"=== PostgreSQL Log Monitor: $(date) ===\" &gt;&gt; $ERROR_LOG<br><br># \u0418\u0449\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438<br>ERRORS=$(grep -E \"ERROR|FATAL|PANIC\" \"$LOG_FILE\" | tail -10)<br><strong>if<\/strong> &#91;&#91; ! -z \"$ERRORS\" ]]; <strong>then<\/strong><br>    echo \"\u041d\u0430\u0439\u0434\u0435\u043d\u044b \u043e\u0448\u0438\u0431\u043a\u0438:\" &gt;&gt; $ERROR_LOG<br>    echo \"$ERRORS\" &gt;&gt; $ERROR_LOG<br>    curl -s -X POST \"https:\/\/api.telegram.org\/bot$TELEGRAM_BOT_TOKEN\/sendMessage\" \\<br>        -d chat_id=\"$TELEGRAM_CHAT_ID\" \\<br>        -d text=\"PostgreSQL \u041e\u0448\u0438\u0431\u043a\u0438: $ERRORS\"<br><strong>fi<\/strong><br><br># \u041c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b<br>SLOW_QUERIES=$(awk -v threshold=\"$THRESHOLD_MS\" '\/duration:\/ {split($2, time, \" \"); if (time&#91;1] &gt; threshold) print $0}' \"$LOG_FILE\" | tail -10)<br><strong>if<\/strong> &#91;&#91; ! -z \"$SLOW_QUERIES\" ]]; <strong>then<\/strong><br>    echo \"\u041c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b:\" &gt;&gt; $SLOW_LOG<br>    echo \"$SLOW_QUERIES\" &gt;&gt; $SLOW_LOG<br>    curl -s -X POST \"https:\/\/api.telegram.org\/bot$TELEGRAM_BOT_TOKEN\/sendMessage\" \\<br>        -d chat_id=\"$TELEGRAM_CHAT_ID\" \\<br>        -d text=\"PostgreSQL \u041c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b: $SLOW_QUERIES\"<br><strong>fi<\/strong><br><br># \u041f\u043e\u0434\u0441\u0447\u0451\u0442 \u043e\u0448\u0438\u0431\u043e\u043a<br>ERROR_STATS=$(awk '\/ERROR\/ {count++} END {print count}' \"$LOG_FILE\")<br>echo \"\u041e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0448\u0438\u0431\u043e\u043a: $ERROR_STATS\" &gt;&gt; $ERROR_LOG<br><br># \u0422\u043e\u043f-5 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<br>TOP_SLOW=$(awk '\/duration:\/ {print $3, $6, $8}' \"$LOG_FILE\" | sort -nr | head -5)<br>echo \"\u0422\u043e\u043f-5 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:\" &gt;&gt; $SLOW_LOG<br>echo \"$TOP_SLOW\" &gt;&gt; $SLOW_LOG<br><br># \u0415\u0441\u043b\u0438 \u043b\u043e\u0433\u0438 \u0440\u0430\u0437\u0434\u0443\u043b\u0438\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0435 500MB \u2014 \u0447\u0438\u0441\u0442\u0438\u043c<br>LOG_SIZE=$(du -m \"$LOG_FILE\" | cut -f1)<br><strong>if<\/strong> &#91;&#91; \"$LOG_SIZE\" -gt 500 ]]; <strong>then<\/strong><br>    echo \"\u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u043b\u043e\u0433\u043e\u0432 PostgreSQL: \u0440\u0430\u0437\u043c\u0435\u0440 $LOG_SIZE MB\" &gt;&gt; $ERROR_LOG<br>    cat \/dev\/null &gt; \"$LOG_FILE\"<br><strong>fi<\/strong><br><br>echo \"=== \u041a\u043e\u043d\u0435\u0446 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 ===\" &gt;&gt; $ERROR_LOG<\/code><\/pre>\n\n\n\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0433\u043e\u0442\u043e\u0432, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a.<\/p>\n\n\n\n<p>\u0412\u044b\u0434\u0430\u0451\u043c \u043f\u0440\u0430\u0432\u0430:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x \/opt\/postgresql_monitor.sh<\/code><\/pre>\n\n\n\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432&nbsp;cron, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0435 5&nbsp;\u043c\u0438\u043d\u0443\u0442:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"*\/5 * * * * root \/opt\/postgresql_monitor.sh\" &gt;&gt; \/etc\/crontab<\/code><\/pre>\n\n\n\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043b\u043e\u0433\u0438 PostgreSQL \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438. \u041e\u043d \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432&nbsp;\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u0440\u0438&nbsp;\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0432&nbsp;Telegram. \u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u043e\u0433\u043e\u0432 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 500MB, \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0438\u0445, \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u044f \u0437\u0430\u0445\u043b\u0430\u043c\u043b\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u043a\u0430.<\/p>\n\n\n\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0443 \u043e\u0448\u0438\u0431\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0431\u043e\u0438 \u0441\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,&nbsp;<code>duplicate key<\/code>,&nbsp;<code>out of memory<\/code>,&nbsp;<code>disk full<\/code>). \u0415\u0441\u043b\u0438 PostgreSQL \u043f\u0438\u0448\u0435\u0442 \u043b\u043e\u0433\u0438 \u0432&nbsp;JSON, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0445 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0438 \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u0440\u0438&nbsp;\u0441\u0431\u043e\u044f\u0445 (<code>FATAL: too many connections<\/code>) \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440, \u0430&nbsp;\u0434\u043b\u044f&nbsp;\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c Grafana Loki + Prometheus.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0441\u0451, \u0447\u0442\u043e&nbsp;\u043f\u0438\u0448\u0435\u0442 PostgreSQL \u0432 \/var\/log\/postgresql\/, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c, \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041d\u0435&nbsp;\u043d\u0443\u0436\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e&nbsp;\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u044b \u043b\u043e\u0433\u043e\u0432&nbsp;\u2014 \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441&nbsp;\u043a\u043e\u043d\u0444\u0438\u0433\u0430\u043c\u0438 \u0432&nbsp;\u043f\u0430\u0440\u0443 \u043a\u043e\u043c\u0430\u043d\u0434. \u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e: grep grep&nbsp;\u2014 \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u043e\u043a \u0432&nbsp;\u0444\u0430\u0439\u043b\u0430\u0445 \u043f\u043e&nbsp;\u0448\u0430\u0431\u043b\u043e\u043d\u0443. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":316,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[20,18,17,19],"class_list":["post-315","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-likbez","tag-awk","tag-grep","tag-postgresql","tag-sed","entry-card--landscape"],"_links":{"self":[{"href":"https:\/\/olvas.dev\/index.php?rest_route=\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/olvas.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/olvas.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/olvas.dev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/olvas.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=315"}],"version-history":[{"count":1,"href":"https:\/\/olvas.dev\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":317,"href":"https:\/\/olvas.dev\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions\/317"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/olvas.dev\/index.php?rest_route=\/wp\/v2\/media\/316"}],"wp:attachment":[{"href":"https:\/\/olvas.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/olvas.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/olvas.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}