From d4f17b292920d9127033ada0f03113b7eb03d42d Mon Sep 17 00:00:00 2001 From: Craig Colegrove Date: Tue, 5 May 2026 10:52:00 -0700 Subject: [PATCH] Update logging example --- examples/logging-example/README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/logging-example/README.md b/examples/logging-example/README.md index de1f484..bf46d35 100644 --- a/examples/logging-example/README.md +++ b/examples/logging-example/README.md @@ -7,8 +7,8 @@ yet. Once the TSP is running, you can experiment with this example Node program. It illustrates the basics of how to use the Tenant Security Client (TSC) SDK to log security events. The example code shows two scenarios: -- logging a login security event with additional metadata -- logging an admin create security event with minimal metadata +- logging a login security event with additional metadata +- logging an admin create security event with minimal metadata To run the example, you will need to have Node installed on your computer. Try a `node -v` to see what version you are using. We tested the example code using v10.22.0 and v12.0.0. @@ -39,17 +39,18 @@ to the TSP. Same thing with "Successfully logged user login event" but for the l If you look in the TSP logs you should see something like: -```bash -{"service":"proxy","message":"Security Event Received","level":"INFO","timestamp":"2021-03-03T20:13:00.502269399+00:00","tenant_id":"tenant-gcp-l","rayid":"mkrWLrYq-gdRzhQe"} -{"service":"proxy","message":"Security Event Received","level":"INFO","timestamp":"2021-03-03T20:13:00.502294948+00:00","tenant_id":"tenant-gcp-l","rayid":"xLyf9BG2ToCbuzrJ"} -{"service":"proxy","message":"{\"iclFields\":{\"dataLabel\":\"PII\",\"requestId\":\"Rq8675309\",\"requestingId\":\"userId1\",\"sourceIp\":\"127.0.0.1\",\"objectId\":\"userId1\",\"event\":\"USER_LOGIN\"},\"customFields\":{\"field2\":\"pokey\",\"field1\":\"gumby\"}}","level":"INFO","timestamp":"2021-03-03T20:13:00.502315310+00:00","tenant_id":"tenant-gcp-l","rayid":"xLyf9BG2ToCbuzrJ"} -{"service":"proxy","message":"{\"iclFields\":{\"dataLabel\":null,\"requestId\":null,\"requestingId\":\"adminId1\",\"sourceIp\":null,\"objectId\":\"newAdmin2\",\"event\":\"ADMIN_ADD\"},\"customFields\":{}}","level":"INFO","timestamp":"2021-03-03T20:13:00.502334931+00:00","tenant_id":"tenant-gcp-l","rayid":"mkrWLrYq-gdRzhQe"} -{"service":"logdriver","message":"Making request to Stackdriver to write 2 log entries.","level":"INFO","timestamp":"2021-03-03T20:13:02.630478837+00:00","tenant_id":"tenant-gcp-l"} -{"service":"logdriver","message":"Successfully wrote 2 log entries to Stackdriver.","level":"INFO","timestamp":"2021-03-03T20:13:02.850532340+00:00","tenant_id":"tenant-gcp-l"} +``` +tenant-security-proxy-1 | {"contexts":"request","level":"INFO","service":"proxy","timestamp":"2026-05-05T17:44:47.667242Z","message":"Security Event Received","name":"request","ray_id":"pZY_gLl25tys429w","tenant_id":"tenant-gcp-l"} +tenant-security-proxy-1 | {"contexts":"request","level":"INFO","service":"proxy","timestamp":"2026-05-05T17:44:47.667242Z","message":"Security Event Received","name":"request","ray_id":"VeV-jMiKGU4Ie44N","tenant_id":"tenant-gcp-l"} +tenant-security-proxy-1 | {"contexts":"request","level":"INFO","service":"proxy","timestamp":"2026-05-05T17:44:47.667266Z","message":"{\"iclFields\":{\"dataLabel\":\"PII\",\"requestId\":\"Rq8675309\",\"requestingId\":\"userId1\",\"sourceIp\":\"127.0.0.1\",\"objectId\":\"userId1\",\"event\":\"USER_LOGIN\"},\"customFields\":{\"field1\":\"gumby\",\"field2\":\"pokey\"}}","name":"request","ray_id":"pZY_gLl25tys429w","tenant_id":"tenant-gcp-l"} +tenant-security-proxy-1 | {"contexts":"request","level":"INFO","service":"proxy","timestamp":"2026-05-05T17:44:47.667277Z","message":"{\"iclFields\":{\"dataLabel\":null,\"requestId\":null,\"requestingId\":\"adminId1\",\"sourceIp\":null,\"objectId\":\"newAdmin2\",\"event\":\"ADMIN_ADD\"},\"customFields\":{}}","name":"request","ray_id":"VeV-jMiKGU4Ie44N","tenant_id":"tenant-gcp-l"} +tenant-security-logdriver-1 | {"contexts":"main;batching;tenant","level":"INFO","service":"logdriver","timestamp":"2026-05-05T17:44:49.679271094Z","message":"BATCH: 2 log events received for an unknown tenant. Using a stdout logger for this tenant.","name":"tenant","tenant_id":"tenant-gcp-l"} +tenant-security-logdriver-1 | {"contexts":"main;batching;stdout client;write-entries","level":"INFO","service":"logdriver","timestamp":"2026-05-05T17:44:49.679569969Z","message":"{\"tenantId\":\"tenant-gcp-l\",\"timestamp\":\"2026-05-05T17:44:42.656Z\",\"iclFields\":{\"dataLabel\":\"PII\",\"sourceIp\":\"127.0.0.1\",\"objectId\":\"userId1\",\"requestingId\":\"userId1\",\"tspRayId\":\"ray_id\",\"event\":\"USER_LOGIN\",\"requestId\":\"Rq8675309\",\"logdriverRayId\":\"kuQ6xXLf2R20oOHX\"},\"customFields\":{\"field1\":\"gumby\",\"field2\":\"pokey\"}}","name":"write-entries"} +tenant-security-logdriver-1 | {"contexts":"main;batching;stdout client;write-entries","level":"INFO","service":"logdriver","timestamp":"2026-05-05T17:44:49.679677552Z","message":"{\"tenantId\":\"tenant-gcp-l\",\"timestamp\":\"2026-05-05T17:44:47.663Z\",\"iclFields\":{\"event\":\"ADMIN_ADD\",\"tspRayId\":\"ray_id\",\"requestingId\":\"adminId1\",\"logdriverRayId\":\"HmK3yMzAtG510ZNf\",\"objectId\":\"newAdmin2\"},\"customFields\":{}}","name":"write-entries"} ``` -This shows the TSP receiving these events, batching them up together, and sending them successfully to Stackdriver (the configured log sink for -`tenant-gcp-l`). +This shows the TSP receiving these events, batching them up together, and sending them successfully to Logdriver. Because this tenant does not have a log sink configured, +the security events will be output to Logdriver's stdout logs. If you would like to experiment with a different tenant, just do: