1
-<!--
1
+---
2
title: "Streaming and replication"
3
description: "Replicate and mirror Netdata's metrics through real-time streaming from child to parent nodes. Then combine, correlate, and export."
4
custom_edit_url: https://github.com/netdata/netdata/edit/master/streaming/README.md
5
--->
5
+---
6
7
-# Streaming and replication
7
9
-Each Netdata is able to replicate/mirror its database to another Netdata, by streaming the collected
10
-metrics in real-time to it. This is quite different to [data archiving to third party time-series
8
+Each Netdata node is able to replicate/mirror its database to another Netdata node, by streaming the collected
9
+metrics in real-time. This is quite different to [data archiving to third party time-series
10
databases](/exporting/README.md).
11
+The nodes that send metrics are called **child** nodes, and the nodes that receive metrics are called **parent** nodes.
12
+
13
+There are also **proxy** nodes, which collect metrics from a child and sends it to a parent.
14
13
-When Netdata streams metrics to another Netdata, the receiving one is able to perform everything a Netdata instance is
14
-capable of. This includes the following:
15
+When one Netdata node streams metrics another, the receiving instance can use the data for all features of a typical Netdata node, for example:
16
17
- Visualize metrics with a dashboard
18
- Run health checks that trigger alarms and send alarm notifications
19
- Export metrics to an external time-series database
20
20
-The nodes that send metrics are called **child** nodes, and the nodes that receive metrics are called **parent** nodes.
21
-There are also **proxy** nodes, which collects metrics from a child and sends it to a parent.
21
+
22
+
23
24
## Supported configurations
25
26
### Netdata without a database or web API (headless collector)
27
27
-Local Netdata (child), **without any database or alarms**, collects metrics and sends them to another Netdata
28
+A local Netdata Agent (child), **without any database or alarms**, collects metrics and sends them to another Netdata node
29
(parent).
30
+The same parent can collect data for any number of child nodes and serves alerts for each child.
31
32
The node menu shows a list of all "databases streamed to" the parent. Clicking one of those links allows the user to
33
view the full dashboard of the child node. The URL has the form
34
`http://parent-host:parent-port/host/child-host/`.
35
34
-Alarms for the child are served by the parent.
36
36
-In this mode the child is just a plain data collector. It spawns all external plugins, but instead of maintaining a
37
-local database and accepting dashboard requests, it streams all metrics to the parent. The memory footprint is reduced
38
-significantly, to between 6 MiB and 40 MiB, depending on the enabled plugins. To reduce the memory usage as much as
37
+In a headless setup, the child acts as a plain data collector. It spawns all external plugins, but instead of maintaining a
38
+local database and accepting dashboard requests, it streams all metrics to the parent.
39
+
40
+This setup works great to reduce the memory footprint. Depending on the enabled plugins, memory usage is between 6 MiB and 40 MiB. To reduce the memory usage as much as
41
possible, refer to the [performance optimization guide](/docs/guides/configure/performance.md).
42
41
-The same parent can collect data for any number of child nodes.
43
44
### Database Replication
45
45
-Local Netdata (child), **with a local database (and possibly alarms)**, collects metrics and
46
-sends them to another Netdata (parent).
46
+The local Netdata Agent (child), **with a local database (and possibly alarms)**, collects metrics and
47
+sends them to another Netdata node (parent).
48
49
The user can use all the functions **at both** `http://child-ip:child-port/` and
50
`http://parent-host:parent-port/host/child-host/`.
51
52
The child and the parent may have different data retention policies for the same metrics.
53
53
-Alarms for the child are triggered by **both** the child and the parent (and actually
54
-each can have different alarms configurations or have alarms disabled).
54
+Alerts for the child are triggered by **both** the child and the parent.
55
+It is possible to enable different alert configurations on the parent and the child.
56
56
-Take a note, that custom chart names, configured on the child, should be in the form `type.name` to work correctly. The parent will truncate the `type` part and substitute the original chart `type` to store the name in the database.
57
+In order for custom chart names on the child to work correctly, follow the form `type.name`. The parent will truncate the `type` part and substitute the original chart `type` to store the name in the database.
58
59
### Netdata proxies
60
60
-Local Netdata (child), with or without a database, collects metrics and sends them to another
61
-Netdata (**proxy**), which may or may not maintain a database, which forwards them to another
61
+The local Netdata Agent(child), with or without a database, collects metrics and sends them to another
62
+Netdata node(**proxy**), which may or may not maintain a database, which forwards them to another
63
Netdata (parent).
64
64
-Alarms for the child can be triggered by any of the involved hosts that maintains a database.
65
+Alerts for the child can be triggered by any of the involved hosts that maintains a database.
66
66
-Any number of daisy chaining Netdata servers are supported, each with or without a database and
67
-with or without alarms for the child metrics.
67
+You can daisy-chain any number of Netdata, each with or without a database and
68
+with or without alerts for the child metrics.
69
69
-### mix and match with backends
70
+### Mix and match with backends
71
72
All nodes that maintain a database can also send their data to a backend database.
73
This allows quite complex setups.
74
75
Example:
76
76
-1. Netdata `A`, `B` do not maintain a database and stream metrics to Netdata `C`(live streaming functionality, i.e. this PR)
77
-2. Netdata `C` maintains a database for `A`, `B`, `C` and archives all metrics to `graphite` with 10 second detail (backends functionality)
78
-3. Netdata `C` also streams data for `A`, `B`, `C` to Netdata `D`, which also collects data from `E`, `F` and `G` from another DMZ (live streaming functionality, i.e. this PR)
79
-4. Netdata `D` is just a proxy, without a database, that streams all data to a remote site at Netdata `H`
80
-5. Netdata `H` maintains a database for `A`, `B`, `C`, `D`, `E`, `F`, `G`, `H` and sends all data to `opentsdb` with 5 seconds detail (backends functionality)
81
-6. alarms are triggered by `H` for all hosts
82
-7. users can use all the Netdata that maintain a database to view metrics (i.e. at `H` all hosts can be viewed).
77
+1. Netdata nodes `A` and `B` do not maintain a database and stream metrics to Netdata node `C`(live streaming functionality).
78
+2. Netdata node `C` maintains a database for `A`, `B`, `C` and archives all metrics to `graphite` with 10 second detail (backends functionality).
79
+3. Netdata node `C` also streams data for `A`, `B`, `C` to Netdata `D`, which also collects data from `E`, `F` and `G` from another DMZ (live streaming functionality).
80
+4. Netdata node `D` is just a proxy, without a database, that streams all data to a remote site at Netdata `H`.
81
+5. Netdata node `H` maintains a database for `A`, `B`, `C`, `D`, `E`, `F`, `G`, `H` and sends all data to `opentsdb` with 5 seconds detail (backends functionality)
82
+6. Alerts are triggered by `H` for all hosts.
83
+7. Users can use all Netdata nodes that maintain a database to view metrics (i.e. at `H` all hosts can be viewed).
84
85
## Configuration
86
86
-These are options that affect the operation of Netdata in this area:
87
+The following options affect how Netdata streams:
88
89
```
90
[global]
92
```
93
94
`[global].memory mode = none` disables the database at this host. This also disables health
94
-monitoring (there cannot be health monitoring without a database).
95
+monitoring because a node can't have health monitoring without a database.
96
97
```
98
[web]
118
`[backend]` configures data archiving to a backend (it archives all databases maintained on
119
this host).
120
120
-### streaming configuration
121
+### Streaming configuration
122
+
123
+The new file `stream.conf` contains streaming configuration for a sending and a receiving Netdata node.
124
+
125
+To configure streaming on your system:
126
+1. Generate an API key using `uuidgen`. Note: API keys are just random GUIDs. You can use the same API key on all your Netdata, or use a different API key for any pair of sending-receiving Netdata nodes.
127
122
-A new file is introduced: `stream.conf` (to edit it on your system run
123
-`/etc/netdata/edit-config stream.conf`). This file holds streaming configuration for both the
124
-sending and the receiving Netdata.
128
+2. Authorize the communication between a pair of sending-receiving Netdata nodes using the generated API key.
129
+Once the communication is authorized, the sending Netdata node can push metrics for any number of hosts.
130
126
-API keys are used to authorize the communication of a pair of sending-receiving Netdata.
127
-Once the communication is authorized, the sending Netdata can push metrics for any number of hosts.
131
+3. To edit `stream.conf`, run `/etc/netdata/edit-config stream.conf`
132
129
-You can generate an API key with the command `uuidgen`. API keys are just random GUIDs.
130
-You can use the same API key on all your Netdata, or use a different API key for any pair of
131
-sending-receiving Netdata.
133
+The following sections describe how you can configure sending and receiving Netdata nodes.
134
133
-##### options for the sending node
135
135
-This is the section for the sending Netdata. On the receiving node, `[stream].enabled` can be `no`.
136
+
137
+
138
+
139
+##### Options for the sending node
140
+
141
+This is the section for the sending Netdata node. On the receiving node, `[stream].enabled` can be `no`.
142
If it is `yes`, the receiving node will also stream the metrics to another node (i.e. it will be
143
a proxy).
144
147
enabled = yes | no
148
destination = IP:PORT[:SSL] ...
149
api key = XXXXXXXXXXX
144
-```
150
151
+[API_KEY]
152
+ enabled = yes | no
153
+
154
+[MACHINE_GUID]
155
+ enabled = yes | no
156
+```
157
This is an overview of how these options can be combined:
158
159
| target|memory<br/>mode|web<br/>mode|stream<br/>enabled|backend|alarms|dashboard|
165
166
For the options to encrypt the data stream between the child and the parent, refer to [securing the communication](#securing-streaming-communications)
167
157
-##### options for the receiving node
168
159
-`stream.conf` looks like this:
169
+##### Options for the receiving node
170
+
171
+For a receiving Netdata node, the `stream.conf` looks like this:
172
173
```sh
174
# replace API_KEY with your uuidgen generated GUID
204
a single host. The additional `page cache size` and `dbengine multihost disk space` configuration options
205
are inherited from the global Netdata configuration.
206
195
-##### allow from
207
+##### Allow from
208
209
`allow from` settings are [Netdata simple patterns](/libnetdata/simple_pattern/README.md): string matches
210
that use `*` as wildcard (any number of times) and a `!` prefix for a negative match.
213
214
`allow from` is available in Netdata v1.9+
215
204
-##### tracing
216
+##### Tracing
217
218
When a child is trying to push metrics to a parent or proxy, it logs entries like these:
219
241
242
### Securing streaming communications
243
232
-Netdata does not activate TLS encryption by default. To encrypt streaming connections, you first need to [enable TLS support](/web/server/README.md#enabling-tls-support) on the parent. With encryption enabled on the receiving side, you need to instruct the child to use TLS/SSL as well. On the child's `stream.conf`, configure the destination as follows:
244
+Netdata does not activate TLS encryption by default. To encrypt streaming connections:
245
+1. On the parent node (receiving node), [enable TLS support](/web/server/README.md#enabling-tls-support).
246
+2. On the child node (sending node), [enable TLS support](/web/server/README.md#enabling-tls-support).
247
+3. On the child's `stream.conf`, configure the destination as follows:
248
249
```
250
[stream]
331
| Yes|-/force/optional|Yes|no|The parent-child stream is encrypted, provided that the parent has a valid TLS/SSL certificate. Otherwise, the child refuses to connect.|
332
| Yes|-/force/optional|Yes|yes|The parent-child stream is encrypted.|
333
334
+### Streaming compression
335
+<a href="https://github.com/netdata/netdata/releases/latest"><img src="https://img.shields.io/badge/Supported%20Netdata%20Agent-v1.33%2B-brightgreen" alt="Supported version Netdata agent release"></a>
336
+
337
+<a href="https://github.com/netdata/netdata/releases/latest"><img src="https://img.shields.io/badge/Supported%20Netdata%20stream%20version-v5%2B-blue" alt="Supported version Netdata agent release"></a>
338
+
339
+#### OS dependencies
340
+* Streaming compression is based on [lz4 v1.9.0+](https://github.com/lz4/lz4). The [lz4 v1.9.0+](https://github.com/lz4/lz4) library must be installed in your OS in order to enable streaming compression. Any lower version will disable Netdata streaming compression for compatibility purposes between the older versions of Netdata agents.
341
+
342
+To check if your Netdata Agent supports stream compression run the following GET request in your browser or terminal:
343
+
344
+```
345
+curl -X GET http://localhost:19999/api/v1/info | grep 'Stream Compression'
346
+```
347
+
348
+**Output**
349
+```
350
+"buildinfo": "dbengine|Native HTTPS|Netdata Cloud|ACLK Next Generation|New Cloud Protocol Support|ACLK Legacy|TLS Host Verification|Machine Learning|Stream Compression|protobuf|JSON-C|libcrypto|libm|LWS v3.2.2|mosquitto|zlib|apps|cgroup Network Tracking|EBPF|perf|slabinfo",
351
+```
352
+> Note: If your OS doesn't support Netdata compression the `buildinfo` will not contain the `Stream Compression` statement.
353
+
354
+To check if your Netdata Agent has stream compression enabled, run the following GET request in your browser or terminal:
355
+
356
+```
357
+ curl -X GET http://localhost:19999/api/v1/info | grep 'stream-compression'
358
+```
359
+**Output**
360
+```
361
+"stream-compression": "enabled"
362
+```
363
+Note: The `stream-compression` status can be `"enabled" | "disabled" | "N/A"`.
364
+
365
+Stream data compression is enabled by default on systems where LZ4 library v1.9.0+ is installed. A compressed data packet is determined and decompressed on the fly.
366
+
367
+#### Limitations
368
+The current implementation of streaming data compression has the limitation that the size of single data block transmitted must not exceed 16384 bytes. If single data block size exceeds this limit, stream data compression should be disabled.
369
+
370
+#### How to enable stream compression
371
+Netdata Agents are shipped with data compression enabled by default. You can also configure which streams will use compression.
372
+
373
+With enabled stream compression, a Netdata Agent can negotiate streaming compression with other Netdata Agents. During the negotiation of streaming compression both Netdata Agents should support and enable compression in order to communicate over a compressed stream. The negotiation will result into an uncompressed stream, if one of the Netdata Agents doesn't support **or** has compression disabled.
374
+
375
+To enable stream compression:
376
+
377
+1. Edit `stream.conf` by using the `edit-config` script:
378
+`/etc/netdata/edit-config stream.conf`.
379
+
380
+2. In the `[stream]` section, set `enable compression` to `yes`.
381
+```
382
+# This is the default stream compression flag for an agent.
383
+
384
+[stream]
385
+ enable compression = yes | no
386
+```
387
+
388
+
389
+| Parent | Stream compression | Child |
390
+|----------------------|--------------------|----------------------|
391
+| Supported & Enabled | compressed | Supported & Enabled |
392
+| (Supported & Disabled)/Not supported | uncompressed | Supported & Enabled |
393
+| Supported & Enabled | uncompressed | (Supported & Disabled)/Not supported |
394
+| (Supported & Disabled)/Not supported | uncompressed | (Supported & Disabled)/Not supported |
395
+
396
+In case of parents with multiple children you can select which streams will be compressed by using the same configuration under the `[API_KEY]`, `[MACHINE_GUID]` section.
397
+
398
+This configuration uses AND logic with the default stream compression configuration under the `[stream]` section. This means the stream compression from child to parent will be enabled only if the outcome of the AND logic operation is true (`default compression enabled` && `api key compression enabled`). So both should be enabled to get stream compression otherwise stream compression is disabled.
399
+```
400
+[API_KEY]
401
+ enable compression = yes | no
402
+```
403
+Same thing applies with the `[MACHINE_GUID]` configuration.
404
+```
405
+[MACHINE_GUID]
406
+ enable compression = yes | no
407
+```
408
## Viewing remote host dashboards, using mirrored databases
409
410
On any receiving Netdata, that maintains remote databases and has its web server enabled,
474
475
#### Configuring the parent
476
388
-On the parent, edit `/etc/netdata/stream.conf` (to edit it on your system run `/etc/netdata/edit-config stream.conf`) and set these:
477
+To configure the parent node:
478
+
479
+1. On the parent node, edit `stream.conf` by using the `edit-config` script:
480
+`/etc/netdata/edit-config stream.conf`
481
+
482
+2. Set the following parameters:
483
484
```bash
485
[11111111-2222-3333-4444-555555555555]
508
509
#### Configuring the child nodes
510
417
-On each of the child nodes, edit `/etc/netdata/stream.conf` (to edit it on your system run `/etc/netdata/edit-config stream.conf`) and set these:
511
+To configure the child node:
512
+
513
+1. On the child node, edit `stream.conf` by using the `edit-config` script:
514
+`/etc/netdata/edit-config stream.conf`
515
+
516
+2. Set the following parameters:
517
518
```bash
519
[stream]
545
546
Keep in mind that setting `memory mode = none` will also force `[health].enabled = no` (health checks require access to a local database). But you can keep the database and disable health checks if you need to. You are however sending all the metrics to the parent node, which can handle the health checking (`[health].enabled = yes`)
547
449
-#### Netdata unique id
548
+#### Netdata unique ID
549
451
-The file `/var/lib/netdata/registry/netdata.public.unique.id` contains a random GUID that **uniquely identifies each Netdata**. This file is automatically generated, by Netdata, the first time it is started and remains unaltered forever.
550
+The file `/var/lib/netdata/registry/netdata.public.unique.id` contains a random GUID that **uniquely identifies each Netdata Agent**. This file is automatically generated, by Netdata, the first time it is started and remains unaltered forever.
551
552
> If you are building an image to be used for automated provisioning of autoscaled VMs, it important to delete that file from the image, so that each instance of your image will generate its own.
553
555
556
Both parent and child nodes log information at `/var/log/netdata/error.log`.
557
459
-Run the following on both the parent and child nodes:
558
+To obtain the error logs, run the following on both the parent and child nodes:
559
560
```
561
tail -f /var/log/netdata/error.log | grep STREAM
610
611
## Proxies
612
514
-A proxy is a Netdata instance that is receiving metrics from a Netdata, and streams them to another Netdata.
613
+A proxy is a Netdata node that is receiving metrics from a Netdata node, and streams them to another Netdata node.
614
615
Netdata proxies may or may not maintain a database for the metrics passing through them.
616
When they maintain a database, they can also run health checks (alarms and notifications)
670
ERROR : STREAM_SENDER[HOSTNAME] : Failed to connect to 'PARENT IP', port 'PARENT PORT' (errno 113, No route to host)
671
```
672
574
-### 'Is this a Netdata?'
673
+### 'Is this a Netdata node?'
674
675
This question can appear when Netdata starts the stream and receives an unexpected response. This error can appear when
676
the parent is using SSL and the child tries to connect using plain text. You will also see this message when
578
-Netdata connects to another server that isn't Netdata. The complete error message will look like this:
677
+Netdata connects to another server that isn't a Netdata node. The complete error message will look like this:
678
679
```
680
ERROR : STREAM_SENDER[CHILD HOSTNAME] : STREAM child HOSTNAME [send to PARENT HOSTNAME:PARENT PORT]: server is not replying properly (is it a netdata?).