(209) Don't url encode args when outputting in ndjson.
@@ -35,12 +35,22 @@ msgAddNewLine(char *msg)
void
sendProcessStartMetric()
{
- char *urlEncodedCmd = fmtUrlEncode(g_proc.cmd);
+ char *urlEncodedCmd = NULL;
+ char *command = g_proc.cmd; // default is no encoding
+
+ // If we're reporting in statsd format, url encode the cmd
+ // to avoid characters that could cause parsing problems
+ // for statsd aggregators :|@#,
+ if (cfgMtcFormat(g_cfg.staticfg) == CFG_FMT_STATSD) {
+ urlEncodedCmd = fmtUrlEncode(g_proc.cmd);
+ command = urlEncodedCmd;
+ }
+
event_field_t fields[] = {
STRFIELD("proc", (g_proc.procname), 4, TRUE),
NUMFIELD("pid", (g_proc.pid), 4, TRUE),
STRFIELD("host", (g_proc.hostname), 4, TRUE),
- STRFIELD("args", (urlEncodedCmd), 7, TRUE),
+ STRFIELD("args", (command), 7, TRUE),
STRFIELD("unit", ("process"), 1, TRUE),
FIELDEND
};
