fluent-plugin-dynatrace, a plugin for fluentd
This project is developed, maintained and supported by Dynatrace.
A fluentd output plugin for sending logs to the Dynatrace Generic log ingest API v2. For more information, see the Dynatrace documentation on streaming logs with Fluentd.
Requirements
- An instance of fluentd >= v1.0 from which logs should be exported
- Ruby version >= 2.7.0
- An ActiveGate with the Generic log ingest API v2 enabled as described in the Dynatrace documentation
- A Dynatrace API token with the
logs.ingest
(Ingest Logs) scope
Installation
The plugin is published on Rubygems at https://rubygems.org/gems/fluent-plugin-dynatrace/.
To install it, run the following command:
fluent-gem install fluent-plugin-dynatrace
If you are using td-agent
, run:
td-agent-gem install fluent-plugin-dynatrace
Configuration options
Below is an example configuration which sends all logs with tags starting with dt
to Dynatrace.
<match dt.**>
@type dynatrace
active_gate_url https://{your-environment-activegate}:8021/e/{your-tenant}/api/v2/logs/ingest
api_token api_token
ssl_verify_none false
inject_timestamp false
</match>
If configured with custom <buffer>
settings, it is recommended to set flush_thread_count
to 1
.
The output plugin is limited to a single outgoing connection to Dynatrace and multiple export threads will have limited impact on export latency.
match directive
required
The match
directive is required to use an output plugin and tells fluentd which tags should be sent to the output plugin. In the above example, any tag that starts with dt.
will be sent to Dynatrace. For more information see how do match patterns work?.
@type
required
The @type
directive tells fluentd which plugin should be used for the corresponding match block. This should always be dynatrace
when you want to use the Dynatrace output plugin.
active_gate_url
required
This is the full URL of the Generic log ingest API v2 endpoint on your ActiveGate.
api_token
required
This is the Dynatrace API token which will be used to authenticate log ingest requests. It should be assigned only the logs.ingest
(Ingest Logs) scope.
ssl_verify_none
optional
default: false
It is recommended to leave this optional configuration set to false
unless absolutely required. Setting ssl_verify_none
to true
causes the output plugin to skip certificate verification when sending log ingest requests to SSL and TLS protected HTTPS endpoints. This option may be required if you are using a self-signed certificate, an expired certificate, or a certificate which was generated for a different domain than the one in use.
inject_timestamp
optional
default: false
If set to true, the timestamp of the log message will be injected into the body of the message in a format readable by Dynatrace.
Example
An full example demonstrating how to set up Fluentd on Kubernetes and export logs to Dynatrace can be found in the example folder.
Development
fluent-plugin-dynatrace
supports Ruby versions >= 2.7.0
but it is recommended that at least 2.7.2
is used for development. Ruby versions can be managed with tools like chruby or rbenv.
Install Dependencies
bundle install
Run All Tests
rake test
Run Specific Tests
# Run one test file
rake test TEST=test/plugin/out_dynatrace_test.rb
Code Style Checks
# Check for code style violations
rake rubocop
# Fix auto-fixable style violations
rake rubocop:auto_correct
Run all checks and build
# Runs rubocop, tests, and builds the gem
rake check