-
Notifications
You must be signed in to change notification settings - Fork 1.9k
in_node_exporter: more pluggable structure #8077
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
Conversation
How to add new collector
1. Create common sourcee.g. #ifdef __linux__
#include "ne_new_linux.c"
#elif __APPLE__
#include "ne_new_darwin.c"
#else
/* Not supported */
struct flb_ne_collector new_collector = {
.name = "new",
.cb_init = NULL,
.cb_update = NULL,
.cb_exit = NULL
};
#endif2. Create common header#ifndef FLB_IN_NE_NEW_H
#define FLB_IN_NE_NEW_H
#include "ne.h"
extern struct flb_ne_collector new_collector;
#endif4. Add mk_list_addne.c: mk_list_add(&systemd_collector._head, &ctx->collectors);
mk_list_add(&processes_collector._head, &ctx->collectors);
mk_list_add(&new_collector._head, &ctx->collectors); // add here !
mk_list_foreach(head, &ctx->collectors) {
coll = mk_list_entry(head, struct flb_ne_collector, _head);
collectors_common_init(coll);
}5. Define config mapProperty name should be ne.c: {
FLB_CONFIG_MAP_TIME, "collector.new.scrape_interval", "0",
0, FLB_FALSE, 0,
"scrape interval to collect new metrics from the node."
},
Modify plugins/in_node_exporter_metrics/CMakeLists.txt to add |
85aa10b to
38fa888
Compare
38fa888 to
17dc64e
Compare
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
17dc64e to
a150551
Compare
cosmo0920
left a comment
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.
It would be really good to have! I love this patch.
I confirmed that this patch does not have any side effect on macOS. Everything is working as expected.
This patch is make more pluggable structure.
It is to remove similar codes for maintainability.
flb_ne_collectorne_filefd.[ch],ne_stat.[ch]andne_vmstat.[ch]ne_systemd.[ch]->ne_systemd_linux.[ch].struct flb_ne_collector
This struct represents common collector like plugin instance.
cpufreqcollector.%name%.scrape_intervalis defined on config map, this value is set by the value of config map. Default :scrape_intervalflb_input_set_collector_timeEnter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Configuration
Debug/Valgrind output
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.