Skip to content

add rcptid to message related trace messages#3972

Merged
gaborznagy merged 13 commits intosyslog-ng:masterfrom
bazsi:msg-related-trace-messages-to-include-rcptid
May 12, 2022
Merged

add rcptid to message related trace messages#3972
gaborznagy merged 13 commits intosyslog-ng:masterfrom
bazsi:msg-related-trace-messages-to-include-rcptid

Conversation

@bazsi
Copy link
Collaborator

@bazsi bazsi commented Apr 3, 2022

The new log_msg_evt_tags() macro adds the rcptid value to the trace messages
making it easier to identify which msg we are manipulating at the moment.

In order to have a non-zero value for rcptid, one needs to enable
use-rcptid() in the configuration.

Fixes portions of #3967

@bazsi bazsi changed the title all: replace evt_tag_str("msg"...) with log_msg_evt_tags() everywhere add rcptid to message related trace messages Apr 3, 2022
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@bazsi bazsi force-pushed the msg-related-trace-messages-to-include-rcptid branch from 90f96a6 to 354ee30 Compare April 4, 2022 09:10
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@gaborznagy
Copy link
Collaborator

I'm not entirely convinced that adding rcptid to trace messages would help much by itself.
Trace messages are useful when only one message is sent to syslog-ng to debug the route a specific message takes.
For one message, an additional rcptid field to the trace message is redundant next to the address of the LogMessage address.

Of course, when a copy-on-write takes place that address is changed, so this is the scenario where rcptid would be useful, but then should we use the address of the LogMessage too?

And wouldn't be more convenient if trace level would turn on rcptid too ? (only from a user's point of view, as on code level they are very distant).

What do you think @rfaircloth-splunk, @bazsi?

@gaborznagy
Copy link
Collaborator

@bazsi you've updated the internal ivykis in this PR too. I guess that's accidental.

@gaborznagy
Copy link
Collaborator

Just a note about what we discussed:

  • we could enable rcptid by default, if it doesn't have significant negative effects on performance. We'll do a perf test on this.
  • we agreed that rcptid in the trace messages is better than the address of the LogMessage object.

@Kokan
Copy link
Collaborator

Kokan commented Apr 7, 2022

Just out of curiosity did some testing:

use_rcptid(no)
center;;received;a;processed;32729670
center;;received;a;processed;32791101
center;;received;a;processed;33424028
center;;received;a;processed;32887275
center;;received;a;processed;31181524
; (32729670+32791101+33424028+32887275+31181524)/5
        32602719.6

use_rcptid(yes)
center;;received;a;processed;26653406
center;;received;a;processed;27627752
center;;received;a;processed;29596720
center;;received;a;processed;29943992
center;;received;a;processed;30723320
; (26653406+27627752+29596720+29943992+30723320)/5
        28909038

; 28909038/32602719.6
        ~0.88670633476846514363

The configuration:

@version: 3.35

options {
#use_rcptid(yes);
};

source s {
    example_msg_generator (
        freq(0.00001)
        template("test message")
    );
    example_msg_generator (
        freq(0.00001)
        template("test message#2")
    );
    example_msg_generator (
        freq(0.00001)
        template("test message#2")
    );
};

log {
    source(s);
destination { file("/dev/null"); };
};

Running: syslog-ng -Fe & ; sleep 60 ; syslog-ng-ctl stats|grep 'center;;received' >> nouniqid ; syslog-ng-ctl stop

Based on this, it does not look like promising.

@bazsi bazsi force-pushed the msg-related-trace-messages-to-include-rcptid branch from 354ee30 to 3835efc Compare April 8, 2022 11:32
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@mitzkia
Copy link
Contributor

mitzkia commented Apr 11, 2022

@kira-syslogng do stresstest this please test branch=micek_perf_with_rcptid

@mitzkia
Copy link
Contributor

mitzkia commented Apr 11, 2022

@kira-syslogng do stresstest branch=micek_perf_with_rcptid

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@kira-syslogng
Copy link
Contributor

Kira-stress-test: Build SUCCESS

@mitzkia
Copy link
Contributor

mitzkia commented Apr 12, 2022

I have also run an internal perf test for enabled rcptid and it shows a ~30% decrease in our fastest combination.

  • it was a 5 minutes run
  • config
options {
    keep_hostname(yes);
    keep_timestamp(no);
    use_rcptid(yes);
    stats_level(2);
    use_dns(no);
};
source s_network_d7e6b375b62e415f8924fd4d883e0e80 {
network(
    ip(0.0.0.0)
    log_fetch_limit(1000)
    log_iw_size(10000)
    max_connections(10)
    port(61001)
);
};
destination d_file_91b6a8918dc742e98e8f447485517f5f {
file(
    "/tmp/output.$HOST" 
    flush_lines(1000)
    log_fifo_size(20000)
);
};
log {
source(s_network_d7e6b375b62e415f8924fd4d883e0e80);
destination(d_file_91b6a8918dc742e98e8f447485517f5f);
flags(flow-control);
};
  • loggen was used with the following parameters:
bin/loggen --active-connections=10 --dont-parse --inet --interval=300 --loop-reading --quiet --rate=1000000 --read-file=/tmp/loggen_input_file.txt --size=512 [ip] [port]

@Kokan
Copy link
Collaborator

Kokan commented Apr 12, 2022

I think using the rcptid is a good idea, but the current implementation is hungry.
According to the documentation it should be a monotone number, but I do not think that is really required. If we can let that requirement go, and focus on uniqueness. Maybe we can come up with a different implementation that does not require locking.
One such idea would be to have a per thread counter, which is prefixed with thread id.

@bazsi
Copy link
Collaborator Author

bazsi commented Apr 13, 2022 via email

@ryanfaircloth
Copy link
Contributor

This PR is exciting. One comment early on in the PR was trace is really only useful for a single message. I think that is a very legacy way of thinking. Using trace on console this is true if I was to get a json blog with a the rcpti field into Splunk, Humio or other observability tools I could much more easily troubleshoot a running problem

@bazsi bazsi force-pushed the msg-related-trace-messages-to-include-rcptid branch from 3835efc to 03e7a28 Compare April 14, 2022 05:03
@bazsi
Copy link
Collaborator Author

bazsi commented Apr 14, 2022

I have now added a commit to enable rcptid generation when --trace is passed as a command line option.

Also, I went back and added rcptid to the very first debug message we emit about a new incoming log message.

We can't enable rcptid now due to performance reasons, I'll revisit that in the future.

But with all of this, this can be merged in my opinion.

@kira-syslogng
Copy link
Contributor

Build FAILURE

@bazsi
Copy link
Collaborator Author

bazsi commented Apr 19, 2022

@kira-syslogng retest this please;

@kira-syslogng
Copy link
Contributor

Build FAILURE

@mitzkia
Copy link
Contributor

mitzkia commented Apr 25, 2022

@kira-syslogng retest this please;

@kira-syslogng
Copy link
Contributor

Build SUCCESS

Copy link
Collaborator

@gaborznagy gaborznagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bazsi, the local ivykis is still updated in this PR.

Sorry for putting request for change flag on it, but I would like to avoid others accidentally merge this.

Otherwise looks good to me.

@bazsi bazsi force-pushed the msg-related-trace-messages-to-include-rcptid branch from 03e7a28 to b634ae0 Compare May 3, 2022 07:06
@bazsi
Copy link
Collaborator Author

bazsi commented May 3, 2022

Sorry. git seems to add submodules to patches automatically during rebase, if I have it updated locally.

I now removed it explicitly.

gaborznagy
gaborznagy previously approved these changes May 3, 2022
Copy link
Collaborator

@gaborznagy gaborznagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, approve!

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@bazsi bazsi force-pushed the msg-related-trace-messages-to-include-rcptid branch from b634ae0 to f4229dc Compare May 4, 2022 16:07
@bazsi
Copy link
Collaborator Author

bazsi commented May 4, 2022

I have done one last rebase in which I've renamed the macro generating the tags to match conventions, as these functions
tend to be called evt_tag_*()

The trigger was that I was adding another set of these tags and it felt somewhat alien, I did some grepping:

lib/gprocess.c:evt_tag_cap_t(const char *tag, cap_t cap)
lib/value-pairs/evttag.c:evt_tag_value_pairs(const char *key, ValuePairs *vp, LogMessage *msg, LogTemplateEvalOptions *options)

We have some inconsistent names still:

bazsi@bzorp:~/src/syslog-ng/syslog-ng$ git grep ^EVTTAG *.h
lib/cfg-lexer.h:EVTTAG *cfg_lexer_format_location_tag(CfgLexer *self, CFG_LTYPE *yylloc);
lib/cfg-tree.h:EVTTAG *log_expr_node_location_tag(LogExprNode *self);
lib/eventlog/src/evtlog.h:EVTTAG *evt_tag_str(const char *tag, const char *value);
lib/eventlog/src/evtlog.h:EVTTAG *evt_tag_mem(const char *tag, const void *value, size_t len);
lib/eventlog/src/evtlog.h:EVTTAG *evt_tag_int(const char *tag, int value);
lib/eventlog/src/evtlog.h:EVTTAG *evt_tag_long(const char *tag, long long value);
lib/eventlog/src/evtlog.h:EVTTAG *evt_tag_errno(const char *tag, int err);
lib/eventlog/src/evtlog.h:EVTTAG *evt_tag_printf(const char *tag, const char *format, ...) G_GNUC_PRINTF(2, 3);
lib/eventlog/src/evtlog.h:EVTTAG *evt_tag_inaddr(const char *tag, const struct in_addr *addr);
lib/eventlog/src/evtlog.h:EVTTAG *evt_tag_inaddr6(const char *tag, const struct in6_addr *addr);
lib/logpipe.h:EVTTAG *log_pipe_location_tag(LogPipe *pipe);
lib/tlscontext.h:EVTTAG *tls_context_format_tls_error_tag(TLSContext *self);
lib/tlscontext.h:EVTTAG *tls_context_format_location_tag(TLSContext *self);
lib/value-pairs/evttag.h:EVTTAG *evt_tag_value_pairs(const char *key, ValuePairs *vp, LogMessage *msg, LogTemplateEvalOptions *options);

Nevertheless, I like the one with evt_tag prefix better, so I quickly renamed the change in this patchset.

There are no other changes since @gaborznagy approved it, so please reapprove.

@kira-syslogng
Copy link
Contributor

Build SUCCESS

bazsi added 9 commits May 5, 2022 10:32
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
In preparation of moving log_msg_new() to an MsgFormat method, rename
msg_format_parse() and its related function to better express their
function, namely that they parse into an existing LogMessage instance.

Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
…t_parse()

log_msg_new() was actually a feature envy and should have been a method
for MsgFormat: it takes an MsgFormat instance and input data, and
based on this it created and populates a LogMessage instance.

Move this functionality from LogMessage to MsgFormat, straightening
the dependencies in the right direction.

Albeit the change is trivial, it cascades into a lot of files, primarily
into test code.

Test code should avoid doing syslog parsing anyway but in a lot of
cases those still use it.

Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
@bazsi bazsi force-pushed the msg-related-trace-messages-to-include-rcptid branch from f4229dc to 512288f Compare May 5, 2022 10:47
@bazsi
Copy link
Collaborator Author

bazsi commented May 5, 2022

@gaborznagy I am afraid the new additions to this branch as described in #3972 (comment) warrant a new review.

This branch is now a lot more than the rcptid tags in trace messages. The changes should be trivial but are quite sizable. Let me know if you want to split this.

@kira-syslogng
Copy link
Contributor

Build SUCCESS

MrAnno
MrAnno previously approved these changes May 5, 2022
Copy link
Collaborator

@MrAnno MrAnno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the refactor commits, they look really good.

bazsi added 2 commits May 5, 2022 13:45
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
Signed-off-by: Balazs Scheidler <bazsi77@gmail.com>
@bazsi bazsi force-pushed the msg-related-trace-messages-to-include-rcptid branch from 512288f to 2bb2539 Compare May 5, 2022 11:46
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@gaborznagy gaborznagy self-requested a review May 5, 2022 12:12
Copy link
Collaborator

@gaborznagy gaborznagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for kept you waiting, I've checked the internal build as discussed.
Approve.

@gaborznagy gaborznagy merged commit 8b7c37e into syslog-ng:master May 12, 2022
@abalage
Copy link

abalage commented Jun 8, 2022

I think #2828 can be closed thanks to this feature. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants