{"id":1380,"date":"2020-07-10T13:42:28","date_gmt":"2020-07-10T11:42:28","guid":{"rendered":"https:\/\/blog.mhasin.eu\/?p=1380"},"modified":"2020-07-10T13:42:39","modified_gmt":"2020-07-10T11:42:39","slug":"syslog_ng-change-date-format-and-send-to-mysql","status":"publish","type":"post","link":"https:\/\/blog.mhasin.eu\/?p=1380","title":{"rendered":"SYSLOG_NG change date format and send to mysql"},"content":{"rendered":"\n<p>Nastavenie casu aky sa ma logovat, posielat do MYSQL..<\/p>\n\n\n\n<p>Nastavenie datumovych premenych:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"TOPIC-1044113\">Date-related macros<\/h4>\n\n\n\n<p><a href=\"https:\/\/www.syslog-ng.com\/technical-documents\/doc\/doc1044109\">template and rewrite: Format, modify, and manipulate log messages<\/a> &gt; <a href=\"https:\/\/www.syslog-ng.com\/technical-documents\/doc\/doc1044110\">Customize message format using macros and templates<\/a> &gt; Date-related macros<\/p>\n\n\n\n<p>The macros related to the date of the message (for example: ${ISODATE}, ${HOUR}, and so on) have three further variants each:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>S_ prefix, for example, ${S_DATE}: The ${S_DATE} macro represents the date found in the log message, that is, when the message was sent by the original application. <img decoding=\"async\" src=\"https:\/\/www.syslog-ng.com\/technical-documents\/doc\/image\/2b1c9a6b-448c-4fa6-9fb3-5dd1f72e8c27\"> Caution: To use the S_ macros, the keep-timestamp() option must be enabled (this is the default behavior of syslog-ng OSE).<\/li><li>R_ prefix, for example, ${R_DATE}: ${R_DATE} is the date when syslog-ng OSE has received the message.<\/li><li>C_ prefix, for example, ${C_DATE}: ${C_DATE} is the current date, that is when syslog-ng OSE processes the message and resolves the macro.<\/li><\/ul>\n\n\n\n<p>The ${DATE} macro equals the ${S_DATE} macro.<\/p>\n\n\n\n<p>The values of the date-related macros are calculated using the original timezone information of the message. To convert it to a different timezone, use the time-zone() option. You can set the time-zone() option as a global option, or per destination. For sources, it applies only if the original message does not contain timezone information. Converting the timezone changes the values of the following date-related macros (macros MSEC and USEC are not changed):<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>AMPM<\/li><li>DATE<\/li><li>DAY<\/li><li>FULLDATE<\/li><li>HOUR<\/li><li>HOUR12<\/li><li>ISODATE<\/li><li>MIN<\/li><li>MONTH<\/li><li>MONTH_ABBREV<\/li><li>MONTH_NAME<\/li><li>MONTH_WEEK<\/li><li>SEC<\/li><li>STAMP<\/li><li>TZ<\/li><li>TZOFFSET<\/li><li>UNIXTIME<\/li><li>WEEK<\/li><li>WEEK_DAY<\/li><li>WEEK_DAY_ABBREV<\/li><li>WEEK_DAY_NAME<\/li><li>YEAR<\/li><li>YEAR_DAY<\/li><\/ul>\n\n\n\n<p>Zdroj:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;www.syslog-ng.com\/technical-documents\/doc\/syslog-ng-open-source-edition\/3.18\/administration-guide\/60<\/code><\/pre>\n\n\n\n<p>nastavenie logovania do MYSQL<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>destination d_mysql_vala {\n\n\nsql(\ntype(mysql)\nhost(\"192.168.191.21\")\nusername(\"syslogadmin\")\npassword(\"remotelog\")\ndatabase(\"lmsfin\")\ntable(\"logs\")\ncolumns(\"host\", \"facility\", \"priority\", \"level\", \"tag\", \"date\", \"time\", \"program\", \"msg\")\n#values(\"$HOST\", \"$FACILITY\", \"$PRIORITY\", \"$LEVEL\", \"$TAG\",\"$YEAR-$MONTH-$DAY\", \"$HOUR:$MIN:$SEC\",\"$PROGRAM\", \"$MSG\")\nvalues(\"$HOST\", \"$FACILITY\", \"$PRIORITY\", \"$LEVEL\", \"$TAG\",\"$C_YEAR-$C_MONTH-$C_DAY\", \"$C_HOUR:$C_MIN:$C_SEC\",\"$PROGRAM\", \"$MSG\")\n\nindexes(\"datetime\", \"host\", \"program\", \"msg\")\n);\n\n\n\n    };\n<\/code><\/pre>\n<div class=\"pdf24Plugin-cp\"> \t<form name=\"pdf24Form0\" method=\"post\" action=\"https:\/\/doc2pdf.pdf24.org\/wordpress.php\" target=\"pdf24PopWin\" onsubmit=\"var pdf24Win = window.open('about:blank', 'pdf24PopWin', 'resizable=yes,scrollbars=yes,width=600,height=250,left='+(screen.width\/2-300)+',top='+(screen.height\/3-125)+''); pdf24Win.focus(); if(typeof pdf24OnCreatePDF === 'function'){void(pdf24OnCreatePDF(this,pdf24Win));}\"> \t\t<input type=\"hidden\" name=\"blogCharset\" value=\"Cw1x07UAAA==\" \/><input type=\"hidden\" name=\"blogPosts\" value=\"MwQA\" \/><input type=\"hidden\" name=\"blogUrl\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLQUA\" \/><input type=\"hidden\" name=\"blogName\" value=\"c\/LxdwcA\" \/><input type=\"hidden\" name=\"blogValueEncoding\" value=\"gzdeflate base64\" \/><input type=\"hidden\" name=\"postId_0\" value=\"MzS2MAAA\" \/><input type=\"hidden\" name=\"postTitle_0\" value=\"C44M9vF3j\/dzV0jOSMxLT1VISSxJVUjLL8pNLFFIzEtRKE4FEiX5CrmVxYU5AA==\" \/><input type=\"hidden\" name=\"postLink_0\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLdW3L7A1NLYwAAA=\" \/><input type=\"hidden\" name=\"postAuthor_0\" value=\"y00syfcwNAIA\" \/><input type=\"hidden\" name=\"postDateTime_0\" value=\"MzIwMtA1MNc1NFAwNLYyMLcysgAA\" \/><input type=\"hidden\" name=\"postContent_0\" value=\"rVZtb9pIEP7Orxi5qAIJQ0i5NC8EiVLSogshB6R36Re02Gu8F9vretdQGvW\/38waG5wmUnR3SIlnZl+eeXlm7Eo37t0wpdmaR4KDw1QK7GELikHIIJAruWa6AbFUggdMgythfD\/747rZ7LbiXgV\/5QtcptNQrreOD3HCQx6hdF5s9TvgBEypS2sT28tAOg+2z5kropUFwr205pPb0cBuH3U67fY7q\/eRaW4nhMtddMdJpOq2\/E4O22XgJ9y7tHytY3Xeam02m6baKvTajlZNR4YtzR0\/Eg4L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7bBnzyM7YbXNXECtb75rt0xZzQxEhFRLDVHuVCpe3To66LQONPiY8dzvaf01l31+RYMV316ujOeg5cBfhVn0LFkh9Bo94GpVaRW9jXjML9Yovla5Z7bPjZvvktNk+azeP21a9giMhiVjIa1YWookC7THibmTi1iz8xpOa4xJasYPYkincHYTKMxs1vWhQlyuFmiODNIxUzSI4qwGWxxwRCL0lOU7wpbOTA77mAQmarehBvWlUbOhsr1wlLCQxVAT9JuvqmlX9PJnNyV696g9G16P5vVFup6PJNFeuh1+G10aa9z9ZDatKDLKrhvp2FZlk1qjVzqvYUedV7ADadjudfJr2x2Z1PPuEsP8JdbDIcAeLHTK9wrK9g0WGjkuEP1i86EFFRC7\/Tj5QjvL85Pn9JU\/1CyIP4O\/nRaVMvn8A\" \/> \t\t<a href=\"https:\/\/www.pdf24.org\" target=\"_blank\" title=\"www.pdf24.org\" rel=\"nofollow\"><img src=\"https:\/\/blog.mhasin.eu\/wp-content\/plugins\/pdf24-post-to-pdf\/img\/pdf_32x32.png\" alt=\"\" border=\"0\" height=\"32\" \/><\/a> \t\t<span class=\"pdf24Plugin-cp-space\">&nbsp;&nbsp;<\/span> \t\t<span class=\"pdf24Plugin-cp-text\">Send article as PDF<\/span> \t\t<span class=\"pdf24Plugin-cp-space\">&nbsp;&nbsp;<\/span> \t\t<input class=\"pdf24Plugin-cp-input\" style=\"margin: 0px;\" type=\"text\" name=\"sendEmailTo\" placeholder=\"Enter email address\" \/> \t\t<input class=\"pdf24Plugin-cp-submit\" style=\"margin: 0px;\" type=\"submit\" value=\"Send\" \/> \t<\/form> <\/div>","protected":false},"excerpt":{"rendered":"Nastavenie casu aky sa ma logovat, posielat do MYSQL.. Nastavenie datumovych premenych: Date-related macros template and rewrite: Format, modify, and manipulate log messages &gt; Customize message format using macros and templates &gt; Date-related macros The macros related to the date of the message (for example: ${ISODATE}, ${HOUR}, and so on) have three further variants each: S_ prefix, for example, ${S_DATE}: The ${S_DATE} macro represents the date found in the log message, that is, when the&hellip;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"arc_restricted_post":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1380","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1380"}],"version-history":[{"count":1,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1380\/revisions"}],"predecessor-version":[{"id":1381,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1380\/revisions\/1381"}],"wp:attachment":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}