Fluentd
Search…
monitor_agent
The in_monitor_agent Input plugin exports Fluentd's internal metrics via REST API.
It is included in Fluentd's core.

Example Configuration

1
<source>
2
@type monitor_agent
3
bind 0.0.0.0
4
port 24220
5
</source>
Copied!
This configuration launches HTTP server with 24220 port and get metrics:
1
$ curl http://host:24220/api/plugins.json
Copied!
Also you can fetch the same data in LTSV format:
1
$ curl http://host:24220/api/plugins
Copied!
Refer to the Configuration File article for the basic structure and syntax of the configuration file.

Parameters

@type (required)

The value must be monitor_agent.

port

type
default
version
integer
24220
0.14.0
The port to listen to.

bind

type
default
version
string
0.0.0.0 (all addresses)
0.14.0
The bind address to listen to.

tag

type
default
version
string
nil
0.14.0
If you set this parameter, this plugin emits metrics as records. See "Reuse plugins" section.

emit_interval

type
default
version
integer
60
0.14.0
The interval time between event emits. This will be used when tag is configured.

include_config

type
default
version
bool
true
0.14.0
You can set this option to false to remove the config field from the response.

include_retry

type
default
version
bool
true
0.14.11
You can set this option to false to remove the retry field from the response.

Configuration Example

Here is a configuration example using in_monitor_agent:
1
<source>
2
@type monitor_agent
3
@id in_monitor_agent
4
include_config false
5
</source>
6
7
<source>
8
@type forward
9
@id in_forward
10
</source>
11
12
<match test.**>
13
@type elasticsearch
14
@id out_es
15
</match>
Copied!
When using this plugin, we strongly recommend setting @id on each plugin in use. This makes the task to identify which record corresponds to which plugin much easier. Without @id, Fluentd uses object_id as the unique identifier, so you cannot identify a record just by looking at its plugin_id field.

Output Example

Here is how the output looks like in JSON:
1
{
2
"plugins": [
3
{
4
"plugin_id": "in_monitor_agent",
5
"plugin_category": "input",
6
"type": "monitor_agent",
7
"output_plugin": false,
8
"retry_count": null
9
},
10
{
11
"plugin_id": "in_forward",
12
"plugin_category": "input",
13
"type": "forward",
14
"output_plugin": false,
15
"retry_count": null
16
},
17
{
18
"plugin_id": "out_es",
19
"plugin_category": "output",
20
"type": "elasticsearch",
21
"output_plugin": true,
22
"buffer_queue_length": 0,
23
"buffer_total_queued_size": 0,
24
"retry_count": 0,
25
"retry": {}
26
}
27
]
28
}
Copied!
If the plugin is an output plugin with the buffer settings, the metrics include the buffer related fields.

retry

If the output plugin is in retry status, additional fields are added to retry. For example, if the Elasticsearch plugin fails to flush the buffer.
Here is the response:
1
{
2
"plugin_id": "out_es",
3
"plugin_category": "output",
4
"type": "elasticsearch",
5
"output_plugin": true,
6
"buffer_queue_length": 1,
7
"buffer_total_queued_size": 0,
8
"retry_count": 3,
9
"retry": {
10
"start": "2018-01-30 22:42:47 +0900",
11
"steps": 2,
12
"next_time": "2018-01-30 22:42:52 +0900"
13
}
14
}
Copied!
steps field in retry show the number of flush failures, so next is the third try. retry_count is the total number of flush failures. This value is cleared when fluentd restarts, not when retry succeeds.

Tips and Tricks

How to use query parameters to tune outputs

This plugin supports a number of query parameters with which you can customize the output format of HTTP responses. For example, you can append debug=1 to the request URL to get the verbose internal metrics:
1
$ curl http://localhost:24220/api/plugins.json?debug=1
Copied!
The following list shows the available query parameters:
Parameter
Value
Explanation
debug
Constant
Expose additional internal metrics
with_ivars
Variable names
Expose the specified instance variables of each plugin
with_config
Boolean
Override the configuration option with_config
with_retry
Boolean
Override the configuration option with_retry
tag
Event tag
Only show plugins that matches the specified tag
@id
Plugin id
Filter plugins by plugin id
@type
Plugin type
Filter plugins by plugin type

How to emit metrics as events

You can emit the internal metrics as events by setting the tag.
For example:
1
<source>
2
@type monitor_agent
3
tag debug.monitor
4
emit_interval 60
5
port 24230
6
</source>
Copied!
Note that in_monitor_agent produces separate records for each plugin. Thus, using this configuration, you will receive events like below once per minute:
1
2018-01-30 22:53:29.591560000 +0900 debug.monitor: { "plugin_id":"object:3ffd9988bea0","plugin_category":"input","type":"monitor_agent","output_plugin":false,"retry_count":null}
2
2018-01-30 22:53:29.591560000 +0900 debug.monitor: { "plugin_id":"in_forward","plugin_category":"input","type":"forward","output_plugin":false,"retry_count":null}
3
2018-01-30 22:53:29.591560000 +0900 debug.monitor: { "plugin_id":"out_out","plugin_category":"output","type":"stdout","output_plugin":true,"retry_count":0}
Copied!

Multi-Process Environment

If you use this plugin under the multi-process environment, the HTTP server will be launched in each worker. Port is assigned sequentially. For example, with this configuration:
1
<system>
2
workers 3
3
</system>
4
5
<source>
6
@type monitor_agent
7
port 24230
8
</source>
Copied!
Three (3) HTTP servers will be launched with:
    port 24230 for worker 0
    port 24231 for worker 1
    port 24232 for worker 2
Note that you may need to set worker_id to @id parameter. See config article.
If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is an open-source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.
Last modified 4mo ago