New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
visualize config graph #2990
visualize config graph #2990
Conversation
Build FAILURE |
81e3f7b
to
e79eaf1
Compare
Build SUCCESS |
lib/logmpx.c
Outdated
@@ -149,5 +166,7 @@ log_multiplexer_new(GlobalConfig *cfg) | |||
self->super.queue = log_multiplexer_queue; | |||
self->super.free_fn = log_multiplexer_free; | |||
self->next_hops = g_ptr_array_new(); | |||
log_pipe_append_description(&self->super, "multiplexer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional] I would consider instead of appending descriptions something like LogPiPe:to_json
virtual function, or a function that provides a key-value pair list/hashmap with things to know about a pipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the representation and walk logic was interleaving, leaving a lot of mess for the reviewers. I improved that part, now string manipulation is separated from the data representation. Please check if it is good enough now.
e79eaf1
to
16e28dd
Compare
Build SUCCESS |
16e28dd
to
fff2141
Compare
Build SUCCESS |
fff2141
to
3d676f2
Compare
Build FAILURE |
Am I allowed to link The problem is for now core does not link to |
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
This module will hold code that will help walking through the config graph. For example collecting nodes and arcs. Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
The new function will collect the arcs of the neighbors of a given LogPipe. Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
into dot format. Signed-off-by: Antal Nemes <antal.nemes@balabit.com>
3d676f2
to
3ece1d2
Compare
I have rewritten the PR from scratch.
I updated the pr description with the new functionality. Removing wip flag. |
Build SUCCESS |
@furiel all packages maintained by me (openSUSE/SLES, fedora/RHEL, FreeBSD) have JSON support in the core syslog-ng package. There was a bug in syslog-ng that it did not start with SCL-s included from syslog-ng.conf and JSON support missing. The easiest workaround for me was to make JSON a mandatory dependency.
So, from my part (covering probably 80%+ of our users) making JSON a mandatory dependency would not be any problem. Of course, for embedded guys it might be still a pain. |
@czanik thanks for the feedback. In the end I decided not to add json-c, with similar reasoning. Thinking about embedded systems, those could ship syslog-ng without json-c. They would most certainly do not need this feature, and they would prefer smaller deployment complexity. If some other feature pulls json-c in, then we can rewrite this part though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the modifications.
@furiel : I think, sooner or later, we need to add json as a hard dependency (just think of EWMM...). |
@furiel : I have three notes.
|
We had a similar discussion with Peter: https://github.com/syslog-ng/syslog-ng/pull/2990/files/e79eaf1929f4d6518355d04c48f2f40d52c2a830#diff-66cacb90ca599fbe12b333a3ea155664 Another idea was that later syslog-ng might change configuration graph after init. In that case it would be nice if we could dump the configuration whenever we want. This time of writing, the logpipes do not change after init (except maybe reload) so this is not necessarily a good argument.
I was aware that I am not familiar with visualization techniques, also there must be many ways/programs that could be used for visualizing, I wanted to make one thing for sure: to dump the graph some data in a popular format. So that if anyone has interest to work with the graph, they could have as easy job as much to transform to their data format of preference. To help them a little bit, I add an very simple example in python that could be used as a starting point. Why json? I was aware that it could be easily parsed with python. I also got a little hyped that with json-c, I can easily transform my graph representation into json, and serialize as string, maybe I could also support pretty printing. It turned out later that core does not link to json-c, and I did not want to be the first one that add such dependency. Then shortly considered xml, but in the end I was thinking it is somewhat easier to parse json than xml (this may be a prejudice from my side). That would have meant that I need to pull another dependency: libxml or glib-xml parser. So I dropped the xml idea. From that I went to the most obvious path, hand formatted json.
My original intention was just develop some tool that could help me understand #2989. Actually, graph visualization as feature was not my goal, just to pull things together enough to deal with that issue. Also, I wanted to make sure if someone else runs into a similar scenario, they could have some code that they could fiddle with, according to their needs. The target users were more the maintainers than the end users. It is visible from the patches, that the focus was more like grabbing as much info about the config, and a little portion is that deals with that we could end up with a screenshot. Where to go next? We can improve the graph walk. If we can collect enough information, we might add a post compile phase that optimizes the graph. Or we improve the the graph visualization. We could choose a better tool, maybe add information about the layouts, or groups. Nice coloring etc. I do not plan to continue either directions in the near future, though. For now I am happy that we could finally catch #2989. |
This patchset intends add supporting code so that users could visualize configuration graph. The results could be used for debugging.
Usage:
Optional:
The idea is simple: logpipes will be nodes, arcs will be connections either through multiplexer (
next_hop
) orpipe_next
. The walk starts fromcfg->initialized_pipes
. Anything that does something with message processing should be accessible from those.During graph walk, I needed to use
sets
when collecting nodes, because some pipes can occur multiple times during walk. For example multiplexers are added to initialized pipes, but also linked inside the graph.Some metadata data needed to be added that made easier to identify the logpipes. The metadata of choice were based on my needs in #2989, so it is surely incomplete. I do not plan to make this complete in the scope of this PR (I do not have any usecase that I could follow).
Here is an example for config:
And here is the output:
PS:
Me neither know what is that logpipe on the top right :)