Monitoring

Fluent Bit comes with a built-in HTTP Server that can be used to query internal information and monitor metrics of each running plugin.

" class="reference-link">Getting Started

To get started, the first step is to enable the HTTP Server from the configuration file:

  1. [SERVICE]
  2. HTTP_Server On
  3. HTTP_Listen 0.0.0.0
  4. HTTP_PORT 2020
  5. [INPUT]
  6. Name cpu
  7. [OUTPUT]
  8. Name stdout
  9. Match *

the above configuration snippet will instruct Fluent Bit to start it HTTP Server on TCP Port 2020 and listening on all network interfaces:

  1. $ bin/fluent-bit -c fluent-bit.conf
  2. Fluent-Bit v0.14.x
  3. Copyright (C) Treasure Data
  4. [2017/10/27 19:08:24] [ info] [engine] started
  5. [2017/10/27 19:08:24] [ info] [http_server] listen iface=0.0.0.0 tcp_port=2020

now with a simple curl command is enough to gather some information:

  1. $ curl -s http://127.0.0.1:2020 | jq
  2. {
  3. "fluent-bit": {
  4. "version": "0.13.0",
  5. "edition": "Community",
  6. "flags": [
  7. "FLB_HAVE_TLS",
  8. "FLB_HAVE_METRICS",
  9. "FLB_HAVE_SQLDB",
  10. "FLB_HAVE_TRACE",
  11. "FLB_HAVE_HTTP_SERVER",
  12. "FLB_HAVE_FLUSH_LIBCO",
  13. "FLB_HAVE_SYSTEMD",
  14. "FLB_HAVE_VALGRIND",
  15. "FLB_HAVE_FORK",
  16. "FLB_HAVE_PROXY_GO",
  17. "FLB_HAVE_REGEX",
  18. "FLB_HAVE_C_TLS",
  19. "FLB_HAVE_SETJMP",
  20. "FLB_HAVE_ACCEPT4",
  21. "FLB_HAVE_INOTIFY"
  22. ]
  23. }
  24. }

Note that we are sending the curl command output to the jq program which helps to make the JSON data easy to read from the terminal. Fluent Bit don’t aim to do JSON pretty-printing.

" class="reference-link">REST API Interface

Fluent Bit aims to expose useful interfaces for monitoring, as of Fluent Bit v0.14 the following end points are available:

URI Description Data Format
/ Fluent Bit build information JSON
/api/v1/uptime Get uptime information in seconds and human readable format JSON
/api/v1/metrics Internal metrics per loaded plugin JSON
/api/v1/metrics/prometheus Internal metrics per loaded plugin ready to be consumed by a Prometheus Server Prometheus Text 0.0.4

Uptime Example

Query the service uptime with the following command:

  1. $ curl -s http://127.0.0.1:2020/api/v1/uptime | jq

it should print a similar output like this:

  1. {
  2. "uptime_sec": 8950000,
  3. "uptime_hr": "Fluent Bit has been running: 103 days, 14 hours, 6 minutes and 40 seconds"
  4. }

Metrics Examples

Query internal metrics in JSON format with the following command:

  1. $ curl -s http://127.0.0.1:2020/api/v1/metrics | jq

it should print a similar output like this:

  1. {
  2. "input": {
  3. "cpu.0": {
  4. "records": 8,
  5. "bytes": 2536
  6. }
  7. },
  8. "output": {
  9. "stdout.0": {
  10. "proc_records": 5,
  11. "proc_bytes": 1585,
  12. "errors": 0,
  13. "retries": 0,
  14. "retries_failed": 0
  15. }
  16. }
  17. }

Metrics in Prometheus format

Query internal metrics in Prometheus Text 0.0.4 format:

  1. $ curl -s http://127.0.0.1:2020/api/v1/metrics/prometheus

this time the same metrics will be in Prometheus format instead of JSON:

  1. fluentbit_input_records_total{name="cpu.0"} 57 1509150350542
  2. fluentbit_input_bytes_total{name="cpu.0"} 18069 1509150350542
  3. fluentbit_output_proc_records_total{name="stdout.0"} 54 1509150350542
  4. fluentbit_output_proc_bytes_total{name="stdout.0"} 17118 1509150350542
  5. fluentbit_output_errors_total{name="stdout.0"} 0 1509150350542
  6. fluentbit_output_retries_total{name="stdout.0"} 0 1509150350542
  7. fluentbit_output_retries_failed_total{name="stdout.0"} 0 1509150350542