|
7 | 7 | Once the TSP is running, you can experiment with this example Node program. It illustrates the basics of how |
8 | 8 | to use the Tenant Security Client (TSC) SDK to log security events. The example code shows two scenarios: |
9 | 9 |
|
10 | | -- logging a login security event with additional metadata |
11 | | -- logging an admin create security event with minimal metadata |
| 10 | +- logging a login security event with additional metadata |
| 11 | +- logging an admin create security event with minimal metadata |
12 | 12 |
|
13 | 13 | To run the example, you will need to have Node installed on your computer. Try a `node -v` to see |
14 | 14 | 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 |
39 | 39 |
|
40 | 40 | If you look in the TSP logs you should see something like: |
41 | 41 |
|
42 | | -```bash |
43 | | -{"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"} |
44 | | -{"service":"proxy","message":"Security Event Received","level":"INFO","timestamp":"2021-03-03T20:13:00.502294948+00:00","tenant_id":"tenant-gcp-l","rayid":"xLyf9BG2ToCbuzrJ"} |
45 | | -{"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"} |
46 | | -{"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"} |
47 | | -{"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"} |
48 | | -{"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"} |
| 42 | +``` |
| 43 | +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"} |
| 44 | +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"} |
| 45 | +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"} |
| 46 | +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"} |
| 47 | +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"} |
| 48 | +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"} |
| 49 | +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"} |
49 | 50 | ``` |
50 | 51 |
|
51 | | -This shows the TSP receiving these events, batching them up together, and sending them successfully to Stackdriver (the configured log sink for |
52 | | -`tenant-gcp-l`). |
| 52 | +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, |
| 53 | +the security events will be output to Logdriver's stdout logs. |
53 | 54 |
|
54 | 55 | If you would like to experiment with a different tenant, just do: |
55 | 56 |
|
|
0 commit comments