Skip to content

Commit 58d72ce

Browse files
committed
Re-merge router_buffering feature into dev
This reverts commit 95a3ac5.
1 parent 83613bf commit 58d72ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3110
-1615
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ pipeline/mock_*.go
77
var/
88
*.sw?
99
externals
10+
*~

CHANGES.txt

+6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
Backwards Incompatibilities
55
---------------------------
66

7+
* Major overhaul of filter and output plugin APIs to support disk buffering
8+
(#1378).
9+
710
* Go 1.4 now required for building.
811

912
* Removed unused PipelinePack.Decoded attribute.
1013

1114
* LogOutput will write data to stdout instead of stderr (#1515).
1215

16+
* Using stftime literals for filenames during rotation in FileOutput plugin
17+
(#1469).
18+
1319
* Implemented stftime format codes in: filenames in FileOutput plugin,
1420
ESJsonEncoder, ESLogstashV0Encoder, Payload encoder (#1469, #1508).
1521

cmake/externals.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ if (INCLUDE_DOCKER_PLUGINS)
168168
endif()
169169

170170
if (INCLUDE_MOZSVC)
171-
add_external_plugin(git https://github.com/mozilla-services/heka-mozsvc-plugins f310f1589afca54ddf6c9f4de826b43acbc1f228)
171+
add_external_plugin(git https://github.com/mozilla-services/heka-mozsvc-plugins 848fc1f3aa858472150c7af5463661393d3c4f3b)
172172
git_clone(https://github.com/getsentry/raven-go 0cc1491d9d27b258a9b4f0238908cb0d51bd6c9b)
173173
add_dependencies(heka-mozsvc-plugins raven-go)
174174
endif()

docs/source/buffering.rst

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
.. _buffering:
2+
3+
=====================
4+
Configuring Buffering
5+
=====================
6+
7+
All filter and output plugins support the use of a disk based message queue.
8+
If ``use_buffering`` is set to true, then the router will deliver messages that
9+
match the plugin's :ref:`message matcher <message_matcher>` to the queue
10+
buffer, and the plugin will read from the queue to get messages to process,
11+
instead of the handoff happening in the process RAM via Go channels. This
12+
improves message delivery reliability and allows plugins to reprocess messages
13+
from the queue in cases where upstream servers are down or Heka is recovering
14+
from a hard shutdown.
15+
16+
Each queue buffer supports a few configuration settings in addition to any
17+
options which the plugin might support. These can be specified in a sub-section
18+
of the plugin's TOML configuration section entitled ``buffering``.
19+
20+
Buffering configuration settings
21+
================================
22+
23+
- max_file_size (uint64)
24+
The maximum size (in bytes) of a single file in the queue buffer. When a
25+
message would increase a queue file to greater than this size, the message
26+
will be written into a new file instead. Defaults to 128MiB. Value cannot
27+
be zero, if zero is specified the default will instead be used.
28+
29+
- max_buffer_size (uint64)
30+
Maximum amount of disk space (in bytes) that the entire queue buffer can
31+
consume. Defaults to 0, or no limit. The action taken when the maximum buffer
32+
size is reached is determined by the ``full_action`` setting.
33+
34+
- full_action (string)
35+
The action Heka will take if the queue buffer grows to larger than the
36+
maximum specified by the ``max_buffer_size`` setting. Must be one of the
37+
following values. Defaults to ``shutdown``, although specific plugins might
38+
override this default with a default of their own:
39+
40+
* ``shutdown``: Heka will stop all processing and attempt a clean shutdown.
41+
42+
* ``drop``: Heka will drop the current message and will continue to process
43+
future messages.
44+
45+
* ``block``: Heka will pause message delivery, applying back pressure through
46+
the router to the inputs. Delivery will resume if and when the
47+
queue buffer size reduces to below the specified maximum.
48+
49+
- cursor_update_count (uint)
50+
A plugin is responsible for notifying the queue buffer when a message has
51+
been processed by calling an ``UpdateCursor`` method on the
52+
PluginRunner. Some plugins call this for every message, while others call it
53+
only periodically after processing a large batch of messages. This setting
54+
specifies how many ``UpdateCursor`` calls must be made before the cursor
55+
location is flushed to disk. Defaults to 1, although specific plugins might
56+
override this default with a default of their own. Value cannot be zero, if
57+
zero is specified the default will be used instead.
58+
59+
Buffering Default Values
60+
========================
61+
62+
Please note that if you provide a `buffering` subsection for your plugin
63+
configuration, it is best to specify *all* of the available settings. In cases
64+
where the plugin specifies a non-standard default for one or more of these
65+
values, that default will only be applied if you omit the `buffering`
66+
subsection altogether. If you specify any of the values, it is expected that
67+
you will specify all of the values.
68+
69+
Sample Buffering Configuration
70+
==============================
71+
72+
The following is a sample TcpOutput configuration showing the use of buffering.
73+
74+
.. code-block:: ini
75+
76+
[TcpOutput]
77+
message_matcher = "Type !~ /^heka/"
78+
address = "upstream.example.com:5565"
79+
keep_alive = true
80+
use_buffering = true
81+
82+
[TcpOutput.buffering]
83+
max_file_size = 268435456 # 256MiB
84+
max_buffer_size = 1073741824 # 1GiB
85+
full_action = "block"
86+
cursor_update_count = 100

docs/source/config/filters/index.rst

+15-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,25 @@ initialization code.
2323
- ticker_interval (uint, optional):
2424
Frequency (in seconds) that a timer event will be sent to the filter.
2525
Defaults to not sending timer events.
26+
27+
.. versionadded:: 0.7
28+
2629
- can_exit (bool, optional)
27-
.. versionadded:: 0.7
28-
2930
Whether or not this plugin can exit without causing Heka to shutdown.
3031
Defaults to false for non-sandbox filters, and true for sandbox filters.
3132

33+
.. versionadded:: 0.10
34+
35+
- use_buffering (bool, optional)
36+
If true, all messages delivered to this filter will be buffered to disk
37+
before delivery, preventing back pressure and allowing retries in cases of
38+
message processing failure. Defaults to false, unless otherwise specified
39+
by the individual filter's documentation.
40+
- buffering (QueueBufferConfig, optional)
41+
A sub-section that specifies the settings to be used for the buffering
42+
behavior. This will only have any impact if `use_buffering` is set to
43+
true. See :ref:`buffering`.
44+
3245
Available Filter Plugins
3346
========================
3447

docs/source/config/inputs/docker_event.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _config_docker_event_input:
22

33
Docker Event Input
4-
=================
4+
==================
55

66
.. versionadded:: 0.10.0
77

docs/source/config/outputs/elasticsearch.rst

+6-17
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,12 @@ Config:
5050
An optional sub-section that specifies the settings to be used for any
5151
SSL/TLS encryption. This will only have any impact if `URL` uses the
5252
`HTTPS` URI scheme. See :ref:`tls`.
53-
- use_buffering: (bool, optional):
54-
Buffer records to a disk-backed buffer on the Heka server before writing them to ElasticSearch.
55-
Defaults to true.
56-
- queue_max_buffer_size (uint64, optional):
57-
Defines maximum queue buffer size, in bytes. Defaults to 0, which means no
58-
max.
59-
- queue_full_action (string, optional):
60-
Specifies how Heka should behave when the queue reaches the specified
61-
maximum capacity. There are currently three possible actions:
62-
63-
- `shutdown` - Shuts down Heka.
64-
- `drop` - New messages are dropped until queue is available again.
65-
Already queued messages are unaffected.
66-
- `block` - Blocks processing of messages, tries to push last message
67-
until its possible.
68-
69-
Defaults to `shutdown`.
53+
- use_buffering (bool, optional):
54+
Buffer records to a disk-backed buffer on the Heka server before writing
55+
them to ElasticSearch. Defaults to true.
56+
- buffering (QueueBufferConfig, optional):
57+
All of the :ref:`buffering <buffering>` config options are set to the
58+
standard default options.
7059

7160
Example:
7261

docs/source/config/outputs/tcp.rst

+10-20
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ Config:
2222

2323
- tls (TlsConfig, optional):
2424
A sub-section that specifies the settings to be used for any SSL/TLS
25-
encryption. This will only have any impact if `use_tls` is set to true.
25+
encryption. This will only have any impact if ``use_tls`` is set to true.
2626
See :ref:`tls`.
27-
- ticker_interval (uint, optional):
28-
Specifies how often, in seconds, the output queue files are rolled.
29-
Defaults to 300.
3027

3128
.. versionadded:: 0.6
3229

@@ -49,22 +46,15 @@ Config:
4946
Time duration in seconds that a TCP connection will be maintained before
5047
keepalive probes start being sent. Defaults to 7200 (i.e. 2 hours).
5148

52-
.. versionadded:: 0.9
49+
.. versionadded:: 0.10
5350

54-
- queue_max_buffer_size (uint64):
55-
Defines maximum queue buffer size, in bytes. Defaults to 0, which means no
56-
max.
57-
- queue_full_action (string, optional):
58-
Specifies how Heka should behave when the queue reaches the specified
59-
maximum capacity. There are currently three possible actions:
60-
61-
- `shutdown`: Shutdowns heka.
62-
- `drop`: Messages are dropped until queue is available again. Already queued
63-
messages are unaffected.
64-
- `block`: Blocks processing of messages, tries to push last message
65-
until its possible.
66-
67-
Defaults to `shutdown`.
51+
- use_buffering (bool, optional):
52+
Buffer records to a disk-backed buffer on the Heka server before sending
53+
them out over the TCP connection. Defaults to true.
54+
- buffering (QueueBufferConfig, optional):
55+
All of the :ref:`buffering <buffering>` config options are set to the
56+
standard default options, except for `cursor_update_count`, which is set to
57+
50 instead of the standard default of 1.
6858

6959
Example:
7060

@@ -74,4 +64,4 @@ Example:
7464
type = "TcpOutput"
7565
address = "heka-aggregator.mydomain.com:55"
7666
local_address = "127.0.0.1"
77-
message_matcher = "Type != 'logfile' && Type != 'heka.counter-output' && Type != 'heka.all-report'"
67+
message_matcher = "Type != 'logfile' && Type !~ /^heka\./'"

0 commit comments

Comments
 (0)