Skip to content

Commit 4193553

Browse files
authored
Merge branch 'fluent:master' into master
2 parents 563999e + 7e7433c commit 4193553

File tree

17 files changed

+1149
-116
lines changed

17 files changed

+1149
-116
lines changed

cmake/plugins_options.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ DEFINE_OPTION(FLB_IN_PROCESS_EXPORTER_METRICS "Enable process exporter metrics i
4545
DEFINE_OPTION(FLB_IN_PROC "Enable Process input plugin" ON)
4646
DEFINE_OPTION(FLB_IN_PROMETHEUS_REMOTE_WRITE "Enable prometheus remote write input plugin" ON)
4747
DEFINE_OPTION(FLB_IN_PROMETHEUS_SCRAPE "Enable Prometheus Scrape input plugin" ON)
48+
DEFINE_OPTION(FLB_IN_PROMETHEUS_TEXTFILE "Enable Prometheus textfile input plugin" ON)
4849
DEFINE_OPTION(FLB_IN_RANDOM "Enable random input plugin" ON)
4950
DEFINE_OPTION(FLB_IN_SERIAL "Enable Serial input plugin" ON)
5051
DEFINE_OPTION(FLB_IN_SPLUNK "Enable Splunk HTTP HEC input plugin" ON)

lib/cmetrics/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
66
# CMetrics Version
77
set(CMT_VERSION_MAJOR 1)
88
set(CMT_VERSION_MINOR 0)
9-
set(CMT_VERSION_PATCH 4)
9+
set(CMT_VERSION_PATCH 5)
1010
set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}")
1111

1212
# Include helpers

lib/cmetrics/src/cmt_cat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static inline int cat_histogram_values(struct cmt_metric *metric_dst, struct cmt
108108
}
109109
}
110110

111-
for (i = 0; i < histogram->buckets->count; i++) {
111+
for (i = 0; i <= histogram->buckets->count; i++) {
112112
/* histogram buckets are always integers, no need to convert them */
113113
metric_dst->hist_buckets[i] += metric_src->hist_buckets[i];
114114
}

lib/cmetrics/src/cmt_histogram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct cmt_histogram_buckets *cmt_histogram_buckets_create_size(double *bkts, si
3636
}
3737

3838
/* besides buckets set by the user, we add an implicit bucket for +inf */
39-
upper_bounds = calloc(1, sizeof(double) * count + 1);
39+
upper_bounds = calloc(1, sizeof(double) * (count + 1));
4040
if (!upper_bounds) {
4141
cmt_errno();
4242
return NULL;

plugins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ endif()
276276

277277
REGISTER_IN_PLUGIN("in_fluentbit_metrics")
278278
REGISTER_IN_PLUGIN("in_prometheus_scrape")
279+
REGISTER_IN_PLUGIN("in_prometheus_textfile")
279280
REGISTER_IN_PLUGIN("in_emitter")
280281
REGISTER_IN_PLUGIN("in_tail")
281282
REGISTER_IN_PLUGIN("in_dummy")

plugins/filter_aws/aws.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,30 @@ static int get_ec2_metadata(struct flb_filter_aws *ctx)
926926
ctx->metadata_retrieved = FLB_TRUE;
927927
}
928928

929+
if (ctx->enable_entity) {
930+
if (!ctx->account_id) {
931+
ret = flb_aws_imds_request_by_key(ctx->client_imds, FLB_AWS_IMDS_ACCOUNT_ID_PATH,
932+
&ctx->account_id, &ctx->account_id_len,
933+
"accountId");
934+
935+
if (ret < 0) {
936+
flb_plg_error(ctx->ins, "Failed to get Account ID");
937+
return -1;
938+
}
939+
}
940+
941+
if (!ctx->instance_id) {
942+
ret = flb_aws_imds_request(ctx->client_imds, FLB_AWS_IMDS_INSTANCE_ID_PATH,
943+
&ctx->instance_id,
944+
&ctx->instance_id_len);
945+
if (ret < 0) {
946+
flb_plg_error(ctx->ins, "Failed to get instance ID");
947+
return -1;
948+
}
949+
}
950+
}
951+
952+
ctx->metadata_retrieved = FLB_TRUE;
929953
return 0;
930954
}
931955

@@ -1104,6 +1128,23 @@ static int cb_aws_filter(const void *data, size_t bytes,
11041128
}
11051129
}
11061130

1131+
if (ctx->enable_entity &&
1132+
ctx->instance_id &&
1133+
ctx->account_id &&
1134+
ret == FLB_EVENT_ENCODER_SUCCESS) {
1135+
ret = flb_log_event_encoder_append_body_values(
1136+
&log_encoder,
1137+
FLB_LOG_EVENT_CSTRING_VALUE(FLB_FILTER_AWS_ENTITY_INSTANCE_ID_KEY),
1138+
FLB_LOG_EVENT_STRING_VALUE(ctx->instance_id,
1139+
ctx->instance_id_len));
1140+
ret = flb_log_event_encoder_append_body_values(
1141+
&log_encoder,
1142+
FLB_LOG_EVENT_CSTRING_VALUE(FLB_FILTER_AWS_ENTITY_ACCOUNT_ID_KEY),
1143+
FLB_LOG_EVENT_STRING_VALUE(ctx->account_id,
1144+
ctx->account_id_len));
1145+
}
1146+
1147+
11071148
if (ret == FLB_EVENT_ENCODER_SUCCESS) {
11081149
ret = flb_log_event_encoder_commit_record(&log_encoder);
11091150
}
@@ -1273,6 +1314,12 @@ static struct flb_config_map config_map[] = {
12731314
0, FLB_TRUE, offsetof(struct flb_filter_aws, retry_required_interval),
12741315
"Defines minimum duration between retries for fetching metadata groups"
12751316
},
1317+
{
1318+
FLB_CONFIG_MAP_BOOL, "enable_entity", "false",
1319+
0, FLB_TRUE, offsetof(struct flb_filter_aws, enable_entity),
1320+
"Enable entity prefix for fields used for constructing entity."
1321+
"This currently only affects instance ID"
1322+
},
12761323
{0}
12771324
};
12781325

plugins/filter_aws/aws.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#define FLB_FILTER_AWS_AVAILABILITY_ZONE_KEY_LEN 2
2828
#define FLB_FILTER_AWS_INSTANCE_ID_KEY "ec2_instance_id"
2929
#define FLB_FILTER_AWS_INSTANCE_ID_KEY_LEN 15
30+
#define FLB_FILTER_AWS_ENTITY_INSTANCE_ID_KEY "aws_entity_ec2_instance_id"
31+
#define FLB_FILTER_AWS_ENTITY_INSTANCE_ID_KEY_LEN 26
3032
#define FLB_FILTER_AWS_INSTANCE_TYPE_KEY "ec2_instance_type"
3133
#define FLB_FILTER_AWS_INSTANCE_TYPE_KEY_LEN 17
3234
#define FLB_FILTER_AWS_PRIVATE_IP_KEY "private_ip"
@@ -37,6 +39,8 @@
3739
#define FLB_FILTER_AWS_AMI_ID_KEY_LEN 6
3840
#define FLB_FILTER_AWS_ACCOUNT_ID_KEY "account_id"
3941
#define FLB_FILTER_AWS_ACCOUNT_ID_KEY_LEN 10
42+
#define FLB_FILTER_AWS_ENTITY_ACCOUNT_ID_KEY "aws_entity_account_id"
43+
#define FLB_FILTER_AWS_ENTITY_ACCOUNT_ID_KEY_LEN 21
4044
#define FLB_FILTER_AWS_HOSTNAME_KEY "hostname"
4145
#define FLB_FILTER_AWS_HOSTNAME_KEY_LEN 8
4246

@@ -110,6 +114,11 @@ struct flb_filter_aws {
110114
/* tags_* fields are related to exposing EC2 tags in log labels
111115
* tags_enabled defines if EC2 tags functionality is enabled */
112116
int tags_enabled;
117+
/*
118+
* Enable entity prefix appending. This appends
119+
* 'aws_entity' to relevant keys
120+
*/
121+
int enable_entity;
113122

114123
/* tags_fetched defines if tag keys and values were fetched successfully
115124
* and might be used to inject into msgpack */
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set(src
2+
prometheus_textfile.c)
3+
4+
FLB_PLUGIN(in_prometheus_textfile "${src}" "")

0 commit comments

Comments
 (0)