Dynatrace Transport
The Dynatrace transport sends logs to Dynatrace using their Log Monitoring API v2.
WARNING
See the "Limitations" section of the documentation for limits. This transport does not do any checks on limitations, so it's up to you to ensure you're not exceeding them. Although the limitations are pretty generous, it is advised to define the onError
callback to handle any errors that may occur.
Installation
bash
npm install loglayer @loglayer/transport-dynatrace serialize-error
bash
yarn add loglayer @loglayer/transport-dynatrace serialize-error
bash
pnpm add loglayer @loglayer/transport-dynatrace serialize-error
Usage
You will need an access token with the logs.ingest
scope. See access token documentation for more details.
typescript
import { LogLayer } from 'loglayer'
import { DynatraceTransport } from "@loglayer/transport-dynatrace"
const log = new LogLayer({
errorSerializer: serializeError,
transport: new DynatraceTransport({
url: "https://your-environment-id.live.dynatrace.com/api/v2/logs/ingest",
ingestToken: "your-api-token",
onError: (error) => {
console.error('Failed to send log to Dynatrace:', error)
}
})
})
log.info('Hello world')
Configuration
The transport accepts the following configuration options:
Required Options
url
: The URL to post logs to. Should be in one of these formats:https://<env-id>.live.dynatrace.com/api/v2/logs/ingest
https://{your-activegate-domain}:9999/e/{your-environment-id}/api/v2/logs/ingest
ingestToken
: An API token with thelogs.ingest
scope
Optional Options
onError
: A callback function that will be called when there's an error sending logs to Dynatraceenabled
: If set tofalse
, the transport will not send any logs (defaults totrue
)consoleDebug
: If set totrue
, logs will also be output to the console (defaults tofalse
)level
: Minimum log level to process. Logs below this level will be filtered out (defaults to"trace"
)
Log Format
The transport sends logs to Dynatrace in the following format:
json
{
"content": "Your log message",
"severity": "info|warn|error|debug",
"timestamp": "2024-01-01T00:00:00.000Z",
// Any additional metadata fields
}
Changelog
View the changelog here.