Skip to content
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

Config-related metrics #4420

Merged
merged 6 commits into from Apr 18, 2023
Merged

Config-related metrics #4420

merged 6 commits into from Apr 18, 2023

Conversation

MrAnno
Copy link
Collaborator

@MrAnno MrAnno commented Apr 11, 2023

New configuration-related metrics

syslogng_last_config_reload_timestamp_seconds 1681309903
syslogng_last_successful_config_reload_timestamp_seconds 1681309758
syslogng_last_config_file_modification_timestamp_seconds 1681309877

The main config file is monitored by CfgMonitor with inotify.
If inotify fails or is not available, the config is polled every 15 minutes.


syslog-ng configuration identifier

A new syslog-ng configuration keyword has been added, which allows specifying a config identifier. For example:

@config-id: cfg-20230404-13-g02b0850fc

This keyword can be used for config identification in managed environments, where syslog-ng instances and their
configuration are deployed/generated automatically.

syslog-ng-ctl config --id can be used to query the active configuration ID and the SHA256 hash of the full
"preprocessed" syslog-ng configuration. For example:

$ syslog-ng-ctl config --id
cfg-20230404-13-g02b0850fc (08ddecfa52a3443b29d5d5aa3e5114e48dd465e195598062da9f5fc5a45d8a83)

lib/pragma-grammar.ym Outdated Show resolved Hide resolved
lib/cfg.h Outdated Show resolved Hide resolved
@bazsi
Copy link
Collaborator

bazsi commented Apr 12, 2023

This is a cool feature. The only question I have was about using git commit ids in place of @config-id, if we resolve that, this could go in, I think.

The GlobalConfig ID consists of an optional user-supplied ID and the
SHA256 hash of the full preprocessed configuration.

The user-supplied part can be specified using the `@config-id` pragma,
for example:

@config-id: cfg-20230404-13-ge1602deee

Signed-off-by: László Várady <laszlo.varady@anno.io>
Signed-off-by: László Várady <laszlo.varady@anno.io>
@MrAnno
Copy link
Collaborator Author

MrAnno commented Apr 12, 2023

I've added a CfgMonitor class with inotify and polling support.

It might sound like a terrible overkill, but I think this unit will be useful in the future (we may want to do some additional clever actions when detecting a configuration change on disk).

…econds"

Signed-off-by: László Várady <laszlo.varady@anno.io>
MrAnno added a commit to MrAnno/syslog-ng that referenced this pull request Apr 12, 2023
Signed-off-by: László Várady <laszlo.varady@anno.io>
@MrAnno
Copy link
Collaborator Author

MrAnno commented Apr 12, 2023

@kira-syslogng do stresstest

@MrAnno
Copy link
Collaborator Author

MrAnno commented Apr 12, 2023

I've updated the PR description according to my changes.

This class can be used to be notified about config file changes on the
disk.

Currently, only the main config file is monitored, and the modification
event is emitted based on st_mtime.

Signed-off-by: László Várady <laszlo.varady@anno.io>
…onds"

Signed-off-by: László Várady <laszlo.varady@anno.io>
Signed-off-by: László Várady <laszlo.varady@anno.io>
@MrAnno
Copy link
Collaborator Author

MrAnno commented Apr 12, 2023

@kira-syslogng do stresstest

@kira-syslogng
Copy link
Contributor

Kira-stress-test: Build SUCCESS

Comment on lines +643 to +649
static void
_cfg_file_modified(const CfgMonitorEvent *event, gpointer c)
{
MainLoop *self = (MainLoop *) c;

stats_counter_set(self->metrics.last_cfgfile_mtime, (gsize) event->st.st_mtime);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nitpick]

I would add a check for event->event == MODIFIED, just to be sure we do not break this accidentally in the future.

@alltilla alltilla merged commit d4d5047 into syslog-ng:master Apr 18, 2023
17 checks passed
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.

None yet

4 participants