auth0-log-extension-tools
Logs API Client
The API client is a low level client allowing you to fetch logs from the Auth0 Management API. This client will get an access_token from the Management API and cache it in memory for as long as it is valid.
const client = domain: clientId: clientSecret: tokenCache: myTokenCache; client ;
A custom token cache provider can be supplied to persist the token somewhere (instead of in memory):
{ return Promise; } { // Save the token somewhere return Promise; }
Logs API Stream
The stream client is a wrapper around the API client and allows you to fetch all logs from a specific point (the checkpoint ID).
const stream = domain: clientId: clientSecret: tokenCache: myTokenCache checkpointId: startCheckpoint types: 'ss' 'fn' ; // Get the first batch of 50 items.streamnext50; // Process batch of logs.stream; // We've reached the end of the stream OR rate limiting kicked in.stream; // An error occured when processing the stream.stream;
Logs Processor
The logs processor will orchestrate everything to make log shipping and processing much easier. It will handle retries, timeouts etc..
batchSize
: Size of the batch we'll make available in the handlermaxRetries
: How many times the batch should be retried (the send part) before discarding the logsmaxRunTimeSeconds
: How long the processor is allowed to runstartFrom
: The Auth0 Log identifier to start fromlogTypes
: An array of log types to filter onlogLevel
: The log level to filter on (0 = debug, 1 = info, 2 = warning, 3 = error, 4 = critical)
const processor = storageContext domain: clientId: clientSecret: batchSize: startFrom: logTypes: 'ss' 'fn' logLevel: ; processor ;