Skip to content

Commit

Permalink
out_stackdriver: use the correct project ID
Browse files Browse the repository at this point in the history
The value for project ID of monitored resources of a LogEntry should be
project ID, not the project number, which is in numeric format.

The value of the project ID of Cloud Logging's Monitored Resources are
documented in
https://cloud.google.com/logging/docs/api/v2/resource-list.

The project ID to be retrived from instance metadata is documented in
https://cloud.google.com/compute/docs/storing-retrieving-metadata#default.

Signed-off-by: Yen-Cheng Chou <[email protected]>
  • Loading branch information
StevenYCChou committed Sep 28, 2020
1 parent 0ae28f2 commit 9a7689d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/out_stackdriver/gce_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static int fetch_metadata(struct flb_stackdriver *ctx,
/* If runtime test mode is enabled, add test data */
if (ctx->ins->test_mode == FLB_TRUE) {
if (strcmp(uri, FLB_STD_METADATA_PROJECT_ID_URI) == 0) {
flb_sds_cat(payload, "111222333", 9);
flb_sds_cat(payload, "fluent-bit-test", 9);
return 0;
}
else if (strcmp(uri, FLB_STD_METADATA_ZONE_URI) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/out_stackdriver/gce_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "stackdriver.h"

/* Project ID metadata URI */
#define FLB_STD_METADATA_PROJECT_ID_URI "/computeMetadata/v1/project/numeric-project-id"
#define FLB_STD_METADATA_PROJECT_ID_URI "/computeMetadata/v1/project/project-id"

/* Zone metadata URI */
#define FLB_STD_METADATA_ZONE_URI "/computeMetadata/v1/instance/zone"
Expand Down
2 changes: 1 addition & 1 deletion tests/runtime/out_stackdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static void cb_check_gce_instance(void *ctx, int ffd,

/* project id */
ret = mp_kv_cmp(res_data, res_size,
"$resource['labels']['project_id']", "111222333");
"$resource['labels']['project_id']", "fluent-bit-test");
TEST_CHECK(ret == FLB_TRUE);

/* zone */
Expand Down

0 comments on commit 9a7689d

Please sign in to comment.