Skip to content

Commit faa6076

Browse files
author
Florian Koch
committed
out_azure: Add support for the x-ms-AzureResourceId Header #2184
Signed-off-by: Florian Koch <flo@ctrl.wtf>
1 parent c0d8099 commit faa6076

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

plugins/out_azure/azure.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ static int build_headers(struct flb_http_client *c,
206206
flb_http_add_header(c, "Content-Type", 12, "application/json", 16);
207207
flb_http_add_header(c, "x-ms-date", 9, rfc1123date,
208208
flb_sds_len(rfc1123date));
209-
209+
/* Header resource_id is optional */
210+
if (ctx->resource_id) {
211+
flb_http_add_header(c, "x-ms-AzureResourceId", 20, ctx->resource_id ,flb_sds_len(ctx->resource_id));
212+
flb_plg_debug(ctx->ins, "resource_id=%s", ctx->resource_id);
213+
}
210214
size = 32 + flb_sds_len(ctx->customer_id) + olen;
211215
auth = flb_malloc(size);
212216
if (!auth) {

plugins/out_azure/azure.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct flb_azure {
3636
/* account setup */
3737
flb_sds_t customer_id;
3838
flb_sds_t log_type;
39+
flb_sds_t resource_id;
3940
flb_sds_t shared_key;
4041
flb_sds_t dec_shared_key;
4142

plugins/out_azure/azure_conf.c

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct flb_azure *flb_azure_conf_create(struct flb_output_instance *ins,
3131
size_t size;
3232
size_t olen;
3333
const char *tmp;
34+
const char *rid;
3435
const char *cid = NULL;
3536
struct flb_upstream *upstream;
3637
struct flb_azure *ctx;
@@ -110,6 +111,12 @@ struct flb_azure *flb_azure_conf_create(struct flb_output_instance *ins,
110111
return NULL;
111112
}
112113

114+
/* config: 'resource_id' */
115+
rid = flb_output_get_property("resource_id", ins);
116+
if (rid) {
117+
ctx->resource_id = flb_sds_create(rid);
118+
}
119+
113120
/* Validate hostname given by command line or 'Host' property */
114121
if (!ins->host.name && !cid) {
115122
flb_plg_error(ctx->ins, "property 'customer_id' is not defined");
@@ -218,6 +225,9 @@ int flb_azure_conf_destroy(struct flb_azure *ctx)
218225
if (ctx->log_type) {
219226
flb_sds_destroy(ctx->log_type);
220227
}
228+
if (ctx->resource_id) {
229+
flb_sds_destroy(ctx->resource_id);
230+
}
221231
if (ctx->time_key) {
222232
flb_sds_destroy(ctx->time_key);
223233
}

0 commit comments

Comments
 (0)