summaryrefslogtreecommitdiffstats
path: root/src/go/plugin/go.d/modules/fluentd
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/plugin/go.d/modules/fluentd')
l---------src/go/plugin/go.d/modules/fluentd/README.md1
-rw-r--r--src/go/plugin/go.d/modules/fluentd/apiclient.go101
-rw-r--r--src/go/plugin/go.d/modules/fluentd/charts.go37
-rw-r--r--src/go/plugin/go.d/modules/fluentd/collect.go66
-rw-r--r--src/go/plugin/go.d/modules/fluentd/config_schema.json183
-rw-r--r--src/go/plugin/go.d/modules/fluentd/fluentd.go122
-rw-r--r--src/go/plugin/go.d/modules/fluentd/fluentd_test.go127
-rw-r--r--src/go/plugin/go.d/modules/fluentd/init.go35
-rw-r--r--src/go/plugin/go.d/modules/fluentd/integrations/fluentd.md256
-rw-r--r--src/go/plugin/go.d/modules/fluentd/metadata.yaml192
-rw-r--r--src/go/plugin/go.d/modules/fluentd/testdata/config.json21
-rw-r--r--src/go/plugin/go.d/modules/fluentd/testdata/config.yaml18
-rw-r--r--src/go/plugin/go.d/modules/fluentd/testdata/plugins.json101
13 files changed, 1260 insertions, 0 deletions
diff --git a/src/go/plugin/go.d/modules/fluentd/README.md b/src/go/plugin/go.d/modules/fluentd/README.md
new file mode 120000
index 000000000..96241702f
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/README.md
@@ -0,0 +1 @@
+integrations/fluentd.md \ No newline at end of file
diff --git a/src/go/plugin/go.d/modules/fluentd/apiclient.go b/src/go/plugin/go.d/modules/fluentd/apiclient.go
new file mode 100644
index 000000000..1c6bf85a9
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/apiclient.go
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package fluentd
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "net/url"
+ "path"
+
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/web"
+)
+
+const pluginsPath = "/api/plugins.json"
+
+type pluginsInfo struct {
+ Payload []pluginData `json:"plugins"`
+}
+
+type pluginData struct {
+ ID string `json:"plugin_id"`
+ Type string `json:"type"`
+ Category string `json:"plugin_category"`
+ RetryCount *int64 `json:"retry_count"`
+ BufferTotalQueuedSize *int64 `json:"buffer_total_queued_size"`
+ BufferQueueLength *int64 `json:"buffer_queue_length"`
+}
+
+func (p pluginData) hasCategory() bool {
+ return p.RetryCount != nil
+}
+
+func (p pluginData) hasBufferQueueLength() bool {
+ return p.BufferQueueLength != nil
+}
+
+func (p pluginData) hasBufferTotalQueuedSize() bool {
+ return p.BufferTotalQueuedSize != nil
+}
+
+func newAPIClient(client *http.Client, request web.Request) *apiClient {
+ return &apiClient{httpClient: client, request: request}
+}
+
+type apiClient struct {
+ httpClient *http.Client
+ request web.Request
+}
+
+func (a apiClient) getPluginsInfo() (*pluginsInfo, error) {
+ req, err := a.createRequest(pluginsPath)
+ if err != nil {
+ return nil, fmt.Errorf("error on creating request : %v", err)
+ }
+
+ resp, err := a.doRequestOK(req)
+ defer closeBody(resp)
+ if err != nil {
+ return nil, err
+ }
+
+ var info pluginsInfo
+ if err = json.NewDecoder(resp.Body).Decode(&info); err != nil {
+ return nil, fmt.Errorf("error on decoding response from %s : %v", req.URL, err)
+ }
+
+ return &info, nil
+}
+
+func (a apiClient) doRequestOK(req *http.Request) (*http.Response, error) {
+ resp, err := a.httpClient.Do(req)
+ if err != nil {
+ return nil, fmt.Errorf("error on request: %v", err)
+ }
+
+ if resp.StatusCode != http.StatusOK {
+ return resp, fmt.Errorf("%s returned HTTP status %d", req.URL, resp.StatusCode)
+ }
+ return resp, nil
+}
+
+func (a apiClient) createRequest(urlPath string) (*http.Request, error) {
+ req := a.request.Copy()
+ u, err := url.Parse(req.URL)
+ if err != nil {
+ return nil, err
+ }
+
+ u.Path = path.Join(u.Path, urlPath)
+ req.URL = u.String()
+ return web.NewHTTPRequest(req)
+}
+
+func closeBody(resp *http.Response) {
+ if resp != nil && resp.Body != nil {
+ _, _ = io.Copy(io.Discard, resp.Body)
+ _ = resp.Body.Close()
+ }
+}
diff --git a/src/go/plugin/go.d/modules/fluentd/charts.go b/src/go/plugin/go.d/modules/fluentd/charts.go
new file mode 100644
index 000000000..b0034c026
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/charts.go
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package fluentd
+
+import "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
+
+type (
+ // Charts is an alias for module.Charts
+ Charts = module.Charts
+ // Dim is an alias for module.Dim
+ Dim = module.Dim
+)
+
+// TODO: units for buffer charts
+var charts = Charts{
+ {
+ ID: "retry_count",
+ Title: "Plugin Retry Count",
+ Units: "count",
+ Fam: "retry count",
+ Ctx: "fluentd.retry_count",
+ },
+ {
+ ID: "buffer_queue_length",
+ Title: "Plugin Buffer Queue Length",
+ Units: "queue length",
+ Fam: "buffer",
+ Ctx: "fluentd.buffer_queue_length",
+ },
+ {
+ ID: "buffer_total_queued_size",
+ Title: "Plugin Buffer Total Size",
+ Units: "buffer total size",
+ Fam: "buffer",
+ Ctx: "fluentd.buffer_total_queued_size",
+ },
+}
diff --git a/src/go/plugin/go.d/modules/fluentd/collect.go b/src/go/plugin/go.d/modules/fluentd/collect.go
new file mode 100644
index 000000000..14ee6df68
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/collect.go
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package fluentd
+
+import "fmt"
+
+func (f *Fluentd) collect() (map[string]int64, error) {
+ info, err := f.apiClient.getPluginsInfo()
+ if err != nil {
+ return nil, err
+ }
+
+ mx := make(map[string]int64)
+
+ for _, p := range info.Payload {
+ // TODO: if p.Category == "input" ?
+ if !p.hasCategory() && !p.hasBufferQueueLength() && !p.hasBufferTotalQueuedSize() {
+ continue
+ }
+
+ if f.permitPlugin != nil && !f.permitPlugin.MatchString(p.ID) {
+ f.Debugf("plugin id: '%s', type: '%s', category: '%s' denied", p.ID, p.Type, p.Category)
+ continue
+ }
+
+ id := fmt.Sprintf("%s_%s_%s", p.ID, p.Type, p.Category)
+
+ if p.hasCategory() {
+ mx[id+"_retry_count"] = *p.RetryCount
+ }
+ if p.hasBufferQueueLength() {
+ mx[id+"_buffer_queue_length"] = *p.BufferQueueLength
+ }
+ if p.hasBufferTotalQueuedSize() {
+ mx[id+"_buffer_total_queued_size"] = *p.BufferTotalQueuedSize
+ }
+
+ if !f.activePlugins[id] {
+ f.activePlugins[id] = true
+ f.addPluginToCharts(p)
+ }
+
+ }
+
+ return mx, nil
+}
+
+func (f *Fluentd) addPluginToCharts(p pluginData) {
+ id := fmt.Sprintf("%s_%s_%s", p.ID, p.Type, p.Category)
+
+ if p.hasCategory() {
+ chart := f.charts.Get("retry_count")
+ _ = chart.AddDim(&Dim{ID: id + "_retry_count", Name: p.ID})
+ chart.MarkNotCreated()
+ }
+ if p.hasBufferQueueLength() {
+ chart := f.charts.Get("buffer_queue_length")
+ _ = chart.AddDim(&Dim{ID: id + "_buffer_queue_length", Name: p.ID})
+ chart.MarkNotCreated()
+ }
+ if p.hasBufferTotalQueuedSize() {
+ chart := f.charts.Get("buffer_total_queued_size")
+ _ = chart.AddDim(&Dim{ID: id + "_buffer_total_queued_size", Name: p.ID})
+ chart.MarkNotCreated()
+ }
+}
diff --git a/src/go/plugin/go.d/modules/fluentd/config_schema.json b/src/go/plugin/go.d/modules/fluentd/config_schema.json
new file mode 100644
index 000000000..037420f74
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/config_schema.json
@@ -0,0 +1,183 @@
+{
+ "jsonSchema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "Fluentd collector configuration.",
+ "type": "object",
+ "properties": {
+ "update_every": {
+ "title": "Update every",
+ "description": "Data collection interval, measured in seconds.",
+ "type": "integer",
+ "minimum": 1,
+ "default": 1
+ },
+ "url": {
+ "title": "URL",
+ "description": "The URL of the Fluentd [monitoring agent](https://docs.fluentd.org/monitoring-fluentd/monitoring-rest-api).",
+ "type": "string",
+ "default": "http://127.0.0.1:24220",
+ "format": "uri"
+ },
+ "timeout": {
+ "title": "Timeout",
+ "description": "The timeout in seconds for the HTTP request.",
+ "type": "number",
+ "minimum": 0.5,
+ "default": 1
+ },
+ "not_follow_redirects": {
+ "title": "Not follow redirects",
+ "description": "If set, the client will not follow HTTP redirects automatically.",
+ "type": "boolean"
+ },
+ "username": {
+ "title": "Username",
+ "description": "The username for basic authentication.",
+ "type": "string",
+ "sensitive": true
+ },
+ "password": {
+ "title": "Password",
+ "description": "The password for basic authentication.",
+ "type": "string",
+ "sensitive": true
+ },
+ "proxy_url": {
+ "title": "Proxy URL",
+ "description": "The URL of the proxy server.",
+ "type": "string"
+ },
+ "proxy_username": {
+ "title": "Proxy username",
+ "description": "The username for proxy authentication.",
+ "type": "string",
+ "sensitive": true
+ },
+ "proxy_password": {
+ "title": "Proxy password",
+ "description": "The password for proxy authentication.",
+ "type": "string",
+ "sensitive": true
+ },
+ "headers": {
+ "title": "Headers",
+ "description": "Additional HTTP headers to include in the request.",
+ "type": [
+ "object",
+ "null"
+ ],
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "tls_skip_verify": {
+ "title": "Skip TLS verification",
+ "description": "If set, TLS certificate verification will be skipped.",
+ "type": "boolean"
+ },
+ "tls_ca": {
+ "title": "TLS CA",
+ "description": "The path to the CA certificate file for TLS verification.",
+ "type": "string",
+ "pattern": "^$|^/"
+ },
+ "tls_cert": {
+ "title": "TLS certificate",
+ "description": "The path to the client certificate file for TLS authentication.",
+ "type": "string",
+ "pattern": "^$|^/"
+ },
+ "tls_key": {
+ "title": "TLS key",
+ "description": "The path to the client key file for TLS authentication.",
+ "type": "string",
+ "pattern": "^$|^/"
+ },
+ "body": {
+ "title": "Body",
+ "type": "string"
+ },
+ "method": {
+ "title": "Method",
+ "type": "string"
+ }
+ },
+ "required": [
+ "url"
+ ],
+ "additionalProperties": false,
+ "patternProperties": {
+ "^name$": {}
+ }
+ },
+ "uiSchema": {
+ "ui:flavour": "tabs",
+ "ui:options": {
+ "tabs": [
+ {
+ "title": "Base",
+ "fields": [
+ "update_every",
+ "url",
+ "timeout",
+ "not_follow_redirects"
+ ]
+ },
+ {
+ "title": "Auth",
+ "fields": [
+ "username",
+ "password"
+ ]
+ },
+ {
+ "title": "TLS",
+ "fields": [
+ "tls_skip_verify",
+ "tls_ca",
+ "tls_cert",
+ "tls_key"
+ ]
+ },
+ {
+ "title": "Proxy",
+ "fields": [
+ "proxy_url",
+ "proxy_username",
+ "proxy_password"
+ ]
+ },
+ {
+ "title": "Headers",
+ "fields": [
+ "headers"
+ ]
+ }
+ ]
+ },
+ "uiOptions": {
+ "fullPage": true
+ },
+ "body": {
+ "ui:widget": "hidden"
+ },
+ "method": {
+ "ui:widget": "hidden"
+ },
+ "timeout": {
+ "ui:help": "Accepts decimals for precise control (e.g., type 1.5 for 1.5 seconds)."
+ },
+ "username": {
+ "ui:widget": "password"
+ },
+ "proxy_username": {
+ "ui:widget": "password"
+ },
+ "password": {
+ "ui:widget": "password"
+ },
+ "proxy_password": {
+ "ui:widget": "password"
+ }
+ }
+}
diff --git a/src/go/plugin/go.d/modules/fluentd/fluentd.go b/src/go/plugin/go.d/modules/fluentd/fluentd.go
new file mode 100644
index 000000000..467edaac8
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/fluentd.go
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package fluentd
+
+import (
+ _ "embed"
+ "errors"
+ "time"
+
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/matcher"
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/web"
+)
+
+//go:embed "config_schema.json"
+var configSchema string
+
+func init() {
+ module.Register("fluentd", module.Creator{
+ JobConfigSchema: configSchema,
+ Create: func() module.Module { return New() },
+ Config: func() any { return &Config{} },
+ })
+}
+
+func New() *Fluentd {
+ return &Fluentd{
+ Config: Config{
+ HTTP: web.HTTP{
+ Request: web.Request{
+ URL: "http://127.0.0.1:24220",
+ },
+ Client: web.Client{
+ Timeout: web.Duration(time.Second),
+ },
+ }},
+ activePlugins: make(map[string]bool),
+ charts: charts.Copy(),
+ }
+}
+
+type Config struct {
+ UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
+ web.HTTP `yaml:",inline" json:""`
+ PermitPlugin string `yaml:"permit_plugin_id,omitempty" json:"permit_plugin_id"`
+}
+
+type Fluentd struct {
+ module.Base
+ Config `yaml:",inline" json:""`
+
+ charts *Charts
+
+ apiClient *apiClient
+
+ permitPlugin matcher.Matcher
+ activePlugins map[string]bool
+}
+
+func (f *Fluentd) Configuration() any {
+ return f.Config
+}
+
+func (f *Fluentd) Init() error {
+ if err := f.validateConfig(); err != nil {
+ f.Error(err)
+ return err
+ }
+
+ pm, err := f.initPermitPluginMatcher()
+ if err != nil {
+ f.Error(err)
+ return err
+ }
+ f.permitPlugin = pm
+
+ client, err := f.initApiClient()
+ if err != nil {
+ f.Error(err)
+ return err
+ }
+ f.apiClient = client
+
+ f.Debugf("using URL %s", f.URL)
+ f.Debugf("using timeout: %s", f.Timeout.Duration())
+
+ return nil
+}
+
+func (f *Fluentd) Check() error {
+ mx, err := f.collect()
+ if err != nil {
+ f.Error(err)
+ return err
+ }
+ if len(mx) == 0 {
+ return errors.New("no metrics collected")
+
+ }
+ return nil
+}
+
+func (f *Fluentd) Charts() *Charts {
+ return f.charts
+}
+
+func (f *Fluentd) Collect() map[string]int64 {
+ mx, err := f.collect()
+
+ if err != nil {
+ f.Error(err)
+ return nil
+ }
+
+ return mx
+}
+
+func (f *Fluentd) Cleanup() {
+ if f.apiClient != nil && f.apiClient.httpClient != nil {
+ f.apiClient.httpClient.CloseIdleConnections()
+ }
+}
diff --git a/src/go/plugin/go.d/modules/fluentd/fluentd_test.go b/src/go/plugin/go.d/modules/fluentd/fluentd_test.go
new file mode 100644
index 000000000..e21b58fc5
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/fluentd_test.go
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package fluentd
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "testing"
+
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+var (
+ dataConfigJSON, _ = os.ReadFile("testdata/config.json")
+ dataConfigYAML, _ = os.ReadFile("testdata/config.yaml")
+
+ dataPluginsMetrics, _ = os.ReadFile("testdata/plugins.json")
+)
+
+func Test_testDataIsValid(t *testing.T) {
+ for name, data := range map[string][]byte{
+ "dataConfigJSON": dataConfigJSON,
+ "dataConfigYAML": dataConfigYAML,
+ "dataPluginsMetrics": dataPluginsMetrics,
+ } {
+ require.NotNil(t, data, name)
+ }
+}
+
+func TestFluentd_ConfigurationSerialize(t *testing.T) {
+ module.TestConfigurationSerialize(t, &Fluentd{}, dataConfigJSON, dataConfigYAML)
+}
+
+func TestFluentd_Init(t *testing.T) {
+ // OK
+ job := New()
+ assert.NoError(t, job.Init())
+ assert.NotNil(t, job.apiClient)
+
+ //NG
+ job = New()
+ job.URL = ""
+ assert.Error(t, job.Init())
+}
+
+func TestFluentd_Check(t *testing.T) {
+ ts := httptest.NewServer(http.HandlerFunc(
+ func(w http.ResponseWriter, r *http.Request) {
+ _, _ = w.Write(dataPluginsMetrics)
+ }))
+ defer ts.Close()
+
+ // OK
+ job := New()
+ job.URL = ts.URL
+ require.NoError(t, job.Init())
+ require.NoError(t, job.Check())
+
+ // NG
+ job = New()
+ job.URL = "http://127.0.0.1:38001/api/plugins.json"
+ require.NoError(t, job.Init())
+ require.Error(t, job.Check())
+}
+
+func TestFluentd_Charts(t *testing.T) {
+ assert.NotNil(t, New().Charts())
+}
+
+func TestFluentd_Cleanup(t *testing.T) {
+ New().Cleanup()
+}
+
+func TestFluentd_Collect(t *testing.T) {
+ ts := httptest.NewServer(http.HandlerFunc(
+ func(w http.ResponseWriter, r *http.Request) {
+ _, _ = w.Write(dataPluginsMetrics)
+ }))
+ defer ts.Close()
+
+ job := New()
+ job.URL = ts.URL
+
+ require.NoError(t, job.Init())
+ require.NoError(t, job.Check())
+
+ expected := map[string]int64{
+ "output_stdout_stdout_output_retry_count": 0,
+ "output_td_tdlog_output_retry_count": 0,
+ "output_td_tdlog_output_buffer_queue_length": 0,
+ "output_td_tdlog_output_buffer_total_queued_size": 0,
+ }
+ assert.Equal(t, expected, job.Collect())
+ assert.Len(t, job.charts.Get("retry_count").Dims, 2)
+ assert.Len(t, job.charts.Get("buffer_queue_length").Dims, 1)
+ assert.Len(t, job.charts.Get("buffer_total_queued_size").Dims, 1)
+}
+
+func TestFluentd_InvalidData(t *testing.T) {
+ ts := httptest.NewServer(http.HandlerFunc(
+ func(w http.ResponseWriter, r *http.Request) {
+ _, _ = w.Write([]byte("hello and goodbye"))
+ }))
+ defer ts.Close()
+
+ job := New()
+ job.URL = ts.URL
+ require.NoError(t, job.Init())
+ assert.Error(t, job.Check())
+}
+
+func TestFluentd_404(t *testing.T) {
+ ts := httptest.NewServer(http.HandlerFunc(
+ func(w http.ResponseWriter, r *http.Request) {
+ w.WriteHeader(404)
+ }))
+ defer ts.Close()
+
+ job := New()
+ job.URL = ts.URL
+ require.NoError(t, job.Init())
+ assert.Error(t, job.Check())
+}
diff --git a/src/go/plugin/go.d/modules/fluentd/init.go b/src/go/plugin/go.d/modules/fluentd/init.go
new file mode 100644
index 000000000..6ee71c0a6
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/init.go
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package fluentd
+
+import (
+ "errors"
+
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/matcher"
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/web"
+)
+
+func (f *Fluentd) validateConfig() error {
+ if f.URL == "" {
+ return errors.New("url not set")
+ }
+
+ return nil
+}
+
+func (f *Fluentd) initPermitPluginMatcher() (matcher.Matcher, error) {
+ if f.PermitPlugin == "" {
+ return matcher.TRUE(), nil
+ }
+
+ return matcher.NewSimplePatternsMatcher(f.PermitPlugin)
+}
+
+func (f *Fluentd) initApiClient() (*apiClient, error) {
+ client, err := web.NewHTTPClient(f.Client)
+ if err != nil {
+ return nil, err
+ }
+
+ return newAPIClient(client, f.Request), nil
+}
diff --git a/src/go/plugin/go.d/modules/fluentd/integrations/fluentd.md b/src/go/plugin/go.d/modules/fluentd/integrations/fluentd.md
new file mode 100644
index 000000000..b4740a77a
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/integrations/fluentd.md
@@ -0,0 +1,256 @@
+<!--startmeta
+custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/go/plugin/go.d/modules/fluentd/README.md"
+meta_yaml: "https://github.com/netdata/netdata/edit/master/src/go/plugin/go.d/modules/fluentd/metadata.yaml"
+sidebar_label: "Fluentd"
+learn_status: "Published"
+learn_rel_path: "Collecting Metrics/Logs Servers"
+most_popular: False
+message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
+endmeta-->
+
+# Fluentd
+
+
+<img src="https://netdata.cloud/img/fluentd.svg" width="150"/>
+
+
+Plugin: go.d.plugin
+Module: fluentd
+
+<img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
+
+## Overview
+
+This collector monitors Fluentd servers.
+
+
+
+
+This collector is supported on all platforms.
+
+This collector supports collecting metrics from multiple instances of this integration, including remote instances.
+
+
+### Default Behavior
+
+#### Auto-Detection
+
+This integration doesn't support auto-detection.
+
+#### Limits
+
+The default configuration for this integration does not impose any limits on data collection.
+
+#### Performance Impact
+
+The default configuration for this integration is not expected to impose a significant performance impact on the system.
+
+
+## Metrics
+
+Metrics grouped by *scope*.
+
+The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
+
+
+
+### Per Fluentd instance
+
+These metrics refer to the entire monitored application.
+
+This scope has no labels.
+
+Metrics:
+
+| Metric | Dimensions | Unit |
+|:------|:----------|:----|
+| fluentd.retry_count | a dimension per plugin | count |
+| fluentd.buffer_queue_length | a dimension per plugin | queue_length |
+| fluentd.buffer_total_queued_size | a dimension per plugin | queued_size |
+
+
+
+## Alerts
+
+There are no alerts configured by default for this integration.
+
+
+## Setup
+
+### Prerequisites
+
+#### Enable monitor agent
+
+To enable monitor agent, follow the [official documentation](https://docs.fluentd.org/v1.0/articles/monitoring-rest-api).
+
+
+
+### Configuration
+
+#### File
+
+The configuration file name for this integration is `go.d/fluentd.conf`.
+
+
+You can edit the configuration file using the `edit-config` script from the
+Netdata [config directory](/docs/netdata-agent/configuration/README.md#the-netdata-config-directory).
+
+```bash
+cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
+sudo ./edit-config go.d/fluentd.conf
+```
+#### Options
+
+The following options can be defined globally: update_every, autodetection_retry.
+
+
+<details open><summary>Config options</summary>
+
+| Name | Description | Default | Required |
+|:----|:-----------|:-------|:--------:|
+| autodetection_retry | Recheck interval in seconds. Zero means no recheck will be scheduled. | 0 | no |
+| url | Server URL. | http://127.0.0.1:24220 | yes |
+| timeout | HTTP request timeout. | 1 | no |
+| username | Username for basic HTTP authentication. | | no |
+| password | Password for basic HTTP authentication. | | no |
+| proxy_url | Proxy URL. | | no |
+| proxy_username | Username for proxy basic HTTP authentication. | | no |
+| proxy_password | Password for proxy basic HTTP authentication. | | no |
+| method | HTTP request method. | GET | no |
+| body | HTTP request body. | | no |
+| headers | HTTP request headers. | | no |
+| not_follow_redirects | Redirect handling policy. Controls whether the client follows redirects. | no | no |
+| tls_skip_verify | Server certificate chain and hostname validation policy. Controls whether the client performs this check. | no | no |
+| tls_ca | Certification authority that the client uses when verifying the server's certificates. | | no |
+| tls_cert | Client TLS certificate. | | no |
+| tls_key | Client TLS key. | | no |
+
+</details>
+
+#### Examples
+
+##### Basic
+
+A basic example configuration.
+
+```yaml
+jobs:
+ - name: local
+ url: http://127.0.0.1:24220
+
+```
+##### HTTP authentication
+
+Basic HTTP authentication.
+
+<details open><summary>Config</summary>
+
+```yaml
+jobs:
+ - name: local
+ url: http://127.0.0.1:24220
+ username: username
+ password: password
+
+```
+</details>
+
+##### HTTPS with self-signed certificate
+
+Fluentd with enabled HTTPS and self-signed certificate.
+
+<details open><summary>Config</summary>
+
+```yaml
+jobs:
+ - name: local
+ url: https://127.0.0.1:24220
+ tls_skip_verify: yes
+
+```
+</details>
+
+##### Multi-instance
+
+> **Note**: When you define multiple jobs, their names must be unique.
+
+Collecting metrics from local and remote instances.
+
+
+<details open><summary>Config</summary>
+
+```yaml
+jobs:
+ - name: local
+ url: http://127.0.0.1:24220
+
+ - name: remote
+ url: http://192.0.2.1:24220
+
+```
+</details>
+
+
+
+## Troubleshooting
+
+### Debug Mode
+
+**Important**: Debug mode is not supported for data collection jobs created via the UI using the Dyncfg feature.
+
+To troubleshoot issues with the `fluentd` collector, run the `go.d.plugin` with the debug option enabled. The output
+should give you clues as to why the collector isn't working.
+
+- Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on
+ your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`.
+
+ ```bash
+ cd /usr/libexec/netdata/plugins.d/
+ ```
+
+- Switch to the `netdata` user.
+
+ ```bash
+ sudo -u netdata -s
+ ```
+
+- Run the `go.d.plugin` to debug the collector:
+
+ ```bash
+ ./go.d.plugin -d -m fluentd
+ ```
+
+### Getting Logs
+
+If you're encountering problems with the `fluentd` collector, follow these steps to retrieve logs and identify potential issues:
+
+- **Run the command** specific to your system (systemd, non-systemd, or Docker container).
+- **Examine the output** for any warnings or error messages that might indicate issues. These messages should provide clues about the root cause of the problem.
+
+#### System with systemd
+
+Use the following command to view logs generated since the last Netdata service restart:
+
+```bash
+journalctl _SYSTEMD_INVOCATION_ID="$(systemctl show --value --property=InvocationID netdata)" --namespace=netdata --grep fluentd
+```
+
+#### System without systemd
+
+Locate the collector log file, typically at `/var/log/netdata/collector.log`, and use `grep` to filter for collector's name:
+
+```bash
+grep fluentd /var/log/netdata/collector.log
+```
+
+**Note**: This method shows logs from all restarts. Focus on the **latest entries** for troubleshooting current issues.
+
+#### Docker Container
+
+If your Netdata runs in a Docker container named "netdata" (replace if different), use this command:
+
+```bash
+docker logs netdata 2>&1 | grep fluentd
+```
+
+
diff --git a/src/go/plugin/go.d/modules/fluentd/metadata.yaml b/src/go/plugin/go.d/modules/fluentd/metadata.yaml
new file mode 100644
index 000000000..0a6a66058
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/metadata.yaml
@@ -0,0 +1,192 @@
+plugin_name: go.d.plugin
+modules:
+ - meta:
+ id: collector-go.d.plugin-fluentd
+ plugin_name: go.d.plugin
+ module_name: fluentd
+ monitored_instance:
+ name: Fluentd
+ link: https://www.fluentd.org/
+ icon_filename: fluentd.svg
+ categories:
+ - data-collection.logs-servers
+ keywords:
+ - fluentd
+ - logging
+ related_resources:
+ integrations:
+ list: []
+ info_provided_to_referring_integrations:
+ description: ""
+ most_popular: false
+ overview:
+ data_collection:
+ metrics_description: |
+ This collector monitors Fluentd servers.
+ method_description: ""
+ supported_platforms:
+ include: []
+ exclude: []
+ multi_instance: true
+ additional_permissions:
+ description: ""
+ default_behavior:
+ auto_detection:
+ description: ""
+ limits:
+ description: ""
+ performance_impact:
+ description: ""
+ setup:
+ prerequisites:
+ list:
+ - title: Enable monitor agent
+ description: |
+ To enable monitor agent, follow the [official documentation](https://docs.fluentd.org/v1.0/articles/monitoring-rest-api).
+ configuration:
+ file:
+ name: go.d/fluentd.conf
+ options:
+ description: |
+ The following options can be defined globally: update_every, autodetection_retry.
+ folding:
+ title: Config options
+ enabled: true
+ list:
+ - name: autodetection_retry
+ description: Recheck interval in seconds. Zero means no recheck will be scheduled.
+ default_value: 0
+ required: false
+ - name: url
+ description: Server URL.
+ default_value: http://127.0.0.1:24220
+ required: true
+ - name: timeout
+ description: HTTP request timeout.
+ default_value: 1
+ required: false
+ - name: username
+ description: Username for basic HTTP authentication.
+ default_value: ""
+ required: false
+ - name: password
+ description: Password for basic HTTP authentication.
+ default_value: ""
+ required: false
+ - name: proxy_url
+ description: Proxy URL.
+ default_value: ""
+ required: false
+ - name: proxy_username
+ description: Username for proxy basic HTTP authentication.
+ default_value: ""
+ required: false
+ - name: proxy_password
+ description: Password for proxy basic HTTP authentication.
+ default_value: ""
+ required: false
+ - name: method
+ description: HTTP request method.
+ default_value: GET
+ required: false
+ - name: body
+ description: HTTP request body.
+ default_value: ""
+ required: false
+ - name: headers
+ description: HTTP request headers.
+ default_value: ""
+ required: false
+ - name: not_follow_redirects
+ description: Redirect handling policy. Controls whether the client follows redirects.
+ default_value: no
+ required: false
+ - name: tls_skip_verify
+ description: Server certificate chain and hostname validation policy. Controls whether the client performs this check.
+ default_value: no
+ required: false
+ - name: tls_ca
+ description: Certification authority that the client uses when verifying the server's certificates.
+ default_value: ""
+ required: false
+ - name: tls_cert
+ description: Client TLS certificate.
+ default_value: ""
+ required: false
+ - name: tls_key
+ description: Client TLS key.
+ default_value: ""
+ required: false
+ examples:
+ folding:
+ title: Config
+ enabled: true
+ list:
+ - name: Basic
+ folding:
+ enabled: false
+ description: A basic example configuration.
+ config: |
+ jobs:
+ - name: local
+ url: http://127.0.0.1:24220
+ - name: HTTP authentication
+ description: Basic HTTP authentication.
+ config: |
+ jobs:
+ - name: local
+ url: http://127.0.0.1:24220
+ username: username
+ password: password
+ - name: HTTPS with self-signed certificate
+ description: Fluentd with enabled HTTPS and self-signed certificate.
+ config: |
+ jobs:
+ - name: local
+ url: https://127.0.0.1:24220
+ tls_skip_verify: yes
+ - name: Multi-instance
+ description: |
+ > **Note**: When you define multiple jobs, their names must be unique.
+
+ Collecting metrics from local and remote instances.
+ config: |
+ jobs:
+ - name: local
+ url: http://127.0.0.1:24220
+
+ - name: remote
+ url: http://192.0.2.1:24220
+ troubleshooting:
+ problems:
+ list: []
+ alerts: []
+ metrics:
+ folding:
+ title: Metrics
+ enabled: false
+ description: ""
+ availability: []
+ scopes:
+ - name: global
+ description: These metrics refer to the entire monitored application.
+ labels: []
+ metrics:
+ - name: fluentd.retry_count
+ description: Plugin Retry Count
+ unit: count
+ chart_type: line
+ dimensions:
+ - name: a dimension per plugin
+ - name: fluentd.buffer_queue_length
+ description: Plugin Buffer Queue Length
+ unit: queue_length
+ chart_type: line
+ dimensions:
+ - name: a dimension per plugin
+ - name: fluentd.buffer_total_queued_size
+ description: Plugin Buffer Total Size
+ unit: queued_size
+ chart_type: line
+ dimensions:
+ - name: a dimension per plugin
diff --git a/src/go/plugin/go.d/modules/fluentd/testdata/config.json b/src/go/plugin/go.d/modules/fluentd/testdata/config.json
new file mode 100644
index 000000000..6477bd57d
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/testdata/config.json
@@ -0,0 +1,21 @@
+{
+ "update_every": 123,
+ "url": "ok",
+ "body": "ok",
+ "method": "ok",
+ "headers": {
+ "ok": "ok"
+ },
+ "username": "ok",
+ "password": "ok",
+ "proxy_url": "ok",
+ "proxy_username": "ok",
+ "proxy_password": "ok",
+ "timeout": 123.123,
+ "not_follow_redirects": true,
+ "tls_ca": "ok",
+ "tls_cert": "ok",
+ "tls_key": "ok",
+ "tls_skip_verify": true,
+ "permit_plugin_id": "ok"
+}
diff --git a/src/go/plugin/go.d/modules/fluentd/testdata/config.yaml b/src/go/plugin/go.d/modules/fluentd/testdata/config.yaml
new file mode 100644
index 000000000..0afd42e67
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/testdata/config.yaml
@@ -0,0 +1,18 @@
+update_every: 123
+url: "ok"
+body: "ok"
+method: "ok"
+headers:
+ ok: "ok"
+username: "ok"
+password: "ok"
+proxy_url: "ok"
+proxy_username: "ok"
+proxy_password: "ok"
+timeout: 123.123
+not_follow_redirects: yes
+tls_ca: "ok"
+tls_cert: "ok"
+tls_key: "ok"
+tls_skip_verify: yes
+permit_plugin_id: "ok"
diff --git a/src/go/plugin/go.d/modules/fluentd/testdata/plugins.json b/src/go/plugin/go.d/modules/fluentd/testdata/plugins.json
new file mode 100644
index 000000000..1fd921f7c
--- /dev/null
+++ b/src/go/plugin/go.d/modules/fluentd/testdata/plugins.json
@@ -0,0 +1,101 @@
+{
+ "plugins": [
+ {
+ "plugin_id": "input_forward",
+ "plugin_category": "input",
+ "type": "forward",
+ "config": {
+ "@type": "forward",
+ "@id": "input_forward"
+ },
+ "output_plugin": false,
+ "retry_count": null
+ },
+ {
+ "plugin_id": "input_http",
+ "plugin_category": "input",
+ "type": "http",
+ "config": {
+ "@type": "http",
+ "@id": "input_http",
+ "port": "8888"
+ },
+ "output_plugin": false,
+ "retry_count": null
+ },
+ {
+ "plugin_id": "input_debug_agent",
+ "plugin_category": "input",
+ "type": "debug_agent",
+ "config": {
+ "@type": "debug_agent",
+ "@id": "input_debug_agent",
+ "bind": "127.0.0.1",
+ "port": "24230"
+ },
+ "output_plugin": false,
+ "retry_count": null
+ },
+ {
+ "plugin_id": "object:3f7e4d08e3e0",
+ "plugin_category": "input",
+ "type": "monitor_agent",
+ "config": {
+ "@type": "monitor_agent",
+ "bind": "0.0.0.0",
+ "port": "24220"
+ },
+ "output_plugin": false,
+ "retry_count": null
+ },
+ {
+ "plugin_id": "output_td",
+ "plugin_category": "output",
+ "type": "tdlog",
+ "config": {
+ "@type": "tdlog",
+ "@id": "output_td",
+ "apikey": "xxxxxx",
+ "auto_create_table": ""
+ },
+ "output_plugin": true,
+ "buffer_queue_length": 0,
+ "buffer_total_queued_size": 0,
+ "retry_count": 0,
+ "retry": {}
+ },
+ {
+ "plugin_id": "output_stdout",
+ "plugin_category": "output",
+ "type": "stdout",
+ "config": {
+ "@type": "stdout",
+ "@id": "output_stdout"
+ },
+ "output_plugin": true,
+ "retry_count": 0,
+ "retry": {}
+ },
+ {
+ "plugin_id": "object:3f7e4b836770",
+ "plugin_category": "filter",
+ "type": "grep",
+ "config": {
+ "@type": "grep",
+ "regexp1": "message cool"
+ },
+ "output_plugin": false,
+ "retry_count": null
+ },
+ {
+ "plugin_id": "object:3f7e4bbe5a38",
+ "plugin_category": "filter",
+ "type": "record_transformer",
+ "config": {
+ "@type": "record_transformer"
+ },
+ "output_plugin": false,
+ "retry_count": null
+ }
+ ]
+} \ No newline at end of file