-
Notifications
You must be signed in to change notification settings - Fork 1.9k
in_node_exporter_metrics: implement additional metrics (filesystem, EXT_* metrics, powersupplyclass) on node exporter metrics #11765
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
Open
cosmo0920
wants to merge
6
commits into
master
Choose a base branch
from
cosmo0920-implement-additional-metrics-on-node_exporter_metrics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,127
−16
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c4b5d7e
in_node_exporter_metrics: Implement metrics of powersupply
cosmo0920 b0364fe
in_node_exporter_metrics: collect TcpExt and IpExt counters on netstat
cosmo0920 97ba323
in_node_exporter_metrics: Add filesystem metrics for macOS
cosmo0920 c785d9d
in_node_exporter_metrics: Enable fielsystem metrics by default
cosmo0920 468dc36
in_node_exporter_metrics: Report powersupplyclass errors on exceptions
cosmo0920 ba016ed
in_node_exporter_metrics: Ensure ito destroy regex instances
cosmo0920 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ set(src | |
| ne_config.c | ||
| ne_systemd.c | ||
| ne_thermalzone.c | ||
| ne_powersupply.c | ||
| ne.c | ||
| ) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
191 changes: 191 additions & 0 deletions
191
plugins/in_node_exporter_metrics/ne_filesystem_darwin.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
|
|
||
| /* Fluent Bit | ||
| * ========== | ||
| * Copyright (C) 2015-2026 The Fluent Bit Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include <fluent-bit/flb_info.h> | ||
| #include <fluent-bit/flb_input_plugin.h> | ||
| #include <sys/param.h> | ||
| #include <sys/mount.h> | ||
|
|
||
| #include "ne.h" | ||
|
|
||
| static int filesystem_update(struct flb_ne *ctx) | ||
| { | ||
| int i; | ||
| int count; | ||
| int skip_flag; | ||
| uint64_t block_size; | ||
| uint64_t blocks; | ||
| uint64_t free_size; | ||
| uint64_t avail_size; | ||
| uint64_t size_bytes; | ||
| uint64_t avail_bytes; | ||
| uint64_t free_bytes; | ||
| uint64_t timestamp; | ||
| char *labels[3]; | ||
| struct statfs *mounts; | ||
|
|
||
| count = getmntinfo(&mounts, MNT_NOWAIT); | ||
| if (count == 0) { | ||
| return -1; | ||
| } | ||
|
|
||
| timestamp = cfl_time_now(); | ||
|
|
||
| for (i = 0; i < count; i++) { | ||
| skip_flag = flb_regex_match(ctx->fs_regex_skip_fs_types, | ||
| (unsigned char *) mounts[i].f_fstypename, | ||
| strlen(mounts[i].f_fstypename)); | ||
| if (skip_flag) { | ||
| continue; | ||
| } | ||
|
|
||
| skip_flag = flb_regex_match(ctx->fs_regex_skip_mount, | ||
| (unsigned char *) mounts[i].f_mntonname, | ||
| strlen(mounts[i].f_mntonname)); | ||
| if (skip_flag) { | ||
| continue; | ||
| } | ||
|
|
||
| labels[0] = mounts[i].f_mntfromname; | ||
| labels[1] = mounts[i].f_fstypename; | ||
| labels[2] = mounts[i].f_mntonname; | ||
|
|
||
| block_size = (uint64_t) mounts[i].f_bsize; | ||
| blocks = (uint64_t) mounts[i].f_blocks; | ||
| free_size = (uint64_t) mounts[i].f_bfree; | ||
| avail_size = (uint64_t) mounts[i].f_bavail; | ||
| avail_bytes = block_size * avail_size; | ||
| size_bytes = block_size * blocks; | ||
| free_bytes = block_size * free_size; | ||
|
|
||
| cmt_gauge_set(ctx->fs_avail_bytes, timestamp, avail_bytes, 3, labels); | ||
| cmt_gauge_set(ctx->fs_device_error, timestamp, 0, 3, labels); | ||
| cmt_gauge_set(ctx->fs_files, timestamp, (uint64_t) mounts[i].f_files, 3, labels); | ||
| cmt_gauge_set(ctx->fs_files_free, timestamp, (uint64_t) mounts[i].f_ffree, 3, labels); | ||
| cmt_gauge_set(ctx->fs_free_bytes, timestamp, free_bytes, 3, labels); | ||
| cmt_gauge_set(ctx->fs_readonly, timestamp, (mounts[i].f_flags & MNT_RDONLY) ? 1 : 0, 3, labels); | ||
| cmt_gauge_set(ctx->fs_size_bytes, timestamp, size_bytes, 3, labels); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static void ne_filesystem_destroy_regexes(struct flb_ne *ctx) | ||
| { | ||
| if (ctx->fs_regex_skip_mount != NULL) { | ||
| flb_regex_destroy(ctx->fs_regex_skip_mount); | ||
| ctx->fs_regex_skip_mount = NULL; | ||
| } | ||
|
|
||
| if (ctx->fs_regex_skip_fs_types != NULL) { | ||
| flb_regex_destroy(ctx->fs_regex_skip_fs_types); | ||
| ctx->fs_regex_skip_fs_types = NULL; | ||
| } | ||
| } | ||
|
|
||
| static int ne_filesystem_init(struct flb_ne *ctx) | ||
| { | ||
| ctx->fs_regex_skip_mount = flb_regex_create(ctx->fs_regex_ingore_mount_point_text); | ||
| if (ctx->fs_regex_skip_mount == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| ctx->fs_regex_skip_fs_types = flb_regex_create(ctx->fs_regex_ingore_filesystem_type_text); | ||
| if (ctx->fs_regex_skip_fs_types == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| ctx->fs_avail_bytes = cmt_gauge_create(ctx->cmt, "node", "filesystem", "avail_bytes", | ||
| "Filesystem space available to non-root users in bytes.", | ||
| 3, (char *[]) {"device", "fstype", "mountpoint"}); | ||
| if (ctx->fs_avail_bytes == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| ctx->fs_device_error = cmt_gauge_create(ctx->cmt, "node", "filesystem", "device_error", | ||
| "Whether an error occurred while getting statistics for the given device.", | ||
| 3, (char *[]) {"device", "fstype", "mountpoint"}); | ||
| if (ctx->fs_device_error == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| ctx->fs_files = cmt_gauge_create(ctx->cmt, "node", "filesystem", "files", | ||
| "Filesystem total file nodes.", | ||
| 3, (char *[]) {"device", "fstype", "mountpoint"}); | ||
| if (ctx->fs_files == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| ctx->fs_files_free = cmt_gauge_create(ctx->cmt, "node", "filesystem", "files_free", | ||
| "Filesystem total free file nodes.", | ||
| 3, (char *[]) {"device", "fstype", "mountpoint"}); | ||
| if (ctx->fs_files_free == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| ctx->fs_free_bytes = cmt_gauge_create(ctx->cmt, "node", "filesystem", "free_bytes", | ||
| "Filesystem free space in bytes.", | ||
| 3, (char *[]) {"device", "fstype", "mountpoint"}); | ||
| if (ctx->fs_free_bytes == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| ctx->fs_readonly = cmt_gauge_create(ctx->cmt, "node", "filesystem", "readonly", | ||
| "Filesystem read-only status.", | ||
| 3, (char *[]) {"device", "fstype", "mountpoint"}); | ||
| if (ctx->fs_readonly == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| ctx->fs_size_bytes = cmt_gauge_create(ctx->cmt, "node", "filesystem", "size_bytes", | ||
| "Filesystem size in bytes.", | ||
| 3, (char *[]) {"device", "fstype", "mountpoint"}); | ||
| if (ctx->fs_size_bytes == NULL) { | ||
| goto error; | ||
| } | ||
|
|
||
| return 0; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| error: | ||
| ne_filesystem_destroy_regexes(ctx); | ||
|
|
||
| return -1; | ||
| } | ||
|
|
||
| static int ne_filesystem_update(struct flb_input_instance *ins, | ||
| struct flb_config *config, void *in_context) | ||
| { | ||
| struct flb_ne *ctx = (struct flb_ne *) in_context; | ||
|
|
||
| return filesystem_update(ctx); | ||
| } | ||
|
|
||
| static int ne_filesystem_exit(struct flb_ne *ctx) | ||
| { | ||
| ne_filesystem_destroy_regexes(ctx); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| struct flb_ne_collector filesystem_collector = { | ||
| .name = "filesystem", | ||
| .cb_init = ne_filesystem_init, | ||
| .cb_update = ne_filesystem_update, | ||
| .cb_exit = ne_filesystem_exit | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.