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

out_azure_logs_ingestion: make the stream_name explicit #8472

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/out_azure_logs_ingestion/azure_logs_ingestion.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_az_li, table_name),
"The name of the custom log table, including '_CL' suffix"
},
{
FLB_CONFIG_MAP_STR, "stream_name", (char *)NULL,
0, FLB_TRUE, offsetof(struct flb_az_li, stream_name),
"The stream name from the DCR"
},
/* optional params */
{
FLB_CONFIG_MAP_STR, "time_key", FLB_AZ_LI_TIME_KEY,
Expand Down
5 changes: 3 additions & 2 deletions plugins/out_azure_logs_ingestion/azure_logs_ingestion.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
/* auth url needs tenant_id */
#define FLB_AZ_LI_AUTH_URL_TMPLT "https://login.microsoftonline.com/"\
"%s/oauth2/v2.0/token"
/* DCE Full URL needs: dce_url, dcr_id, Log Analytics custom table name */
/* DCE Full URL needs: dce_url, dcr_id, stream_name */
#define FLB_AZ_LI_DCE_URL_TMPLT "%s/dataCollectionRules/%s/streams/"\
"Custom-%s?"FLB_AZ_LI_API_VERSION
"%s?"FLB_AZ_LI_API_VERSION
/* TLS Modes for upstream connection = FLB_IO_TLS or FLB_IO_OPT_TLS*/
#define FLB_AZ_LI_TLS_MODE FLB_IO_TLS
/* refresh token every 60 minutes */
Expand All @@ -47,6 +47,7 @@ struct flb_az_li {
flb_sds_t dce_url;
flb_sds_t dcr_id;
flb_sds_t table_name;
flb_sds_t stream_name;

/* time_generated: on/off */
int time_generated;
Expand Down
15 changes: 11 additions & 4 deletions plugins/out_azure_logs_ingestion/azure_logs_ingestion_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ struct flb_az_li* flb_az_li_ctx_create(struct flb_output_instance *ins,
return NULL;
}

/* config: 'stream_name' */
if (!ctx->stream_name) {
flb_plg_error(ins, "property 'stream_name' is not defined");
flb_az_li_ctx_destroy(ctx);
return NULL;
}

/* Allocate and set auth url */
ctx->auth_url = flb_sds_create_size(sizeof(FLB_AZ_LI_AUTH_URL_TMPLT) - 1 +
flb_sds_len(ctx->tenant_id));
Expand All @@ -106,15 +113,15 @@ struct flb_az_li* flb_az_li_ctx_create(struct flb_output_instance *ins,
ctx->dce_u_url = flb_sds_create_size(sizeof(FLB_AZ_LI_DCE_URL_TMPLT) - 1 +
flb_sds_len(ctx->dce_url) +
flb_sds_len(ctx->dcr_id) +
flb_sds_len(ctx->table_name));
flb_sds_len(ctx->stream_name));
if (!ctx->dce_u_url) {
flb_errno();
flb_az_li_ctx_destroy(ctx);
return NULL;
}
flb_sds_snprintf(&ctx->dce_u_url, flb_sds_alloc(ctx->dce_u_url),
FLB_AZ_LI_DCE_URL_TMPLT, ctx->dce_url,
ctx->dcr_id, ctx->table_name);
ctx->dcr_id, ctx->stream_name);

/* Initialize the auth mutex */
pthread_mutex_init(&ctx->token_mutex, NULL);
Expand All @@ -138,8 +145,8 @@ struct flb_az_li* flb_az_li_ctx_create(struct flb_output_instance *ins,
}
flb_output_upstream_set(ctx->u_dce, ins);

flb_plg_info(ins, "dce_url='%s', dcr='%s', table='%s', stream='Custom-%s'",
ctx->dce_url, ctx->dcr_id, ctx->table_name, ctx->table_name);
flb_plg_info(ins, "dce_url='%s', dcr='%s', table='%s', stream='%s'",
ctx->dce_url, ctx->dcr_id, ctx->table_name, ctx->stream_name);

return ctx;
}
Expand Down