From 803a806aae401417cb2313a5e71568cec31ec6f6 Mon Sep 17 00:00:00 2001 From: truthbk Date: Mon, 1 Nov 2021 14:55:18 -0400 Subject: [PATCH 1/3] datadog: support v2 endpoint This commit migrates the datadog plugin to use the now available v2 endpoints. The changes should be transparent to the user. Signed-off-by: truthbk --- plugins/out_datadog/datadog.c | 5 +++++ plugins/out_datadog/datadog.h | 4 ++++ plugins/out_datadog/datadog_conf.c | 3 ++- plugins/out_datadog/datadog_conf.h | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/out_datadog/datadog.c b/plugins/out_datadog/datadog.c index f684842776c..8d903753c20 100644 --- a/plugins/out_datadog/datadog.c +++ b/plugins/out_datadog/datadog.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -354,7 +355,11 @@ static void cb_datadog_flush(struct flb_event_chunk *event_chunk, FLB_OUTPUT_RETURN(FLB_ERROR); } + /* Add the required headers to the URI */ flb_http_add_header(client, "User-Agent", 10, "Fluent-Bit", 10); + flb_http_add_header(client, FLB_DATADOG_API_HDR, sizeof(FLB_DATADOG_API_HDR) - 1, ctx->api_key, flb_sds_len(ctx->api_key)); + flb_http_add_header(client, FLB_DATADOG_ORIGIN_HDR, sizeof(FLB_DATADOG_ORIGIN_HDR) - 1, "Fluent-Bit", 10); + flb_http_add_header(client, FLB_DATADOG_ORIGIN_VERSION_HDR, sizeof(FLB_DATADOG_ORIGIN_VERSION_HDR) - 1, FLB_VERSION_STR, sizeof(FLB_VERSION_STR) - 1); flb_http_add_header(client, FLB_DATADOG_CONTENT_TYPE, sizeof(FLB_DATADOG_CONTENT_TYPE) - 1, FLB_DATADOG_MIME_JSON, sizeof(FLB_DATADOG_MIME_JSON) - 1); diff --git a/plugins/out_datadog/datadog.h b/plugins/out_datadog/datadog.h index abcf8d26952..1ca2d6f058a 100644 --- a/plugins/out_datadog/datadog.h +++ b/plugins/out_datadog/datadog.h @@ -36,6 +36,10 @@ #define FLB_DATADOG_REMAP_PROVIDER "ecs" #define FLB_DATADOG_TAG_SEPERATOR "," +#define FLB_DATADOG_API_HDR "DD-API-KEY" +#define FLB_DATADOG_ORIGIN_HDR "DD-EVP-ORIGIN" +#define FLB_DATADOG_ORIGIN_VERSION_HDR "DD-EVP-ORIGIN-VERSION" + #define FLB_DATADOG_CONTENT_TYPE "Content-Type" #define FLB_DATADOG_MIME_JSON "application/json" diff --git a/plugins/out_datadog/datadog_conf.c b/plugins/out_datadog/datadog_conf.c index 3ddad3e276b..6baa7059c66 100644 --- a/plugins/out_datadog/datadog_conf.c +++ b/plugins/out_datadog/datadog_conf.c @@ -115,12 +115,13 @@ struct flb_out_datadog *flb_datadog_conf_create(struct flb_output_instance *ins, ctx->remap = tmp && (strlen(tmp) == strlen(FLB_DATADOG_REMAP_PROVIDER)) && \ (strncmp(tmp, FLB_DATADOG_REMAP_PROVIDER, strlen(tmp)) == 0); - ctx->uri = flb_sds_create("/v1/input/"); + ctx->uri = flb_sds_create("/api/v2/logs"); if (!ctx->uri) { flb_plg_error(ctx->ins, "error on uri generation"); flb_datadog_conf_destroy(ctx); return NULL; } + /* Add the api_key to the URI */ ctx->uri = flb_sds_cat(ctx->uri, ctx->api_key, flb_sds_len(ctx->api_key)); flb_plg_debug(ctx->ins, "uri: %s", ctx->uri); diff --git a/plugins/out_datadog/datadog_conf.h b/plugins/out_datadog/datadog_conf.h index a4547ba5e9a..057a5e5f2dc 100644 --- a/plugins/out_datadog/datadog_conf.h +++ b/plugins/out_datadog/datadog_conf.h @@ -21,7 +21,7 @@ #define FLB_OUT_DATADOG_CONF_H #include -#include +#include #include "datadog.h" From c118ca112bb870156e9c76f64b3566e1d613e038 Mon Sep 17 00:00:00 2001 From: truthbk Date: Fri, 25 Feb 2022 14:40:11 +0100 Subject: [PATCH 2/3] datadog: do not append api-key to uri Signed-off-by: truthbk --- plugins/out_datadog/datadog_conf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/out_datadog/datadog_conf.c b/plugins/out_datadog/datadog_conf.c index 6baa7059c66..def064c48c5 100644 --- a/plugins/out_datadog/datadog_conf.c +++ b/plugins/out_datadog/datadog_conf.c @@ -122,8 +122,6 @@ struct flb_out_datadog *flb_datadog_conf_create(struct flb_output_instance *ins, return NULL; } - /* Add the api_key to the URI */ - ctx->uri = flb_sds_cat(ctx->uri, ctx->api_key, flb_sds_len(ctx->api_key)); flb_plg_debug(ctx->ins, "uri: %s", ctx->uri); /* Get network configuration */ From 007c05dea68faa733b1e16749cdb96ae2428a8ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 10:13:55 +0000 Subject: [PATCH 3/3] workflows: bump actions/download-artifact from 2 to 4 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 4. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/staging-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging-build.yaml b/.github/workflows/staging-build.yaml index ccb9dac46ea..ff7cd28c28b 100644 --- a/.github/workflows/staging-build.yaml +++ b/.github/workflows/staging-build.yaml @@ -151,7 +151,7 @@ jobs: steps: - name: Download all artefacts continue-on-error: true - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: path: artifacts/