diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-08-13 11:34:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-13 11:34:03 +0300 |
commit | 714446c1c038112571c27c2429d5e40da01b2ca5 (patch) | |
tree | 4720956547bb11a5b6b59ba8f017d2266b45a473 /collectors/systemd-journal.plugin | |
parent | 93c55cca5008e7c3cf213715ea9ba97c7fc388ba (diff) |
Function systemd-journal: always have a nd_journal_process (#15798)
Diffstat (limited to 'collectors/systemd-journal.plugin')
-rw-r--r-- | collectors/systemd-journal.plugin/systemd-journal.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/collectors/systemd-journal.plugin/systemd-journal.c b/collectors/systemd-journal.plugin/systemd-journal.c index 08a1891e5a..4c670632ac 100644 --- a/collectors/systemd-journal.plugin/systemd-journal.c +++ b/collectors/systemd-journal.plugin/systemd-journal.c @@ -305,14 +305,23 @@ static void systemd_journal_transform_gid(FACETS *facets __maybe_unused, BUFFER } static void systemd_journal_dynamic_row_id(FACETS *facets __maybe_unused, BUFFER *json_array, FACET_ROW_KEY_VALUE *rkv, FACET_ROW *row, void *data __maybe_unused) { - FACET_ROW_KEY_VALUE *syslog_identifier_rkv = dictionary_get(row->dict, "SYSLOG_IDENTIFIER"); FACET_ROW_KEY_VALUE *pid_rkv = dictionary_get(row->dict, "_PID"); + const char *pid = pid_rkv ? buffer_tostring(pid_rkv->wb) : FACET_VALUE_UNSET; + + FACET_ROW_KEY_VALUE *syslog_identifier_rkv = dictionary_get(row->dict, "SYSLOG_IDENTIFIER"); + const char *identifier = syslog_identifier_rkv ? buffer_tostring(syslog_identifier_rkv->wb) : FACET_VALUE_UNSET; - const char *identifier = syslog_identifier_rkv ? buffer_tostring(syslog_identifier_rkv->wb) : "UNKNOWN"; - const char *pid = pid_rkv ? buffer_tostring(pid_rkv->wb) : "UNKNOWN"; + if(strcmp(identifier, FACET_VALUE_UNSET) == 0) { + FACET_ROW_KEY_VALUE *comm_rkv = dictionary_get(row->dict, "_COMM"); + identifier = comm_rkv ? buffer_tostring(comm_rkv->wb) : FACET_VALUE_UNSET; + } buffer_flush(rkv->wb); - buffer_sprintf(rkv->wb, "%s[%s]", identifier, pid); + + if(strcmp(pid, FACET_VALUE_UNSET) == 0) + buffer_strcat(rkv->wb, identifier); + else + buffer_sprintf(rkv->wb, "%s[%s]", identifier, pid); buffer_json_add_array_item_string(json_array, buffer_tostring(rkv->wb)); } |