Fluentd
1.0
1.0
  • Introduction
  • Overview
    • Life of a Fluentd event
    • Support
    • FAQ
    • Logo
    • fluent-package v5 vs td-agent v4
  • Installation
    • Before Installation
    • Install fluent-package
      • RPM Package (Red Hat Linux)
      • DEB Package (Debian/Ubuntu)
      • .dmg Package (macOS)
      • .msi Installer (Windows)
    • Install calyptia-fluentd
      • RPM Package (Red Hat Linux)
      • DEB Package (Debian/Ubuntu)
      • .dmg Package (macOS)
      • .msi Installer (Windows)
    • Install by Ruby Gem
    • Install from Source
    • Post Installation Guide
    • Obsolete Installation
      • Treasure Agent v4 (EOL) Installation
        • Install by RPM Package v4 (Red Hat Linux)
        • Install by DEB Package v4 (Debian/Ubuntu)
        • Install by .dmg Package v4 (macOS)
        • Install by .msi Installer v4 (Windows)
      • Treasure Agent v3 (EOL) Installation
        • Install by RPM Package v3 (Red Hat Linux)
        • Install by DEB Package v3 (Debian/Ubuntu)
        • Install by .dmg Package v3 (macOS)
        • Install by .msi Installer v3 (Windows)
  • Configuration
    • Config File Syntax
    • Config File Syntax (YAML)
    • Routing Examples
    • Config: Common Parameters
    • Config: Parse Section
    • Config: Buffer Section
    • Config: Format Section
    • Config: Extract Section
    • Config: Inject Section
    • Config: Transport Section
    • Config: Storage Section
    • Config: Service Discovery Section
  • Deployment
    • System Configuration
    • Logging
    • Signals
    • RPC
    • High Availability Config
    • Performance Tuning
    • Multi Process Workers
    • Failure Scenarios
    • Plugin Management
    • Trouble Shooting
    • Fluentd UI
    • Linux Capability
    • Command Line Option
    • Source Only Mode
    • Zero-downtime restart
  • Container Deployment
    • Docker Image
    • Docker Logging Driver
    • Docker Compose
    • Kubernetes
  • Monitoring Fluentd
    • Overview
    • Monitoring by Prometheus
    • Monitoring by REST API
  • Input Plugins
    • tail
    • forward
    • udp
    • tcp
    • unix
    • http
    • syslog
    • exec
    • sample
    • monitor_agent
    • windows_eventlog
  • Output Plugins
    • file
    • forward
    • http
    • exec
    • exec_filter
    • secondary_file
    • copy
    • relabel
    • roundrobin
    • stdout
    • null
    • s3
    • kafka
    • elasticsearch
    • opensearch
    • mongo
    • mongo_replset
    • rewrite_tag_filter
    • webhdfs
    • buffer
  • Filter Plugins
    • record_transformer
    • grep
    • parser
    • geoip
    • stdout
  • Parser Plugins
    • regexp
    • apache2
    • apache_error
    • nginx
    • syslog
    • ltsv
    • csv
    • tsv
    • json
    • msgpack
    • multiline
    • none
  • Formatter Plugins
    • out_file
    • json
    • ltsv
    • csv
    • msgpack
    • hash
    • single_value
    • stdout
    • tsv
  • Buffer Plugins
    • memory
    • file
    • file_single
  • Storage Plugins
    • local
  • Service Discovery Plugins
    • static
    • file
    • srv
  • Metrics Plugins
    • local
  • How-to Guides
    • Stream Analytics with Materialize
    • Send Apache Logs to S3
    • Send Apache Logs to Minio
    • Send Apache Logs to Mongodb
    • Send Syslog Data to Graylog
    • Send Syslog Data to InfluxDB
    • Send Syslog Data to Sematext
    • Data Analytics with Treasure Data
    • Data Collection with Hadoop (HDFS)
    • Simple Stream Processing with Fluentd
    • Stream Processing with Norikra
    • Stream Processing with Kinesis
    • Free Alternative To Splunk
    • Email Alerting like Splunk
    • How to Parse Syslog Messages
    • Cloud Data Logging with Raspberry Pi
  • Language Bindings
    • Java
    • Ruby
    • Python
    • Perl
    • PHP
    • Nodejs
    • Scala
  • Plugin Development
    • How to Write Input Plugin
    • How to Write Base Plugin
    • How to Write Buffer Plugin
    • How to Write Filter Plugin
    • How to Write Formatter Plugin
    • How to Write Output Plugin
    • How to Write Parser Plugin
    • How to Write Storage Plugin
    • How to Write Service Discovery Plugin
    • How to Write Tests for Plugin
    • Configuration Parameter Types
    • Upgrade Plugin from v0.12
  • Plugin Helper API
    • Plugin Helper: Child Process
    • Plugin Helper: Compat Parameters
    • Plugin Helper: Event Emitter
    • Plugin Helper: Event Loop
    • Plugin Helper: Extract
    • Plugin Helper: Formatter
    • Plugin Helper: Inject
    • Plugin Helper: Parser
    • Plugin Helper: Record Accessor
    • Plugin Helper: Server
    • Plugin Helper: Socket
    • Plugin Helper: Storage
    • Plugin Helper: Thread
    • Plugin Helper: Timer
    • Plugin Helper: Http Server
    • Plugin Helper: Service Discovery
  • Troubleshooting Guide
  • Appendix
    • Update from v0.12 to v1
    • td-agent v2 vs v3 vs v4
Powered by GitBook
On this page
  • Methods
  • service_discovery_configure(title, static_default_service_directive: nil, load_balancer: nil, custom_build_method: nil, interval: 3)
  • service_discovery_create_manager(title, configurations:, load_balancer: nil, custom_build_method: nil, interval: 3)
  • discovery_manager
  • Plugins using service_discovery
  • Migration guide from service_discovery_create_manager to more simpler helper method

Was this helpful?

  1. Plugin Helper API

Plugin Helper: Service Discovery

The service_discovery plugin helper provides users with the service discovery functionality.

Example:

require 'fluent/plugin/output'

module Fluent::Plugin
  class ExampleOutput < Output
    Fluent::Plugin.register_output('example', self)

    # 1. Load service_discovery helper
    helpers :service_discovery

    def configure(conf)
      super

      # 2. Create and start service discovery manager
      service_discovery_configure(
        :out_example_service_discovery_watcher,
        static_default_service_directive: 'server'
      )
    end

    def write(chunk)
      # 3. Select service to send data
      service_discovery_select_service do |node|
        send_data(node, chunk)
      end
    end

    def send_data(node, chunk)
      # Send data
    end
  end
end

NOTE: The launched plugin itself is managed by its plugin helper which stops it automatically. No need to stop it in the stop method.

Methods

service_discovery_configure(title, static_default_service_directive: nil, load_balancer: nil, custom_build_method: nil, interval: 3)

Since v1.13.0, discovery_manager is almost automatically configured only by calling this method.

Parameters

  • title: Thread name. Must be unique. (required)

  • static_default_service_directive: The directive name of each service when "static" service discovery is enabled in default.

  • load_balancer: object which has two methods #rebalance and #select_service.

  • custom_build_method: The custom method to build the service.

  • interval: Time interval for updating target service.

service_discovery_create_manager(title, configurations:, load_balancer: nil, custom_build_method: nil, interval: 3)

This method creates service_discovery_manager.

Parameters

  • title: Thread name. Must be unique. (required)

  • configurations: Configuration of target service. (required)

  • load_balancer: Balancing load to target servers. (default: Round-Robin)

  • custom_build_method: The custom method to build the service.

  • interval: Time interval for updating target service.

discovery_manager

It manages service discovery functionalities such as updating target services and selecting target services. It provides the select_service method that returns a target service to send data.

Plugins using service_discovery

Migration guide from service_discovery_create_manager to more simpler helper method

Here is the guide to migrate to newer API which is available since v1.13.0.

Example:

require 'fluent/plugin/output'

module Fluent::Plugin
  class ExampleOutput < Output
    Fluent::Plugin.register_output('example', self)

    helpers :service_discovery

    def configure(conf)
      super

      # 1. Remove the following code which parse 'service_discovery' section by yourself
      #
      # config = conf.elements(name: 'service_discovery').map do |s|
      #  { type: :static, conf: s }
      # end

      # 2. Remove the following code and use service_discovery_configure
      #
      # service_discovery_create_manager(
      #  :out_example_service_discovery_watcher,
      #  configurations: config,
      # )
      service_discovery_configure(
        :out_example_service_discovery_watcher,
        static_default_service_directive: 'server'
      )
    end

    def write(chunk)
      # 3. Remove the following code and use service_discovery_select_service to select service
      #
      # @discovery_manager.select_service do |node|
      #  send_data(node, chunk)
      # end
      service_discovery_select_service do |node|
        send_data(node, chunk)
      end
    end

    def send_data(node, chunk)
      # Send data
    end
  end
end

You can also use helper methods such as service_discovery_services or service_discovery_rebalance instead of @discovery_manager.services or @discovery_manager.rebalance.

PreviousPlugin Helper: Http ServerNextTroubleshooting Guide

Last updated 3 years ago

Was this helpful?

If this article is incorrect or outdated, or omits critical information, please . is an open-source project under . All components are available under the Apache 2 License.

out_forward
let us know
Fluentd
Cloud Native Computing Foundation (CNCF)