enable-streaming.mdx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. ---
  2. title: "Enable streaming between nodes"
  3. description: >-
  4. "With metrics streaming enabled, you can not only replicate metrics data
  5. into a second database, but also view dashboards and trigger alarm notifications
  6. for multiple nodes in parallel."
  7. type: "how-to"
  8. custom_edit_url: "https://github.com/netdata/netdata/blob/master/docs/metrics-storage-management/enable-streaming.mdx"
  9. sidebar_label: "Enable streaming between nodes"
  10. learn_status: "Published"
  11. learn_topic_type: "Tasks"
  12. learn_rel_path: "Setup"
  13. ---
  14. # Enable streaming between nodes
  15. The simplest streaming configuration is **replication**, in which a child node streams its metrics in real time to a
  16. parent node, and both nodes retain metrics in their own databases.
  17. To configure replication, you need two nodes, each running Netdata. First you'll first enable streaming on your parent
  18. node, then enable streaming on your child node. When you're finished, you'll be able to see the child node's metrics in
  19. the parent node's dashboard, quickly switch between the two dashboards, and be able to serve [alarm
  20. notifications](https://github.com/netdata/netdata/blob/master/docs/monitor/enable-notifications.md) from either or both nodes.
  21. ## Enable streaming on the parent node
  22. First, log onto the node that will act as the parent.
  23. Run `uuidgen` to create a new API key, which is a randomly-generated machine GUID the Netdata Agent uses to identify
  24. itself while initiating a streaming connection. Copy that into a separate text file for later use.
  25. > Find out how to [install `uuidgen`](https://command-not-found.com/uuidgen) on your node if you don't already have it.
  26. Next, open `stream.conf` using [`edit-config`](https://github.com/netdata/netdata/blob/master/docs/configure/nodes.md#use-edit-config-to-edit-configuration-files)
  27. from within the [Netdata config directory](https://github.com/netdata/netdata/blob/master/docs/configure/nodes.md#the-netdata-config-directory).
  28. ```bash
  29. cd /etc/netdata
  30. sudo ./edit-config stream.conf
  31. ```
  32. Scroll down to the section beginning with `[API_KEY]`. Paste the API key you generated earlier between the brackets, so
  33. that it looks like the following:
  34. ```conf
  35. [11111111-2222-3333-4444-555555555555]
  36. ```
  37. Set `enabled` to `yes`, and `default memory mode` to `dbengine`. Leave all the other settings as their defaults. A
  38. simplified version of the configuration, minus the commented lines, looks like the following:
  39. ```conf
  40. [11111111-2222-3333-4444-555555555555]
  41. enabled = yes
  42. default memory mode = dbengine
  43. ```
  44. Save the file and close it, then restart Netdata with `sudo systemctl restart netdata`, or the [appropriate
  45. method](https://github.com/netdata/netdata/blob/master/docs/configure/start-stop-restart.md) for your system.
  46. ## Enable streaming on the child node
  47. Connect to your child node with SSH.
  48. Open `stream.conf` again. Scroll down to the `[stream]` section and set `enabled` to `yes`. Paste the IP address of your
  49. parent node at the end of the `destination` line, and paste the API key generated on the parent node onto the `api key`
  50. line.
  51. Leave all the other settings as their defaults. A simplified version of the configuration, minus the commented lines,
  52. looks like the following:
  53. ```conf
  54. [stream]
  55. enabled = yes
  56. destination = 203.0.113.0
  57. api key = 11111111-2222-3333-4444-555555555555
  58. ```
  59. Save the file and close it, then restart Netdata with `sudo systemctl restart netdata`, or the [appropriate
  60. method](https://github.com/netdata/netdata/blob/master/docs/configure/start-stop-restart.md) for your system.
  61. ## Enable TLS/SSL on streaming (optional)
  62. While encrypting the connection between your parent and child nodes is recommended for security, it's not required to
  63. get started. If you're not interested in encryption, skip ahead to [view streamed
  64. metrics](#view-streamed-metrics-in-netdatas-dashboard).
  65. In this example, we'll use self-signed certificates.
  66. On the **parent** node, use OpenSSL to create the key and certificate, then use `chown` to make the new files readable
  67. by the `netdata` user.
  68. ```bash
  69. sudo openssl req -newkey rsa:2048 -nodes -sha512 -x509 -days 365 -keyout /etc/netdata/ssl/key.pem -out /etc/netdata/ssl/cert.pem
  70. sudo chown netdata:netdata /etc/netdata/ssl/cert.pem /etc/netdata/ssl/key.pem
  71. ```
  72. Next, enforce TLS/SSL on the web server. Open `netdata.conf`, scroll down to the `[web]` section, and look for the `bind
  73. to` setting. Add `^SSL=force` to turn on TLS/SSL. See the [web server
  74. reference](https://github.com/netdata/netdata/blob/master/web/server/README.md#enabling-tls-support) for other TLS/SSL options.
  75. ```conf
  76. [web]
  77. bind to = *=dashboard|registry|badges|management|streaming|netdata.conf^SSL=force
  78. ```
  79. Next, connect to the **child** node and open `stream.conf`. Add `:SSL` to the end of the existing `destination` setting
  80. to connect to the parent using TLS/SSL. Uncomment the `ssl skip certificate verification` line to allow the use of
  81. self-signed certificates.
  82. ```conf
  83. [stream]
  84. enabled = yes
  85. destination = 203.0.113.0:SSL
  86. ssl skip certificate verification = yes
  87. api key = 11111111-2222-3333-4444-555555555555
  88. ```
  89. Restart both the parent and child nodes with `sudo systemctl restart netdata`, or the [appropriate
  90. method](https://github.com/netdata/netdata/blob/master/docs/configure/start-stop-restart.md) for your system, to stream encrypted metrics using TLS/SSL.
  91. ## View streamed metrics in Netdata's dashboard
  92. At this point, the child node is streaming its metrics in real time to its parent. Open the local Agent dashboard for
  93. the parent by navigating to `http://PARENT-NODE:19999` in your browser, replacing `PARENT-NODE` with its IP address or
  94. hostname.
  95. This dashboard shows parent metrics. To see child metrics, open the left-hand sidebar with the hamburger icon
  96. ![Hamburger icon](https://raw.githubusercontent.com/netdata/netdata-ui/master/src/components/icon/assets/hamburger.svg)
  97. in the top panel. Both nodes appear under the **Replicated Nodes** menu. Click on either of the links to switch between
  98. separate parent and child dashboards.
  99. ![Switching between parent and child
  100. dashboards](https://user-images.githubusercontent.com/1153921/110043346-761ec000-7d04-11eb-8e58-77670ba39161.gif)
  101. The child dashboard is also available directly at `http://PARENT-NODE:19999/host/CHILD-HOSTNAME`, which in this example
  102. is `http://203.0.113.0:19999/host/netdata-child`.
  103. ## What's next?
  104. Now that you have a basic streaming setup with replication, you may want to tweak the configuration to eliminate the
  105. child database, disable the child dashboard, or enable SSL on the streaming connection between the parent and child.
  106. See the [streaming reference
  107. doc](https://github.com/netdata/netdata/blob/master/docs/metrics-storage-management/reference-streaming.mdx#examples) for details about
  108. other possible configurations.
  109. When using Netdata's default TSDB (`dbengine`), the parent node maintains separate, parallel databases for itself and
  110. every child node streaming to it. Each instance is sized identically based on the `dbengine multihost disk space`
  111. setting in `netdata.conf`. See our doc on [changing metrics retention](https://github.com/netdata/netdata/blob/master/docs/store/change-metrics-storage.md) for
  112. details.
  113. ### Related information & further reading
  114. - Streaming
  115. - [How Netdata streams metrics](https://github.com/netdata/netdata/blob/master/docs/metrics-storage-management/how-streaming-works.mdx)
  116. - **[Enable streaming between nodes](https://github.com/netdata/netdata/blob/master/docs/metrics-storage-management/enable-streaming.mdx)**
  117. - [Streaming reference](https://github.com/netdata/netdata/blob/master/docs/metrics-storage-management/reference-streaming.mdx)