@cryptotaxi247 / netdata-1 / commits / 5230b15f5

fixes for logging (#16459)

* fixes for logging * added log environment variables to cgroup-network * fix wrong condition * rename variable * fix leftovers * fix log2journal docs and logs

Costa Tsaousis committed Nov 22, 2023 at 21:47 UTC 5230b15f59fdd47efae668e5ac0c4ca042186e26
13 files changed +419 -256
collectors/cgroups.plugin/cgroup-name.sh.in
+5 -5
@@ -3,7 +3,7 @@
3
4 # netdata
5 # real-time performance and health monitoring, done right!
6 -# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
6 +# (C) 2023 Netdata Inc.
7 # SPDX-License-Identifier: GPL-3.0-or-later
8 #
9 # Script to find a better name for cgroups
@@ -33,7 +33,7 @@ NDLP_DEBUG=7 # debug-level messages
33 LOG_LEVEL=$NDLP_INFO
34
35 set_log_min_priority() {
36 - case "${NETDATA_LOG_PRIORITY_LEVEL,,}" in
36 + case "${NETDATA_LOG_LEVEL,,}" in
37 "emerg" | "emergency")
38 LOG_LEVEL=$NDLP_EMERG
39 ;;
@@ -76,14 +76,14 @@ log() {
76
77 [[ -n "$level" && -n "$LOG_LEVEL" && "$level" -gt "$LOG_LEVEL" ]] && return
78
79 - systemd-cat-native --log-as-netdata --newline="{NEWLINE}" <<EOFLOG
79 + systemd-cat-native --log-as-netdata --newline="--NEWLINE--" <<EOFLOG
80 INVOCATION_ID=${NETDATA_INVOCATION_ID}
81 SYSLOG_IDENTIFIER=${PROGRAM_NAME}
82 PRIORITY=${level}
83 -THREAD_TAG="cgroup-name"
83 +THREAD_TAG=cgroup-name
84 ND_LOG_SOURCE=collector
85 ND_REQUEST=${cmd_line}
86 -MESSAGE=${*//[$'\r\n']/{NEWLINE}}
86 +MESSAGE=${*//\\n/--NEWLINE--}
87
88 EOFLOG
89 # AN EMPTY LINE IS NEEDED ABOVE
collectors/cgroups.plugin/cgroup-network-helper.sh.in
+5 -5
@@ -4,7 +4,7 @@
4 # cgroup-network-helper.sh
5 # detect container and virtual machine interfaces
6 #
7 -# (C) 2017 Costa Tsaousis
7 +# (C) 2023 Netdata Inc.
8 # SPDX-License-Identifier: GPL-3.0-or-later
9 #
10 # This script is called as root (by cgroup-network), with either a pid, or a cgroup path.
@@ -51,7 +51,7 @@ NDLP_DEBUG=7 # debug-level messages
51 LOG_LEVEL=$NDLP_INFO
52
53 set_log_min_priority() {
54 - case "${NETDATA_LOG_PRIORITY_LEVEL,,}" in
54 + case "${NETDATA_LOG_LEVEL,,}" in
55 "emerg" | "emergency")
56 LOG_LEVEL=$NDLP_EMERG
57 ;;
@@ -94,14 +94,14 @@ log() {
94
95 [[ -n "$level" && -n "$LOG_LEVEL" && "$level" -gt "$LOG_LEVEL" ]] && return
96
97 - systemd-cat-native --log-as-netdata --newline="{NEWLINE}" <<EOFLOG
97 + systemd-cat-native --log-as-netdata --newline="--NEWLINE--" <<EOFLOG
98 INVOCATION_ID=${NETDATA_INVOCATION_ID}
99 SYSLOG_IDENTIFIER=${PROGRAM_NAME}
100 PRIORITY=${level}
101 -THREAD_TAG="cgroup-network-helper.sh"
101 +THREAD_TAG=cgroup-network-helper
102 ND_LOG_SOURCE=collector
103 ND_REQUEST=${cmd_line}
104 -MESSAGE=${*//[$'\r\n']/{NEWLINE}}
104 +MESSAGE=${*//\\n/--NEWLINE--}
105
106 EOFLOG
107 # AN EMPTY LINE IS NEEDED ABOVE
collectors/cgroups.plugin/cgroup-network.c
+20 -7
@@ -10,12 +10,16 @@
10 #include <sched.h>
11 #endif
12
13 -char environment_variable2[FILENAME_MAX + 50] = "";
14 -char environment_variable3[FILENAME_MAX + 50] = "";
13 +char env_netdata_host_prefix[FILENAME_MAX + 50] = "";
14 +char env_netdata_log_method[FILENAME_MAX + 50] = "";
15 +char env_netdata_log_format[FILENAME_MAX + 50] = "";
16 +char env_netdata_log_level[FILENAME_MAX + 50] = "";
17 char *environment[] = {
18 "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin",
17 - environment_variable2,
18 - environment_variable3,
19 + env_netdata_host_prefix,
20 + env_netdata_log_method,
21 + env_netdata_log_format,
22 + env_netdata_log_level,
23 NULL
24 };
25
@@ -671,11 +675,20 @@ int main(int argc, char **argv) {
675 // build a safe environment for our script
676
677 // the first environment variable is a fixed PATH=
674 - snprintfz(environment_variable2, sizeof(environment_variable2) - 1, "NETDATA_HOST_PREFIX=%s", netdata_configured_host_prefix);
678 + snprintfz(env_netdata_host_prefix, sizeof(env_netdata_host_prefix) - 1, "NETDATA_HOST_PREFIX=%s", netdata_configured_host_prefix);
679
676 - char *s = getenv("NETDATA_LOG_SEVERITY_LEVEL");
680 + char *s;
681 +
682 + s = getenv("NETDATA_LOG_METHOD");
683 + snprintfz(env_netdata_log_method, sizeof(env_netdata_log_method) - 1, "NETDATA_LOG_METHOD=%s", nd_log_method_for_external_plugins(s));
684 +
685 + s = getenv("NETDATA_LOG_FORMAT");
686 + if (s)
687 + snprintfz(env_netdata_log_format, sizeof(env_netdata_log_format) - 1, "NETDATA_LOG_FORMAT=%s", s);
688 +
689 + s = getenv("NETDATA_LOG_LEVEL");
690 if (s)
678 - snprintfz(environment_variable3, sizeof(environment_variable3) - 1, "NETDATA_LOG_SEVERITY_LEVEL=%s", s);
691 + snprintfz(env_netdata_log_level, sizeof(env_netdata_log_level) - 1, "NETDATA_LOG_LEVEL=%s", s);
692
693 // ------------------------------------------------------------------------
694
collectors/charts.d.plugin/charts.d.plugin.in
+2 -2
@@ -37,7 +37,7 @@ NDLP_DEBUG=7 # debug-level messages
37 LOG_LEVEL=$NDLP_INFO
38
39 set_log_min_priority() {
40 - case "${NETDATA_LOG_PRIORITY_LEVEL,,}" in
40 + case "${NETDATA_LOG_LEVEL,,}" in
41 "emerg" | "emergency")
42 LOG_LEVEL=$NDLP_EMERG
43 ;;
@@ -84,7 +84,7 @@ log() {
84 INVOCATION_ID=${NETDATA_INVOCATION_ID}
85 SYSLOG_IDENTIFIER=${PROGRAM_NAME}
86 PRIORITY=${level}
87 -THREAD_TAG="charts.d.plugin"
87 +THREAD_TAG=charts.d.plugin
88 ND_LOG_SOURCE=collector
89 MESSAGE=${MODULE_NAME}: ${*//[$'\r\n']}
90
collectors/ioping.plugin/ioping.plugin.in
+68 -29
@@ -9,7 +9,7 @@
9 # This plugin requires a latest version of ioping.
10 # You can compile it from source, by running me with option: install
11
12 -export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
12 +export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin:@sbindir_POST@"
13 export LC_ALL=C
14
15 usage="$(basename "$0") [install] [-h] [-e]
@@ -93,60 +93,99 @@ if [ "$INSTALL" == "1" ]
93 fi
94
95 # -----------------------------------------------------------------------------
96 +# logging
97
98 PROGRAM_NAME="$(basename "${0}")"
99
99 -LOG_LEVEL_ERR=1
100 -LOG_LEVEL_WARN=2
101 -LOG_LEVEL_INFO=3
102 -LOG_LEVEL="$LOG_LEVEL_INFO"
103 -
104 -set_log_severity_level() {
105 - case ${NETDATA_LOG_SEVERITY_LEVEL,,} in
106 - "info") LOG_LEVEL="$LOG_LEVEL_INFO";;
107 - "warn" | "warning") LOG_LEVEL="$LOG_LEVEL_WARN";;
108 - "err" | "error") LOG_LEVEL="$LOG_LEVEL_ERR";;
100 +# these should be the same with syslog() priorities
101 +NDLP_EMERG=0 # system is unusable
102 +NDLP_ALERT=1 # action must be taken immediately
103 +NDLP_CRIT=2 # critical conditions
104 +NDLP_ERR=3 # error conditions
105 +NDLP_WARN=4 # warning conditions
106 +NDLP_NOTICE=5 # normal but significant condition
107 +NDLP_INFO=6 # informational
108 +NDLP_DEBUG=7 # debug-level messages
109 +
110 +# the max (numerically) log level we will log
111 +LOG_LEVEL=$NDLP_INFO
112 +
113 +set_log_min_priority() {
114 + case "${NETDATA_LOG_LEVEL,,}" in
115 + "emerg" | "emergency")
116 + LOG_LEVEL=$NDLP_EMERG
117 + ;;
118 +
119 + "alert")
120 + LOG_LEVEL=$NDLP_ALERT
121 + ;;
122 +
123 + "crit" | "critical")
124 + LOG_LEVEL=$NDLP_CRIT
125 + ;;
126 +
127 + "err" | "error")
128 + LOG_LEVEL=$NDLP_ERR
129 + ;;
130 +
131 + "warn" | "warning")
132 + LOG_LEVEL=$NDLP_WARN
133 + ;;
134 +
135 + "notice")
136 + LOG_LEVEL=$NDLP_NOTICE
137 + ;;
138 +
139 + "info")
140 + LOG_LEVEL=$NDLP_INFO
141 + ;;
142 +
143 + "debug")
144 + LOG_LEVEL=$NDLP_DEBUG
145 + ;;
146 esac
147 }
148
112 -set_log_severity_level
113 -
114 -logdate() {
115 - date "+%Y-%m-%d %H:%M:%S"
116 -}
149 +set_log_min_priority
150
151 log() {
119 - local status="${1}"
120 - shift
152 + local level="${1}"
153 + shift 1
154 +
155 + [[ -n "$level" && -n "$LOG_LEVEL" && "$level" -gt "$LOG_LEVEL" ]] && return
156
122 - echo >&2 "$(logdate): ${PROGRAM_NAME}: ${status}: ${*}"
157 + systemd-cat-native --log-as-netdata <<EOFLOG
158 +INVOCATION_ID=${NETDATA_INVOCATION_ID}
159 +SYSLOG_IDENTIFIER=${PROGRAM_NAME}
160 +PRIORITY=${level}
161 +THREAD_TAG=ioping.plugin
162 +ND_LOG_SOURCE=collector
163 +MESSAGE=${MODULE_NAME}: ${*//[$'\r\n']}
164
165 +EOFLOG
166 + # AN EMPTY LINE IS NEEDED ABOVE
167 }
168
169 info() {
127 - [[ -n "$LOG_LEVEL" && "$LOG_LEVEL_INFO" -gt "$LOG_LEVEL" ]] && return
128 - log INFO "${@}"
170 + log "$NDLP_INFO" "${@}"
171 }
172
173 warning() {
132 - [[ -n "$LOG_LEVEL" && "$LOG_LEVEL_WARN" -gt "$LOG_LEVEL" ]] && return
133 - log WARNING "${@}"
174 + log "$NDLP_WARN" "${@}"
175 }
176
177 error() {
137 - [[ -n "$LOG_LEVEL" && "$LOG_LEVEL_ERR" -gt "$LOG_LEVEL" ]] && return
138 - log ERROR "${@}"
178 + log "$NDLP_ERR" "${@}"
179 }
180
181 fatal() {
142 - log FATAL "${@}"
182 + log "$NDLP_ALERT" "${@}"
183 echo "DISABLE"
144 - exit 1
184 + exit 1
185 }
186
147 -debug=0
187 debug() {
149 - [ $debug -eq 1 ] && log DEBUG "${@}"
188 + log "$NDLP_DEBUG" "${@}"
189 }
190
191 # -----------------------------------------------------------------------------
collectors/python.d.plugin/python.d.plugin.in
+1 -1
@@ -876,7 +876,7 @@ def main():
876 cmd = parse_command_line()
877 log = PythonDLogger()
878
879 - level = os.getenv('NETDATA_LOG_SEVERITY_LEVEL') or str()
879 + level = os.getenv('NETDATA_LOG_LEVEL') or str()
880 level = level.lower()
881 if level == 'debug':
882 log.logger.severity = 'DEBUG'
collectors/tc.plugin/tc-qos-helper.sh.in
+79 -20
@@ -2,54 +2,113 @@
2
3 # netdata
4 # real-time performance and health monitoring, done right!
5 -# (C) 2017 Costa Tsaousis <costa@tsaousis.gr>
5 +# (C) 2023 Netdata Inc.
6 # SPDX-License-Identifier: GPL-3.0-or-later
7 #
8 # This script is a helper to allow netdata collect tc data.
9 # tc output parsing has been implemented in C, inside netdata
10 # This script allows setting names to dimensions.
11
12 -export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
12 +export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin:@sbindir_POST@"
13 export LC_ALL=C
14
15 +cmd_line="'${0}' $(printf "'%s' " "${@}")"
16 +
17 # -----------------------------------------------------------------------------
16 -# logging functions
18 +# logging
19
18 -PROGRAM_NAME="$(basename "$0")"
20 +PROGRAM_NAME="$(basename "${0}")"
21 PROGRAM_NAME="${PROGRAM_NAME/.plugin/}"
22
21 -logdate() {
22 - date "+%Y-%m-%d %H:%M:%S"
23 +# these should be the same with syslog() priorities
24 +NDLP_EMERG=0 # system is unusable
25 +NDLP_ALERT=1 # action must be taken immediately
26 +NDLP_CRIT=2 # critical conditions
27 +NDLP_ERR=3 # error conditions
28 +NDLP_WARN=4 # warning conditions
29 +NDLP_NOTICE=5 # normal but significant condition
30 +NDLP_INFO=6 # informational
31 +NDLP_DEBUG=7 # debug-level messages
32 +
33 +# the max (numerically) log level we will log
34 +LOG_LEVEL=$NDLP_INFO
35 +
36 +set_log_min_priority() {
37 + case "${NETDATA_LOG_LEVEL,,}" in
38 + "emerg" | "emergency")
39 + LOG_LEVEL=$NDLP_EMERG
40 + ;;
41 +
42 + "alert")
43 + LOG_LEVEL=$NDLP_ALERT
44 + ;;
45 +
46 + "crit" | "critical")
47 + LOG_LEVEL=$NDLP_CRIT
48 + ;;
49 +
50 + "err" | "error")
51 + LOG_LEVEL=$NDLP_ERR
52 + ;;
53 +
54 + "warn" | "warning")
55 + LOG_LEVEL=$NDLP_WARN
56 + ;;
57 +
58 + "notice")
59 + LOG_LEVEL=$NDLP_NOTICE
60 + ;;
61 +
62 + "info")
63 + LOG_LEVEL=$NDLP_INFO
64 + ;;
65 +
66 + "debug")
67 + LOG_LEVEL=$NDLP_DEBUG
68 + ;;
69 + esac
70 }
71
25 -log() {
26 - local status="${1}"
27 - shift
72 +set_log_min_priority
73
29 - echo >&2 "$(logdate): ${PROGRAM_NAME}: ${status}: ${*}"
74 +log() {
75 + local level="${1}"
76 + shift 1
77 +
78 + [[ -n "$level" && -n "$LOG_LEVEL" && "$level" -gt "$LOG_LEVEL" ]] && return
79 +
80 + systemd-cat-native --log-as-netdata --newline="--NEWLINE--" <<EOFLOG
81 +INVOCATION_ID=${NETDATA_INVOCATION_ID}
82 +SYSLOG_IDENTIFIER=${PROGRAM_NAME}
83 +PRIORITY=${level}
84 +THREAD_TAG=tc-qos-helper
85 +ND_LOG_SOURCE=collector
86 +ND_REQUEST=${cmd_line}
87 +MESSAGE=${*//\\n/--NEWLINE--}
88 +
89 +EOFLOG
90 + # AN EMPTY LINE IS NEEDED ABOVE
91 +}
92
93 +info() {
94 + log "$NDLP_INFO" "${@}"
95 }
96
97 warning() {
34 - log WARNING "${@}"
98 + log "$NDLP_WARN" "${@}"
99 }
100
101 error() {
38 - log ERROR "${@}"
39 -}
40 -
41 -info() {
42 - log INFO "${@}"
102 + log "$NDLP_ERR" "${@}"
103 }
104
105 fatal() {
46 - log FATAL "${@}"
47 - exit 1
106 + log "$NDLP_ALERT" "${@}"
107 + exit 1
108 }
109
50 -debug=0
110 debug() {
52 - [ $debug -eq 1 ] && log DEBUG "${@}"
111 + log "$NDLP_DEBUG" "${@}"
112 }
113
114 # -----------------------------------------------------------------------------
health/notifications/alarm-notify.sh.in
+4 -4
@@ -98,7 +98,7 @@ NDLP_DEBUG=7 # debug-level messages
98 LOG_LEVEL=$NDLP_INFO
99
100 set_log_min_priority() {
101 - case "${NETDATA_LOG_PRIORITY_LEVEL,,}" in
101 + case "${NETDATA_LOG_LEVEL,,}" in
102 "emerg" | "emergency")
103 LOG_LEVEL=$NDLP_EMERG
104 ;;
@@ -141,11 +141,11 @@ log() {
141
142 [[ -n "$level" && -n "$LOG_LEVEL" && "$level" -gt "$LOG_LEVEL" ]] && return
143
144 - systemd-cat-native --log-as-netdata --newline="{NEWLINE}" <<EOFLOG
144 + systemd-cat-native --log-as-netdata --newline="--NEWLINE--" <<EOFLOG
145 INVOCATION_ID=${NETDATA_INVOCATION_ID}
146 SYSLOG_IDENTIFIER=${PROGRAM_NAME}
147 PRIORITY=${level}
148 -THREAD_TAG="alarm-notify"
148 +THREAD_TAG=alarm-notify
149 ND_LOG_SOURCE=health
150 ND_NIDL_NODE=${host}
151 ND_NIDL_INSTANCE=${chart}
@@ -169,7 +169,7 @@ ND_ALERT_INFO=${info}
169 ND_ALERT_DURATION=${duration}
170 ND_REQUEST=${cmd_line}
171 MESSAGE_ID=6db0018e83e34320ae2a659d78019fb7
172 -MESSAGE=[ALERT NOTIFICATION]: ${*//[$'\r\n']/{NEWLINE}}
172 +MESSAGE=[ALERT NOTIFICATION]: ${*//\\n/--NEWLINE--}
173
174 EOFLOG
175 # AN EMPTY LINE IS NEEDED ABOVE
libnetdata/log/log.c
+140 -133
@@ -40,54 +40,65 @@ static bool nd_log_limit_reached(struct nd_log_source *source);
40 // logging method
41
42 typedef enum __attribute__((__packed__)) {
43 - NDLO_DISABLED = 0,
44 - NDLO_DEVNULL,
45 - NDLO_DEFAULT,
46 - NDLO_JOURNAL,
47 - NDLO_SYSLOG,
48 - NDLO_STDOUT,
49 - NDLO_STDERR,
50 - NDLO_FILE,
51 -} ND_LOG_OUTPUT;
52 -
43 + NDLM_DISABLED = 0,
44 + NDLM_DEVNULL,
45 + NDLM_DEFAULT,
46 + NDLM_JOURNAL,
47 + NDLM_SYSLOG,
48 + NDLM_STDOUT,
49 + NDLM_STDERR,
50 + NDLM_FILE,
51 +} ND_LOG_METHOD;
52
53 static struct {
55 - ND_LOG_OUTPUT output;
54 + ND_LOG_METHOD method;
55 const char *name;
57 -} nd_log_outputs[] = {
58 - { .output = NDLO_DISABLED, .name = "none" },
59 - { .output = NDLO_DEVNULL, .name = "/dev/null" },
60 - { .output = NDLO_DEFAULT, .name = "default" },
61 - { .output = NDLO_JOURNAL, .name = "journal" },
62 - { .output = NDLO_SYSLOG, .name = "syslog" },
63 - { .output = NDLO_STDOUT, .name = "stdout" },
64 - { .output = NDLO_STDERR, .name = "stderr" },
65 - { .output = NDLO_FILE, .name = "file" },
56 +} nd_log_methods[] = {
57 + { .method = NDLM_DISABLED, .name = "none" },
58 + { .method = NDLM_DEVNULL, .name = "/dev/null" },
59 + { .method = NDLM_DEFAULT, .name = "default" },
60 + { .method = NDLM_JOURNAL, .name = "journal" },
61 + { .method = NDLM_SYSLOG, .name = "syslog" },
62 + { .method = NDLM_STDOUT, .name = "stdout" },
63 + { .method = NDLM_STDERR, .name = "stderr" },
64 + { .method = NDLM_FILE, .name = "file" },
65 };
66
68 -static ND_LOG_OUTPUT nd_log_output2id(const char *output) {
69 - if(!output || !*output)
70 - return NDLO_DEFAULT;
67 +static ND_LOG_METHOD nd_log_method2id(const char *method) {
68 + if(!method || !*method)
69 + return NDLM_DEFAULT;
70
72 - size_t entries = sizeof(nd_log_outputs) / sizeof(nd_log_outputs[0]);
71 + size_t entries = sizeof(nd_log_methods) / sizeof(nd_log_methods[0]);
72 for(size_t i = 0; i < entries ;i++) {
74 - if(strcmp(nd_log_outputs[i].name, output) == 0)
75 - return nd_log_outputs[i].output;
73 + if(strcmp(nd_log_methods[i].name, method) == 0)
74 + return nd_log_methods[i].method;
75 }
76
78 - return NDLO_FILE;
77 + return NDLM_FILE;
78 }
79
81 -static const char *nd_log_id2output(ND_LOG_OUTPUT output) {
82 - size_t entries = sizeof(nd_log_outputs) / sizeof(nd_log_outputs[0]);
80 +static const char *nd_log_id2method(ND_LOG_METHOD method) {
81 + size_t entries = sizeof(nd_log_methods) / sizeof(nd_log_methods[0]);
82 for(size_t i = 0; i < entries ;i++) {
84 - if(output == nd_log_outputs[i].output)
85 - return nd_log_outputs[i].name;
83 + if(method == nd_log_methods[i].method)
84 + return nd_log_methods[i].name;
85 }
86
87 return "unknown";
88 }
89
90 +#define IS_VALID_LOG_METHOD_FOR_EXTERNAL_PLUGINS(ndlo) ((ndlo) == NDLM_JOURNAL || (ndlo) == NDLM_SYSLOG || (ndlo) == NDLM_STDERR)
91 +
92 +const char *nd_log_method_for_external_plugins(const char *s) {
93 + if(s && *s) {
94 + ND_LOG_METHOD method = nd_log_method2id(s);
95 + if(IS_VALID_LOG_METHOD_FOR_EXTERNAL_PLUGINS(method))
96 + return nd_log_id2method(method);
97 + }
98 +
99 + return nd_log_id2method(NDLM_STDERR);
100 +}
101 +
102 // ----------------------------------------------------------------------------
103 // workaround strerror_r()
104
@@ -256,23 +267,23 @@ static const char *nd_log_source2str(ND_LOG_SOURCES source) {
267 // log output formats
268
269 typedef enum __attribute__((__packed__)) {
259 - NDLOF_JOURNAL,
260 - NDLOF_LOGFMT,
261 - NDLOF_JSON,
262 -} ND_LOG_OUTPUT_FORMAT;
270 + NDLF_JOURNAL,
271 + NDLF_LOGFMT,
272 + NDLF_JSON,
273 +} ND_LOG_FORMAT;
274
275 static struct {
265 - ND_LOG_OUTPUT_FORMAT format;
276 + ND_LOG_FORMAT format;
277 const char *name;
278 } nd_log_formats[] = {
268 - { .format = NDLOF_JOURNAL, .name = "journal" },
269 - { .format = NDLOF_LOGFMT, .name = "logfmt" },
270 - { .format = NDLOF_JSON, .name = "json" },
279 + { .format = NDLF_JOURNAL, .name = "journal" },
280 + { .format = NDLF_LOGFMT, .name = "logfmt" },
281 + { .format = NDLF_JSON, .name = "json" },
282 };
283
273 -static ND_LOG_OUTPUT_FORMAT nd_log_format2id(const char *format) {
284 +static ND_LOG_FORMAT nd_log_format2id(const char *format) {
285 if(!format || !*format)
275 - return NDLOF_LOGFMT;
286 + return NDLF_LOGFMT;
287
288 size_t entries = sizeof(nd_log_formats) / sizeof(nd_log_formats[0]);
289 for(size_t i = 0; i < entries ;i++) {
@@ -280,10 +291,10 @@ static ND_LOG_OUTPUT_FORMAT nd_log_format2id(const char *format) {
291 return nd_log_formats[i].format;
292 }
293
283 - return NDLOF_LOGFMT;
294 + return NDLF_LOGFMT;
295 }
296
286 -static const char *nd_log_id2format(ND_LOG_OUTPUT_FORMAT format) {
297 +static const char *nd_log_id2format(ND_LOG_FORMAT format) {
298 size_t entries = sizeof(nd_log_formats) / sizeof(nd_log_formats[0]);
299 for(size_t i = 0; i < entries ;i++) {
300 if(format == nd_log_formats[i].format)
@@ -333,8 +344,8 @@ struct nd_log_limit {
344
345 struct nd_log_source {
346 SPINLOCK spinlock;
336 - ND_LOG_OUTPUT method;
337 - ND_LOG_OUTPUT_FORMAT format;
347 + ND_LOG_METHOD method;
348 + ND_LOG_FORMAT format;
349 const char *filename;
350 int fd;
351 FILE *fp;
@@ -406,8 +417,8 @@ static struct {
417 .sources = {
418 [NDLS_UNSET] = {
419 .spinlock = NETDATA_SPINLOCK_INITIALIZER,
409 - .method = NDLO_DISABLED,
410 - .format = NDLOF_JOURNAL,
420 + .method = NDLM_DISABLED,
421 + .format = NDLF_JOURNAL,
422 .filename = NULL,
423 .fd = -1,
424 .fp = NULL,
@@ -416,8 +427,8 @@ static struct {
427 },
428 [NDLS_ACCESS] = {
429 .spinlock = NETDATA_SPINLOCK_INITIALIZER,
419 - .method = NDLO_DEFAULT,
420 - .format = NDLOF_LOGFMT,
430 + .method = NDLM_DEFAULT,
431 + .format = NDLF_LOGFMT,
432 .filename = LOG_DIR "/access.log",
433 .fd = -1,
434 .fp = NULL,
@@ -426,8 +437,8 @@ static struct {
437 },
438 [NDLS_ACLK] = {
439 .spinlock = NETDATA_SPINLOCK_INITIALIZER,
429 - .method = NDLO_FILE,
430 - .format = NDLOF_LOGFMT,
440 + .method = NDLM_FILE,
441 + .format = NDLF_LOGFMT,
442 .filename = LOG_DIR "/aclk.log",
443 .fd = -1,
444 .fp = NULL,
@@ -436,8 +447,8 @@ static struct {
447 },
448 [NDLS_COLLECTORS] = {
449 .spinlock = NETDATA_SPINLOCK_INITIALIZER,
439 - .method = NDLO_DEFAULT,
440 - .format = NDLOF_LOGFMT,
450 + .method = NDLM_DEFAULT,
451 + .format = NDLF_LOGFMT,
452 .filename = LOG_DIR "/collectors.log",
453 .fd = STDERR_FILENO,
454 .fp = NULL,
@@ -446,8 +457,8 @@ static struct {
457 },
458 [NDLS_DEBUG] = {
459 .spinlock = NETDATA_SPINLOCK_INITIALIZER,
449 - .method = NDLO_DISABLED,
450 - .format = NDLOF_LOGFMT,
460 + .method = NDLM_DISABLED,
461 + .format = NDLF_LOGFMT,
462 .filename = LOG_DIR "/debug.log",
463 .fd = STDOUT_FILENO,
464 .fp = NULL,
@@ -456,9 +467,9 @@ static struct {
467 },
468 [NDLS_DAEMON] = {
469 .spinlock = NETDATA_SPINLOCK_INITIALIZER,
459 - .method = NDLO_DEFAULT,
470 + .method = NDLM_DEFAULT,
471 .filename = LOG_DIR "/daemon.log",
461 - .format = NDLOF_LOGFMT,
472 + .format = NDLF_LOGFMT,
473 .fd = -1,
474 .fp = NULL,
475 .min_priority = NDLP_INFO,
@@ -466,8 +477,8 @@ static struct {
477 },
478 [NDLS_HEALTH] = {
479 .spinlock = NETDATA_SPINLOCK_INITIALIZER,
469 - .method = NDLO_DEFAULT,
470 - .format = NDLOF_LOGFMT,
480 + .method = NDLM_DEFAULT,
481 + .format = NDLF_LOGFMT,
482 .filename = LOG_DIR "/health.log",
483 .fd = -1,
484 .fp = NULL,
@@ -520,11 +531,11 @@ void nd_log_set_user_settings(ND_LOG_SOURCES source, const char *setting) {
531 if (!name || !*name) continue;
532
533 if(strcmp(name, "logfmt") == 0)
523 - ls->format = NDLOF_LOGFMT;
534 + ls->format = NDLF_LOGFMT;
535 else if(strcmp(name, "json") == 0)
525 - ls->format = NDLOF_JSON;
536 + ls->format = NDLF_JSON;
537 else if(strcmp(name, "journal") == 0)
527 - ls->format = NDLOF_JOURNAL;
538 + ls->format = NDLF_JOURNAL;
539 else if(strcmp(name, "level") == 0 && value && *value)
540 ls->min_priority = nd_log_priority2id(value);
541 else if(strcmp(name, "protection") == 0 && value && *value) {
@@ -557,45 +568,45 @@ void nd_log_set_user_settings(ND_LOG_SOURCES source, const char *setting) {
568 }
569
570 if(!output || !*output || strcmp(output, "none") == 0 || strcmp(output, "off") == 0) {
560 - ls->method = NDLO_DISABLED;
571 + ls->method = NDLM_DISABLED;
572 ls->filename = "/dev/null";
573 }
574 else if(strcmp(output, "journal") == 0) {
564 - ls->method = NDLO_JOURNAL;
575 + ls->method = NDLM_JOURNAL;
576 ls->filename = NULL;
577 }
578 else if(strcmp(output, "syslog") == 0) {
568 - ls->method = NDLO_SYSLOG;
579 + ls->method = NDLM_SYSLOG;
580 ls->filename = NULL;
581 }
582 else if(strcmp(output, "/dev/null") == 0) {
572 - ls->method = NDLO_DEVNULL;
583 + ls->method = NDLM_DEVNULL;
584 ls->filename = "/dev/null";
585 }
586 else if(strcmp(output, "system") == 0) {
587 if(ls->fd == STDERR_FILENO) {
577 - ls->method = NDLO_STDERR;
588 + ls->method = NDLM_STDERR;
589 ls->filename = NULL;
590 ls->fd = STDERR_FILENO;
591 }
592 else {
582 - ls->method = NDLO_STDOUT;
593 + ls->method = NDLM_STDOUT;
594 ls->filename = NULL;
595 ls->fd = STDOUT_FILENO;
596 }
597 }
598 else if(strcmp(output, "stderr") == 0) {
588 - ls->method = NDLO_STDERR;
599 + ls->method = NDLM_STDERR;
600 ls->filename = NULL;
601 ls->fd = STDERR_FILENO;
602 }
603 else if(strcmp(output, "stdout") == 0) {
593 - ls->method = NDLO_STDOUT;
604 + ls->method = NDLM_STDOUT;
605 ls->filename = NULL;
606 ls->fd = STDOUT_FILENO;
607 }
608 else {
598 - ls->method = NDLO_FILE;
609 + ls->method = NDLM_FILE;
610 ls->filename = strdupz(output);
611 }
612
@@ -606,19 +617,18 @@ void nd_log_set_user_settings(ND_LOG_SOURCES source, const char *setting) {
617 if(source == NDLS_COLLECTORS) {
618 // set the method for the collector processes we will spawn
619
609 - ND_LOG_OUTPUT method;
610 - ND_LOG_OUTPUT_FORMAT format = ls->format;
620 + ND_LOG_METHOD method;
621 + ND_LOG_FORMAT format = ls->format;
622 ND_LOG_FIELD_PRIORITY priority = ls->min_priority;
623
613 - if(ls->method == NDLO_SYSLOG || ls->method == NDLO_JOURNAL)
624 + if(ls->method == NDLM_SYSLOG || ls->method == NDLM_JOURNAL)
625 method = ls->method;
626 else
616 - method = NDLO_STDERR;
627 + method = NDLM_STDERR;
628
618 - setenv("NETDATA_LOG_METHOD", nd_log_id2output(method), 1);
629 + setenv("NETDATA_LOG_METHOD", nd_log_id2method(method), 1);
630 setenv("NETDATA_LOG_FORMAT", nd_log_id2format(format), 1);
620 - setenv("NETDATA_LOG_SEVERITY_LEVEL", nd_log_id2priority(priority), 1);
621 - setenv("NETDATA_LOG_PRIORITY_LEVEL", nd_log_id2priority(priority), 1);
631 + setenv("NETDATA_LOG_LEVEL", nd_log_id2priority(priority), 1);
632 }
633 }
634
@@ -635,11 +645,8 @@ void nd_log_set_priority_level(const char *setting) {
645 nd_log.sources[NDLS_DAEMON].min_priority = priority;
646 nd_log.sources[NDLS_COLLECTORS].min_priority = priority;
647
638 - // backwards compatibility
639 - setenv("NETDATA_LOG_SEVERITY_LEVEL", nd_log_id2priority(priority), 1);
640 -
648 // the right one
642 - setenv("NETDATA_LOG_PRIORITY_LEVEL", nd_log_id2priority(priority), 1);
649 + setenv("NETDATA_LOG_LEVEL", nd_log_id2priority(priority), 1);
650 }
651
652 void nd_log_set_facility(const char *facility) {
@@ -677,7 +684,7 @@ static bool nd_log_journal_systemd_init(void) {
684 }
685
686 static void nd_log_journal_direct_set_env(void) {
680 - if(nd_log.sources[NDLS_COLLECTORS].method == NDLO_JOURNAL)
687 + if(nd_log.sources[NDLS_COLLECTORS].method == NDLM_JOURNAL)
688 setenv("NETDATA_SYSTEMD_JOURNAL_PATH", nd_log.journal_direct.filename, 1);
689 }
690
@@ -747,7 +754,7 @@ void nd_log_initialize_for_external_plugins(const char *name) {
754 nd_log.sources[i].fp = NULL;
755 }
756
750 - nd_log_set_priority_level(getenv("NETDATA_LOG_PRIORITY_LEVEL"));
757 + nd_log_set_priority_level(getenv("NETDATA_LOG_LEVEL"));
758 nd_log_set_facility(getenv("NETDATA_SYSLOG_FACILITY"));
759
760 time_t period = 1200;
@@ -770,35 +777,35 @@ void nd_log_initialize_for_external_plugins(const char *name) {
777 netdata_configured_host_prefix = (char *)s;
778 }
779
773 - ND_LOG_OUTPUT method = nd_log_output2id(getenv("NETDATA_LOG_METHOD"));
774 - ND_LOG_OUTPUT_FORMAT format = nd_log_format2id(getenv("NETDATA_LOG_FORMAT"));
780 + ND_LOG_METHOD method = nd_log_method2id(getenv("NETDATA_LOG_METHOD"));
781 + ND_LOG_FORMAT format = nd_log_format2id(getenv("NETDATA_LOG_FORMAT"));
782
776 - if(method != NDLO_JOURNAL && method != NDLO_SYSLOG && method != NDLO_STDERR) {
783 + if(!IS_VALID_LOG_METHOD_FOR_EXTERNAL_PLUGINS(method)) {
784 if(is_stderr_connected_to_journal()) {
785 nd_log(NDLS_COLLECTORS, NDLP_WARNING, "NETDATA_LOG_METHOD is not set. Using journal.");
779 - method = NDLO_JOURNAL;
786 + method = NDLM_JOURNAL;
787 }
788 else {
789 nd_log(NDLS_COLLECTORS, NDLP_WARNING, "NETDATA_LOG_METHOD is not set. Using stderr.");
783 - method = NDLO_STDERR;
790 + method = NDLM_STDERR;
791 }
792 }
793
794 switch(method) {
788 - case NDLO_JOURNAL:
795 + case NDLM_JOURNAL:
796 if(!nd_log_journal_direct_init(getenv("NETDATA_SYSTEMD_JOURNAL_PATH")) ||
797 !nd_log_journal_direct_init(NULL) || !nd_log_journal_systemd_init()) {
798 nd_log(NDLS_COLLECTORS, NDLP_WARNING, "Failed to initialize journal. Using stderr.");
792 - method = NDLO_STDERR;
799 + method = NDLM_STDERR;
800 }
801 break;
802
796 - case NDLO_SYSLOG:
803 + case NDLM_SYSLOG:
804 nd_log_syslog_init();
805 break;
806
807 default:
801 - method = NDLO_STDERR;
808 + method = NDLM_STDERR;
809 break;
810 }
811
@@ -841,46 +848,46 @@ static bool nd_log_replace_existing_fd(struct nd_log_source *e, int new_fd) {
848 }
849
850 static void nd_log_open(struct nd_log_source *e, ND_LOG_SOURCES source) {
844 - if(e->method == NDLO_DEFAULT)
851 + if(e->method == NDLM_DEFAULT)
852 nd_log_set_user_settings(source, e->filename);
853
847 - if((e->method == NDLO_FILE && !e->filename) ||
848 - (e->method == NDLO_DEVNULL && e->fd == -1))
849 - e->method = NDLO_DISABLED;
854 + if((e->method == NDLM_FILE && !e->filename) ||
855 + (e->method == NDLM_DEVNULL && e->fd == -1))
856 + e->method = NDLM_DISABLED;
857
858 if(e->fp)
859 fflush(e->fp);
860
861 switch(e->method) {
855 - case NDLO_SYSLOG:
862 + case NDLM_SYSLOG:
863 nd_log_syslog_init();
864 break;
865
859 - case NDLO_JOURNAL:
866 + case NDLM_JOURNAL:
867 nd_log_journal_direct_init(NULL);
868 nd_log_journal_systemd_init();
869 break;
870
864 - case NDLO_STDOUT:
871 + case NDLM_STDOUT:
872 e->fp = stdout;
873 e->fd = STDOUT_FILENO;
874 break;
875
876 default:
870 - case NDLO_DEFAULT:
871 - case NDLO_STDERR:
872 - e->method = NDLO_STDERR;
877 + case NDLM_DEFAULT:
878 + case NDLM_STDERR:
879 + e->method = NDLM_STDERR;
880 e->fp = stderr;
881 e->fd = STDERR_FILENO;
882 break;
883
877 - case NDLO_DEVNULL:
878 - case NDLO_FILE: {
884 + case NDLM_DEVNULL:
885 + case NDLM_FILE: {
886 int fd = open(e->filename, O_WRONLY | O_APPEND | O_CREAT, 0664);
887 if(fd == -1) {
888 if(e->fd != STDOUT_FILENO && e->fd != STDERR_FILENO) {
889 e->fd = STDERR_FILENO;
883 - e->method = NDLO_STDERR;
890 + e->method = NDLM_STDERR;
891 netdata_log_error("Cannot open log file '%s'. Falling back to stderr.", e->filename);
892 }
893 else
@@ -890,9 +897,9 @@ static void nd_log_open(struct nd_log_source *e, ND_LOG_SOURCES source) {
897 if (!nd_log_replace_existing_fd(e, fd)) {
898 if(e->fd == STDOUT_FILENO || e->fd == STDERR_FILENO) {
899 if(e->fd == STDOUT_FILENO)
893 - e->method = NDLO_STDOUT;
900 + e->method = NDLM_STDOUT;
901 else if(e->fd == STDERR_FILENO)
895 - e->method = NDLO_STDERR;
902 + e->method = NDLM_STDERR;
903
904 // we have dup2() fd, so we can close the one we opened
905 if(fd != STDOUT_FILENO && fd != STDERR_FILENO)
@@ -1884,7 +1891,7 @@ static bool nd_logger_journal_direct(struct log_field *fields, size_t fields_max
1891 // ----------------------------------------------------------------------------
1892 // syslog logger - uses logfmt
1893
1887 -static bool nd_logger_syslog(int priority, ND_LOG_OUTPUT_FORMAT format, struct log_field *fields, size_t fields_max) {
1894 +static bool nd_logger_syslog(int priority, ND_LOG_FORMAT format, struct log_field *fields, size_t fields_max) {
1895 CLEAN_BUFFER *wb = buffer_create(1024, NULL);
1896
1897 nd_logger_logfmt(wb, fields, fields_max);
@@ -1896,10 +1903,10 @@ static bool nd_logger_syslog(int priority, ND_LOG_OUTPUT_FORMAT format, struct l
1903 // ----------------------------------------------------------------------------
1904 // file logger - uses logfmt
1905
1899 -static bool nd_logger_file(FILE *fp, ND_LOG_OUTPUT_FORMAT format, struct log_field *fields, size_t fields_max) {
1906 +static bool nd_logger_file(FILE *fp, ND_LOG_FORMAT format, struct log_field *fields, size_t fields_max) {
1907 BUFFER *wb = buffer_create(1024, NULL);
1908
1902 - if(format == NDLOF_JSON)
1909 + if(format == NDLF_JSON)
1910 nd_logger_json(wb, fields, fields_max);
1911 else
1912 nd_logger_logfmt(wb, fields, fields_max);
@@ -1914,14 +1921,14 @@ static bool nd_logger_file(FILE *fp, ND_LOG_OUTPUT_FORMAT format, struct log_fie
1921 // ----------------------------------------------------------------------------
1922 // logger router
1923
1917 -static ND_LOG_OUTPUT nd_logger_select_output(ND_LOG_SOURCES source, FILE **fpp, SPINLOCK **spinlock) {
1924 +static ND_LOG_METHOD nd_logger_select_output(ND_LOG_SOURCES source, FILE **fpp, SPINLOCK **spinlock) {
1925 *spinlock = NULL;
1919 - ND_LOG_OUTPUT output = nd_log.sources[source].method;
1926 + ND_LOG_METHOD output = nd_log.sources[source].method;
1927
1928 switch(output) {
1922 - case NDLO_JOURNAL:
1929 + case NDLM_JOURNAL:
1930 if(unlikely(!nd_log.journal_direct.initialized && !nd_log.journal.initialized)) {
1924 - output = NDLO_FILE;
1931 + output = NDLM_FILE;
1932 *fpp = stderr;
1933 *spinlock = &nd_log.std_error.spinlock;
1934 }
@@ -1931,9 +1938,9 @@ static ND_LOG_OUTPUT nd_logger_select_output(ND_LOG_SOURCES source, FILE **fpp,
1938 }
1939 break;
1940
1934 - case NDLO_SYSLOG:
1941 + case NDLM_SYSLOG:
1942 if(unlikely(!nd_log.syslog.initialized)) {
1936 - output = NDLO_FILE;
1943 + output = NDLM_FILE;
1944 *spinlock = &nd_log.std_error.spinlock;
1945 *fpp = stderr;
1946 }
@@ -1943,7 +1950,7 @@ static ND_LOG_OUTPUT nd_logger_select_output(ND_LOG_SOURCES source, FILE **fpp,
1950 }
1951 break;
1952
1946 - case NDLO_FILE:
1953 + case NDLM_FILE:
1954 if(!nd_log.sources[source].fp) {
1955 *fpp = stderr;
1956 *spinlock = &nd_log.std_error.spinlock;
@@ -1954,23 +1961,23 @@ static ND_LOG_OUTPUT nd_logger_select_output(ND_LOG_SOURCES source, FILE **fpp,
1961 }
1962 break;
1963
1957 - case NDLO_STDOUT:
1958 - output = NDLO_FILE;
1964 + case NDLM_STDOUT:
1965 + output = NDLM_FILE;
1966 *fpp = stdout;
1967 *spinlock = &nd_log.std_output.spinlock;
1968 break;
1969
1970 default:
1964 - case NDLO_DEFAULT:
1965 - case NDLO_STDERR:
1966 - output = NDLO_FILE;
1971 + case NDLM_DEFAULT:
1972 + case NDLM_STDERR:
1973 + output = NDLM_FILE;
1974 *fpp = stderr;
1975 *spinlock = &nd_log.std_error.spinlock;
1976 break;
1977
1971 - case NDLO_DISABLED:
1972 - case NDLO_DEVNULL:
1973 - output = NDLO_DISABLED;
1978 + case NDLM_DISABLED:
1979 + case NDLM_DEVNULL:
1980 + output = NDLM_DISABLED;
1981 *fpp = NULL;
1982 *spinlock = NULL;
1983 break;
@@ -1983,7 +1990,7 @@ static ND_LOG_OUTPUT nd_logger_select_output(ND_LOG_SOURCES source, FILE **fpp,
1990 // high level logger
1991
1992 static void nd_logger_log_fields(SPINLOCK *spinlock, FILE *fp, bool limit, ND_LOG_FIELD_PRIORITY priority,
1986 - ND_LOG_OUTPUT output, struct nd_log_source *source,
1993 + ND_LOG_METHOD output, struct nd_log_source *source,
1994 struct log_field *fields, size_t fields_max) {
1995 if(spinlock)
1996 spinlock_lock(spinlock);
@@ -1992,13 +1999,13 @@ static void nd_logger_log_fields(SPINLOCK *spinlock, FILE *fp, bool limit, ND_LO
1999 if(limit && nd_log_limit_reached(source))
2000 goto cleanup;
2001
1995 - if(output == NDLO_JOURNAL) {
2002 + if(output == NDLM_JOURNAL) {
2003 if(!nd_logger_journal_direct(fields, fields_max) && !nd_logger_journal_libsystemd(fields, fields_max)) {
2004 // we can't log to journal, let's log to stderr
2005 if(spinlock)
2006 spinlock_unlock(spinlock);
2007
2001 - output = NDLO_FILE;
2008 + output = NDLM_FILE;
2009 spinlock = &nd_log.std_error.spinlock;
2010 fp = stderr;
2011
@@ -2007,10 +2014,10 @@ static void nd_logger_log_fields(SPINLOCK *spinlock, FILE *fp, bool limit, ND_LO
2014 }
2015 }
2016
2010 - if(output == NDLO_SYSLOG)
2017 + if(output == NDLM_SYSLOG)
2018 nd_logger_syslog(priority, source->format, fields, fields_max);
2019
2013 - if(output == NDLO_FILE)
2020 + if(output == NDLM_FILE)
2021 nd_logger_file(fp, source->format, fields, fields_max);
2022
2023
@@ -2056,8 +2063,8 @@ static void nd_logger(const char *file, const char *function, const unsigned lon
2063
2064 SPINLOCK *spinlock;
2065 FILE *fp;
2059 - ND_LOG_OUTPUT output = nd_logger_select_output(source, &fp, &spinlock);
2060 - if(output != NDLO_FILE && output != NDLO_JOURNAL && output != NDLO_SYSLOG)
2066 + ND_LOG_METHOD output = nd_logger_select_output(source, &fp, &spinlock);
2067 + if(output != NDLM_FILE && output != NDLM_JOURNAL && output != NDLM_SYSLOG)
2068 return;
2069
2070 // mark all fields as unset
libnetdata/log/log.h
+1
@@ -147,6 +147,7 @@ bool nd_log_journal_socket_available(void);
147 ND_LOG_FIELD_ID nd_log_field_id_by_name(const char *field, size_t len);
148 int nd_log_priority2id(const char *priority);
149 const char *nd_log_id2priority(ND_LOG_FIELD_PRIORITY priority);
150 +const char *nd_log_method_for_external_plugins(const char *s);
151
152 typedef bool (*log_formatter_callback_t)(BUFFER *wb, void *data);
153
libnetdata/log/log2journal.c
+4 -4
@@ -381,7 +381,7 @@ static pcre2_code *jb_compile_pcre2_pattern(const char *pattern) {
381 return re;
382 }
383
384 -static inline bool jb_pcre2_match(pcre2_code *re, pcre2_match_data *match_data, char *line, size_t len) {
384 +static inline bool jb_pcre2_match(pcre2_code *re, pcre2_match_data *match_data, char *line, size_t len, bool log) {
385 int rc = pcre2_match(re, (PCRE2_SPTR)line, len, 0, 0, match_data, NULL);
386 if(rc < 0) {
387 PCRE2_UCHAR errbuf[1024];
@@ -402,7 +402,7 @@ static char *rewrite_value(struct log_job *jb, const char *key, XXH64_hash_t has
402 struct key_rewrite *rw = &jb->rewrites.array[i];
403
404 if (rw->hash == hash && strcmp(rw->key, key) == 0) {
405 - if (!jb_pcre2_match(rw->re, rw->match_data, (char *)value, value_len)) {
405 + if (!jb_pcre2_match(rw->re, rw->match_data, (char *)value, value_len, false)) {
406 continue; // No match found, skip to next rewrite rule
407 }
408
@@ -718,7 +718,7 @@ bool parse_parameters(struct log_job *jb, int argc, char **argv) {
718 if (!jb->pattern) {
719 jb->pattern = arg;
720 } else {
721 - log2stderr("Error: Multiple patterns detected. Specify only one pattern.");
721 + log2stderr("Error: Multiple patterns detected. Specify only one pattern. The first is '%s', the second is '%s'", jb->pattern, arg);
722 return false;
723 }
724 }
@@ -978,7 +978,7 @@ int main(int argc, char *argv[]) {
978 jb_reset_injections(jb);
979
980 bool line_is_matched;
981 - if(!jb_pcre2_match(re, match_data, line, len)) {
981 + if(!jb_pcre2_match(re, match_data, line, len, true)) {
982 line_is_matched = false;
983
984 if (jb->unmatched.key) {
libnetdata/log/log2journal.md
+88 -44
@@ -11,14 +11,13 @@ The overall process looks like this:
11 ```bash
12 tail -F /var/log/nginx/*.log |\ # outputs log lines
13 log2journal 'PATTERN' |\ # outputs Journal Export Format
14 - sed -u -e SEARCH-REPLACE-RULES |\ # optional rewriting rules
14 systemd-cat-native # send to local/remote journald
15 ```
16
17 Let's see the steps:
18
19 1. `tail -F /var/log/nginx/*.log`<br/>this command will tail all `*.log` files in `/var/log/nginx/`. We use `-F` instead of `-f` to ensure that files will still be tailed after log rotation.
21 -2. `log2joural` is a Netdata program. It reads log entries and extracts fields, according to the PCRE2 pattern it accepts. It can also apply some basic operations on the fields, like injecting new fields or duplicating existing ones. The output of `log2journal` is in Systemd Journal Export Format, and it looks like this:
20 +2. `log2joural` is a Netdata program. It reads log entries and extracts fields, according to the PCRE2 pattern it accepts. It can also apply some basic operations on the fields, like injecting new fields or duplicating existing ones or rewriting their values. The output of `log2journal` is in Systemd Journal Export Format, and it looks like this:
21 ```bash
22 KEY1=VALUE1 # << start of the first log line
23 KEY2=VALUE2
@@ -26,8 +25,7 @@ Let's see the steps:
25 KEY1=VALUE1 # << start of the second log line
26 KEY2=VALUE2
27 ```
29 -3. `sed` is an optional step and is an example. Any kind of processing can be applied at this stage, in case we want to alter the fields in some way. For example, we may want to set the PRIORITY field of systemd-journal to make Netdata dashboards and `journalctl` color the internal server errors. Or we may want to anonymize the logs, to remove sensitive information from them. Or even we may want to remove the variable parts of the requests, to make them uniform. We will see below how such processing can be done.
30 -4. `systemd-cat-native` is a Netdata program. I can send the logs to a local `systemd-journald` (journal namespaces supported), or to a remote `systemd-journal-remote`.
28 +3. `systemd-cat-native` is a Netdata program. I can send the logs to a local `systemd-journald` (journal namespaces supported), or to a remote `systemd-journal-remote`.
29
30 ## Real-life example
31
@@ -142,10 +140,10 @@ Avoid setting priority to 0 (`LOG_EMERG`), because these will be on your termina
140
141 To set the PRIORITY field in the output, we can use `NGINX_STATUS` fields. We need a copy of it, which we will alter later.
142
145 -We can instruct `log2journal` to duplicate `NGINX_STATUS`, like this: `log2journal --duplicate=STATUS2PRIORITY=NGINX_STATUS`. Let's try it:
143 +We can instruct `log2journal` to duplicate `NGINX_STATUS`, like this: `log2journal --duplicate=PRIORITY=NGINX_STATUS`. Let's try it:
144
145 ```bash
148 -# echo '1.2.3.4 - - [19/Nov/2023:00:24:43 +0000] "GET /index.html HTTP/1.1" 200 4172 104 0.001 "-" "Go-http-client/1.1"' | log2journal '^(?<NGINX_REMOTE_ADDR>[^ ]+) - (?<NGINX_REMOTE_USER>[^ ]+) \[(?<NGINX_TIME_LOCAL>[^\]]+)\] "(?<MESSAGE>(?<NGINX_METHOD>[A-Z]+) (?<NGINX_URL>[^ ]+) HTTP/(?<NGINX_HTTP_VERSION>[^"]+))" (?<NGINX_STATUS>\d+) (?<NGINX_BODY_BYTES_SENT>\d+) (?<NGINX_REQUEST_LENGTH>\d+) (?<NGINX_REQUEST_TIME>[\d.]+) "(?<NGINX_HTTP_REFERER>[^"]*)" "(?<NGINX_HTTP_USER_AGENT>[^"]*)"' --duplicate=STATUS2PRIORITY=NGINX_STATUS
146 +# echo '1.2.3.4 - - [19/Nov/2023:00:24:43 +0000] "GET /index.html HTTP/1.1" 200 4172 104 0.001 "-" "Go-http-client/1.1"' | log2journal '^(?<NGINX_REMOTE_ADDR>[^ ]+) - (?<NGINX_REMOTE_USER>[^ ]+) \[(?<NGINX_TIME_LOCAL>[^\]]+)\] "(?<MESSAGE>(?<NGINX_METHOD>[A-Z]+) (?<NGINX_URL>[^ ]+) HTTP/(?<NGINX_HTTP_VERSION>[^"]+))" (?<NGINX_STATUS>\d+) (?<NGINX_BODY_BYTES_SENT>\d+) (?<NGINX_REQUEST_LENGTH>\d+) (?<NGINX_REQUEST_TIME>[\d.]+) "(?<NGINX_HTTP_REFERER>[^"]*)" "(?<NGINX_HTTP_USER_AGENT>[^"]*)"' --duplicate=PRIORITY=NGINX_STATUS
147 MESSAGE=GET /index.html HTTP/1.1
148 NGINX_BODY_BYTES_SENT=4172
149 NGINX_HTTP_REFERER=-
@@ -157,24 +155,16 @@ NGINX_REMOTE_USER=-
155 NGINX_REQUEST_LENGTH=104
156 NGINX_REQUEST_TIME=0.001
157 NGINX_STATUS=200
160 -STATUS2PRIORITY=200 # <<<<<<<<< STATUS2PRIORITY IS HERE
158 +PRIORITY=200 # <<<<<<<<< PRIORITY IS HERE
159 NGINX_TIME_LOCAL=19/Nov/2023:00:24:43 +0000
160 NGINX_URL=/index.html
161
162 ```
163
166 -Now that we have the `STATUS2PRIORITY` field equal to the `NGINX_STATUS`, we can use a `sed` command to change it to the `PRIORITY` field we want. The `sed` command could be:
164 +Now that we have the `PRIORITY` field equal to the `NGINX_STATUS`, we can use instruct `log2journal` to change it to a valid priority, by appending: `--rewrite=PRIORITY=/^5/3 --rewrite=PRIORITY=/.*/6`. These rewrite commands say to match everything that starts with `5` and replace it with priority `3` (error) and everything else with priority `6` (info). Let's see it:
165
166 ```bash
169 -sed -u -e 's|STATUS2PRIORITY=5.*|PRIORITY=3|' -e 's|STATUS2PRIORITY=.*|PRIORITY=6|'
170 -```
171 -
172 -We use `-u` for unbuffered communication.
173 -
174 -This command first changes all 5xx `STATUS2PRIORITY` fields to `PRIORITY=3` (error) and then changes all the rest to `PRIORITY=6` (info). Let's see the whole of it:
175 -
176 -```bash
177 -# echo '1.2.3.4 - - [19/Nov/2023:00:24:43 +0000] "GET /index.html HTTP/1.1" 200 4172 104 0.001 "-" "Go-http-client/1.1"' | log2journal '^(?<NGINX_REMOTE_ADDR>[^ ]+) - (?<NGINX_REMOTE_USER>[^ ]+) \[(?<NGINX_TIME_LOCAL>[^\]]+)\] "(?<MESSAGE>(?<NGINX_METHOD>[A-Z]+) (?<NGINX_URL>[^ ]+) HTTP/(?<NGINX_HTTP_VERSION>[^"]+))" (?<NGINX_STATUS>\d+) (?<NGINX_BODY_BYTES_SENT>\d+) (?<NGINX_REQUEST_LENGTH>\d+) (?<NGINX_REQUEST_TIME>[\d.]+) "(?<NGINX_HTTP_REFERER>[^"]*)" "(?<NGINX_HTTP_USER_AGENT>[^"]*)"' --duplicate=STATUS2PRIORITY=NGINX_STATUS | sed -u -e 's|STATUS2PRIORITY=5.*|PRIORITY=3|' -e 's|STATUS2PRIORITY=.*|PRIORITY=6|'
167 +# echo '1.2.3.4 - - [19/Nov/2023:00:24:43 +0000] "GET /index.html HTTP/1.1" 200 4172 104 0.001 "-" "Go-http-client/1.1"' | log2journal '^(?<NGINX_REMOTE_ADDR>[^ ]+) - (?<NGINX_REMOTE_USER>[^ ]+) \[(?<NGINX_TIME_LOCAL>[^\]]+)\] "(?<MESSAGE>(?<NGINX_METHOD>[A-Z]+) (?<NGINX_URL>[^ ]+) HTTP/(?<NGINX_HTTP_VERSION>[^"]+))" (?<NGINX_STATUS>\d+) (?<NGINX_BODY_BYTES_SENT>\d+) (?<NGINX_REQUEST_LENGTH>\d+) (?<NGINX_REQUEST_TIME>[\d.]+) "(?<NGINX_HTTP_REFERER>[^"]*)" "(?<NGINX_HTTP_USER_AGENT>[^"]*)"' --duplicate=STATUS2PRIORITY=NGINX_STATUS --rewrite=PRIORITY=/^5/3 --rewrite=PRIORITY=/.*/6
168 MESSAGE=GET /index.html HTTP/1.1
169 NGINX_BODY_BYTES_SENT=4172
170 NGINX_HTTP_REFERER=-
@@ -186,7 +176,7 @@ NGINX_REMOTE_USER=-
176 NGINX_REQUEST_LENGTH=104
177 NGINX_REQUEST_TIME=0.001
178 NGINX_STATUS=200
189 -PRIORITY=6 # <<<<<<<<< PRIORITY IS HERE
179 +PRIORITY=6 # <<<<<<<<<< PRIORITY changed to 6
180 NGINX_TIME_LOCAL=19/Nov/2023:00:24:43 +0000
181 NGINX_URL=/index.html
182
@@ -194,10 +184,10 @@ NGINX_URL=/index.html
184
185 Similarly, we could duplicate `NGINX_URL` to `NGINX_ENDPOINT` and then process it with sed to remove any query string, or replace IDs in the URL path with constant names, thus giving us uniform endpoints independently of the parameters.
186
197 -To complete the example, we can also inject a `SYSLOG_IDENTIFIER` with `log2journal`, using `--inject=SYSLOG_IDENTIFIER=nginx`, like this:
187 +To complete the example, we can also inject a `SYSLOG_IDENTIFIER` with `log2journal`, using `--inject=SYSLOG_IDENTIFIER=nginx-log`, like this:
188
189 ```bash
200 -# echo '1.2.3.4 - - [19/Nov/2023:00:24:43 +0000] "GET /index.html HTTP/1.1" 200 4172 104 0.001 "-" "Go-http-client/1.1"' | log2journal '^(?<NGINX_REMOTE_ADDR>[^ ]+) - (?<NGINX_REMOTE_USER>[^ ]+) \[(?<NGINX_TIME_LOCAL>[^\]]+)\] "(?<MESSAGE>(?<NGINX_METHOD>[A-Z]+) (?<NGINX_URL>[^ ]+) HTTP/(?<NGINX_HTTP_VERSION>[^"]+))" (?<NGINX_STATUS>\d+) (?<NGINX_BODY_BYTES_SENT>\d+) (?<NGINX_REQUEST_LENGTH>\d+) (?<NGINX_REQUEST_TIME>[\d.]+) "(?<NGINX_HTTP_REFERER>[^"]*)" "(?<NGINX_HTTP_USER_AGENT>[^"]*)"' --duplicate=STATUS2PRIORITY=NGINX_STATUS --inject=SYSLOG_IDENTIFIER=nginx | sed -u -e 's|STATUS2PRIORITY=5.*|PRIORITY=3|' -e 's|STATUS2PRIORITY=.*|PRIORITY=6|'
190 +# echo '1.2.3.4 - - [19/Nov/2023:00:24:43 +0000] "GET /index.html HTTP/1.1" 200 4172 104 0.001 "-" "Go-http-client/1.1"' | log2journal '^(?<NGINX_REMOTE_ADDR>[^ ]+) - (?<NGINX_REMOTE_USER>[^ ]+) \[(?<NGINX_TIME_LOCAL>[^\]]+)\] "(?<MESSAGE>(?<NGINX_METHOD>[A-Z]+) (?<NGINX_URL>[^ ]+) HTTP/(?<NGINX_HTTP_VERSION>[^"]+))" (?<NGINX_STATUS>\d+) (?<NGINX_BODY_BYTES_SENT>\d+) (?<NGINX_REQUEST_LENGTH>\d+) (?<NGINX_REQUEST_TIME>[\d.]+) "(?<NGINX_HTTP_REFERER>[^"]*)" "(?<NGINX_HTTP_USER_AGENT>[^"]*)"' --duplicate=STATUS2PRIORITY=NGINX_STATUS --inject=SYSLOG_IDENTIFIER=nginx -rewrite=PRIORITY=/^5/3 --rewrite=PRIORITY=/.*/6
191 MESSAGE=GET /index.html HTTP/1.1
192 NGINX_BODY_BYTES_SENT=4172
193 NGINX_HTTP_REFERER=-
@@ -212,7 +202,7 @@ NGINX_STATUS=200
202 PRIORITY=6
203 NGINX_TIME_LOCAL=19/Nov/2023:00:24:43 +0000
204 NGINX_URL=/index.html
215 -SYSLOG_IDENTIFIER=nginx # <<<<<<<<< THIS HAS BEEN ADDED
205 +SYSLOG_IDENTIFIER=nginx-log # <<<<<<<<< THIS HAS BEEN ADDED
206
207 ```
208
@@ -220,7 +210,7 @@ Now the message is ready to be sent to a systemd-journal. For this we use `syste
210
211
212 ```bash
223 -# echo '1.2.3.4 - - [19/Nov/2023:00:24:43 +0000] "GET /index.html HTTP/1.1" 200 4172 104 0.001 "-" "Go-http-client/1.1"' | log2journal '^(?<NGINX_REMOTE_ADDR>[^ ]+) - (?<NGINX_REMOTE_USER>[^ ]+) \[(?<NGINX_TIME_LOCAL>[^\]]+)\] "(?<MESSAGE>(?<NGINX_METHOD>[A-Z]+) (?<NGINX_URL>[^ ]+) HTTP/(?<NGINX_HTTP_VERSION>[^"]+))" (?<NGINX_STATUS>\d+) (?<NGINX_BODY_BYTES_SENT>\d+) (?<NGINX_REQUEST_LENGTH>\d+) (?<NGINX_REQUEST_TIME>[\d.]+) "(?<NGINX_HTTP_REFERER>[^"]*)" "(?<NGINX_HTTP_USER_AGENT>[^"]*)"' --duplicate=STATUS2PRIORITY=NGINX_STATUS --inject=SYSLOG_IDENTIFIER=nginx | sed -u -e 's|STATUS2PRIORITY=5.*|PRIORITY=3|' -e 's|STATUS2PRIORITY=.*|PRIORITY=6|' | systemd-cat-native
213 +# echo '1.2.3.4 - - [19/Nov/2023:00:24:43 +0000] "GET /index.html HTTP/1.1" 200 4172 104 0.001 "-" "Go-http-client/1.1"' | log2journal '^(?<NGINX_REMOTE_ADDR>[^ ]+) - (?<NGINX_REMOTE_USER>[^ ]+) \[(?<NGINX_TIME_LOCAL>[^\]]+)\] "(?<MESSAGE>(?<NGINX_METHOD>[A-Z]+) (?<NGINX_URL>[^ ]+) HTTP/(?<NGINX_HTTP_VERSION>[^"]+))" (?<NGINX_STATUS>\d+) (?<NGINX_BODY_BYTES_SENT>\d+) (?<NGINX_REQUEST_LENGTH>\d+) (?<NGINX_REQUEST_TIME>[\d.]+) "(?<NGINX_HTTP_REFERER>[^"]*)" "(?<NGINX_HTTP_USER_AGENT>[^"]*)"' --duplicate=STATUS2PRIORITY=NGINX_STATUS --inject=SYSLOG_IDENTIFIER=nginx -rewrite=PRIORITY=/^5/3 --rewrite=PRIORITY=/.*/6 | systemd-cat-native
214 # no output
215
216 # let's find the message
@@ -258,7 +248,7 @@ Sun 2023-11-19 04:34:06.583912 EET [s=1eb59e7934984104ab3b61f5d9648057;i=115b6d4
248 NGINX_STATUS=200 # <<<<<<<<< CHECK
249 NGINX_TIME_LOCAL=19/Nov/2023:00:24:43 +0000 # <<<<<<<<< CHECK
250 NGINX_URL=/index.html # <<<<<<<<< CHECK
261 - SYSLOG_IDENTIFIER=nginx # <<<<<<<<< CHECK
251 + SYSLOG_IDENTIFIER=nginx-log # <<<<<<<<< CHECK
252 _PID=354312
253 _SOURCE_REALTIME_TIMESTAMP=1700361246583912
254
@@ -304,20 +294,18 @@ pattern='(?x) # Enable PCRE2 extended mode
294 "(?<NGINX_HTTP_USER_AGENT>[^"]*)" # NGINX_HTTP_USER_AGENT
295 '
296
307 -tail -n $last -F /var/log/nginx/*access.log |\
308 - log2journal "${pattern}" \
297 +tail -n $last -F /var/log/nginx/*access.log \
298 + | log2journal "${pattern}" \
299 --filename-key=NGINX_LOG_FILE \
310 - --duplicate=STATUS2PRIORITY=NGINX_STATUS \
311 - --duplicate=STATUS_FAMILY=NGINX_STATUS \
312 - --inject=SYSLOG_IDENTIFIER=nginx \
300 + --duplicate=PRIORITY=NGINX_STATUS \
301 + --duplicate=NGINX_STATUS_FAMILY=NGINX_STATUS \
302 + --inject=SYSLOG_IDENTIFIER=nginx-log \
303 --unmatched-key=MESSAGE \
304 --inject-unmatched=PRIORITY=1 \
315 - | sed -u \
316 - -e 's|^STATUS2PRIORITY=5.*$|PRIORITY=3|' \
317 - -e 's|^STATUS2PRIORITY=.*$|PRIORITY=6|' \
318 - -e 's|^STATUS_FAMILY=\([0-9]\).*$|NGINX_STATUS_FAMILY=\1xx|' \
319 - -e 's|^STATUS_FAMILY=.*$|NGINX_STATUS_FAMILY=UNKNOWN|' \
320 - | $send_or_show
305 + --rewrite='PRIORITY=/^5/3 --rewrite=PRIORITY=/.*/6' \
306 + --rewrite='NGINX_STATUS_FAMILY=/^(?<first_digit>[0-9]).*$/${first_digit}xx' \
307 + --rewrite='NGINX_STATUS_FAMILY=/^.*$/UNKNOWN' \
308 + | $send_or_show
309 ```
310
311
@@ -325,14 +313,14 @@ tail -n $last -F /var/log/nginx/*access.log |\
313
314 ```
315
328 -Netdata log2journal v1.43.0-337-g116dc1bc3
316 +Netdata log2journal v1.40.0-1214-gae733dd49
317
318 Convert structured log input to systemd Journal Export Format.
319
320 Using PCRE2 patterns, extract the fields from structured logs on the standard
333 -input, and generate output according to systemd Journal Export Format
321 +input, and generate output according to systemd Journal Export Format.
322
335 -Usage: ./log2journal [OPTIONS] PATTERN
323 +Usage: log2journal [OPTIONS] PATTERN
324
325 Options:
326
@@ -353,20 +341,43 @@ Options:
341 Create a new key called TARGET, duplicating the values of the keys
342 given. Useful for further processing. When multiple keys are given,
343 their values are separated by comma.
356 - Up to 2048 duplications can be given on the command line, and up to
357 - 10 keys per duplication command are allowed.
344 + Up to 512 duplications can be given on the command line, and up to
345 + 20 keys per duplication command are allowed.
346
347 --inject=LINE
348 Inject constant fields to the output (both matched and unmatched logs).
349 --inject entries are added to unmatched lines too, when their key is
350 not used in --inject-unmatched (--inject-unmatched override --inject).
363 - Up to 2048 fields can be injected.
351 + Up to 512 fields can be injected.
352
353 --inject-unmatched=LINE
354 Inject lines into the output for each unmatched log entry.
355 Usually, --inject-unmatched=PRIORITY=3 is needed to mark the unmatched
356 lines as errors, so that they can easily be spotted in the journals.
369 - Up to 2048 such lines can be injected.
357 + Up to 512 such lines can be injected.
358 +
359 + --rewrite=KEY=/SearchPattern/ReplacePattern
360 + Apply a rewrite rule to the values of a specific key.
361 + The first character after KEY= is the separator, which should also
362 + be used between the search pattern and the replacement pattern.
363 + The search pattern is a PCRE2 regular expression, and the replacement
364 + pattern supports literals and named capture groups from the search pattern.
365 + Example:
366 + --rewrite=DATE=/^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/
367 + ${day}/${month}/${year}
368 + This will rewrite dates in the format YYYY-MM-DD to DD/MM/YYYY.
369 +
370 + Only one rewrite rule is applied per key; the sequence of rewrites stops
371 + for the key once a rule matches it. This allows providing a sequence of
372 + independent rewriting rules for the same key, matching the different values
373 + the key may get, and also provide a catch-all rewrite rule at the end of the
374 + sequence for setting the key value if no other rule matched it.
375 +
376 + The combination of duplicating keys with the values of multiple other keys
377 + combined with multiple rewrite rules, allows creating complex rules for
378 + rewriting key values.
379 +
380 + Up to 512 rewriting rules are allowed.
381
382 -h, --help
383 Display this help and exit.
@@ -378,7 +389,34 @@ Options:
389 Regular expressions without named groups are ignored.
390
391 The maximum line length accepted is 1048576 characters.
381 -The maximum number of fields in the PCRE2 pattern is 8192.
392 +The maximum number of fields in the PCRE2 pattern is 1024.
393 +
394 +PIPELINE AND SEQUENCE OF PROCESSING
395 +
396 +This is a simple diagram of the pipeline taking place:
397 +
398 + +---------------------------------------------------+
399 + | INPUT |
400 + +---------------------------------------------------+
401 + v v
402 + +---------------------------------+ |
403 + | EXTRACT FIELDS AND VALUES | |
404 + +---------------------------------+ |
405 + v v |
406 + +---------------+ | |
407 + | DUPLICATE | | |
408 + | create fields | | |
409 + | with values | | |
410 + +---------------+ | |
411 + v v v
412 + +---------------------------------+ +--------------+
413 + | REWRITE PIPELINES | | INJECT |
414 + | altering the values | | constants |
415 + +---------------------------------+ +--------------+
416 + v v
417 + +---------------------------------------------------+
418 + | OUTPUT |
419 + +---------------------------------------------------+
420
421 JOURNAL FIELDS RULES (enforced by systemd-journald)
422
@@ -417,7 +455,7 @@ You can find the most common fields at 'man systemd.journal-fields'.
455
456 ```
457
420 -Netdata systemd-cat-native v1.43.0-319-g4ada93a6e
458 +Netdata systemd-cat-native v1.40.0-1214-gae733dd49
459
460 This program reads from its standard input, lines in the format:
461
@@ -436,7 +474,7 @@ and sends them to systemd-journal.
474
475 Usage:
476
439 - ./systemd-cat-native
477 + systemd-cat-native
478 [--newline=STRING]
479 [--log-as-netdata|-N]
480 [--namespace=NAMESPACE] [--socket=PATH]
@@ -476,6 +514,9 @@ The program has the following modes of logging:
514 systemd, or even it is not Linux, allowing a remote Linux systemd
515 journald to become the logs database of the local system.
516
517 + Unfortunately systemd-journal-remote does not accept compressed
518 + data over the network, so the stream will be uncompressed.
519 +
520 --url=URL
521 The destination systemd-journal-remote address and port, similarly
522 to what /etc/systemd/journal-upload.conf accepts.
@@ -496,6 +537,9 @@ The program has the following modes of logging:
537 The default is: /etc/ssl/ca/trusted.pem
538 The keyword 'all' can be used to trust all CAs.
539
540 + --keep-trying
541 + Keep trying to send the message, if the remote journal is not there.
542 +
543 NEWLINES PROCESSING
544 systemd-journal logs entries may have newlines in them. However the
545 Journal Export Format uses binary formatted data to achieve this,
libnetdata/log/systemd-cat-native.c
+2 -2
@@ -500,8 +500,8 @@ static int help(void) {
500 " The parameter --newline=STRING allows setting the string to be replaced\n"
501 " with newlines.\n"
502 "\n"
503 - " For example by setting --newline='{NEWLINE}', the program will replace\n"
504 - " all occurrences of {NEWLINE} with the newline character, within each\n"
503 + " For example by setting --newline='--NEWLINE--', the program will replace\n"
504 + " all occurrences of --NEWLINE-- with the newline character, within each\n"
505 " VALUE of the KEY=VALUE lines. Once this this done, the program will\n"
506 " switch the field to the binary Journal Export Format before sending the\n"
507 " log event to systemd-journal.\n"