37 host text not null, |
36 host text not null, |
38 metrics jsonb default '{}'::jsonb not null |
37 metrics jsonb default '{}'::jsonb not null |
39 ); |
38 ); |
40 ``` |
39 ``` |
41 |
40 |
42 Index it however you please based on how you intend to query the data, |
41 Index it based on how you intend to query the data, including JSON |
43 including JSON functional indexing, etc. See PostgreSQL documentation |
42 functional indexing, etc. See PostgreSQL documentation for details. |
44 for details. |
|
45 |
43 |
46 Strongly encouraged: Promote this table to a Timescale "hypertable". |
44 Strongly encouraged: Promote this table to a Timescale "hypertable". |
47 See Timescale docs for that, but a quick example to partition |
45 See [Timescale](http://timescale.com) docs for that, but a quick example |
48 automatically at weekly boundaries would look something like: |
46 to partition automatically at weekly boundaries would look something |
|
47 like: |
49 |
48 |
50 ```sql |
49 ```sql |
51 SELECT create_hypertable( 'netdata', 'time', chunk_time_interval => 604800000000 ); |
50 SELECT create_hypertable( 'netdata', 'time', chunk_time_interval => 604800000000 ); |
52 ``` |
51 ``` |
53 |
52 |
|
53 Timescale also has some great examples and advice for efficient [JSON |
|
54 indexing](http://docs.timescale.com/v0.8/using-timescaledb/schema-management#json) |
|
55 and queries. |
54 |
56 |
55 |
57 |
56 ### Netdata |
58 ### Netdata |
57 |
59 |
58 You'll likely want to pare down what netdata is sending. Here's an |
60 You'll likely want to pare down what netdata is sending. Here's an |
59 example configuration for `netdata.conf` -- you will want to season |
61 example configuration for `netdata.conf` -- season this to taste (what |
60 this to taste. |
62 charts to send and frequency.) |
61 |
63 |
62 ``` |
64 ``` |
63 [backend] |
65 [backend] |
64 hostname = your-hostname |
66 hostname = your-hostname |
65 enabled = yes |
67 enabled = yes |
66 type = json |
68 type = json |
67 data source = average |
69 data source = average |
68 destination = machine-where-netdata-tsrelay-lives:14866 |
70 destination = machine-where-netdata-tsrelay-lives:14866 |
69 prefix = n |
71 prefix = n |
70 update every = 10 |
72 update every = 60 |
71 buffer on failures = 6 |
73 buffer on failures = 5 |
72 send charts matching = !cpu.cpu* !ipv6* !users* nfs.rpc net.* net_drops.* net_packets.* !system.interrupts* system.* disk.* disk_space.* disk_ops.* mem.* |
74 send charts matching = !cpu.cpu* !ipv6* !users* nfs.rpc net.* net_drops.* net_packets.* !system.interrupts* system.* disk.* disk_space.* disk_ops.* mem.* |
73 ``` |
75 ``` |
74 |
76 |
|
77 |
|
78 Running the Relay |
|
79 ----------------- |
|
80 |
|
81 ### Options |
|
82 |
|
83 * [-q|--quiet]: Quiet mode. No output at all. Ignored if -d is supplied. |
|
84 * [-d|--debug]: Debug mode. Show incoming data. |
|
85 * [--dbopts]: PostgreSQL connection information. (See below for more details.) |
|
86 * [-h|--help]: Display quick help text. |
|
87 * [--listen-addr]: A specific IP address to listen on. Defaults to INADDR_ANY. |
|
88 * [--listen-port]: The port to listen for netdata JSON streams. |
|
89 Default is 14866. |
|
90 * [-T|--dbtable]: Change the table name to insert to. Defaults to **netdata**. |
|
91 * [-t|--timeout]: Maximum time in milliseconds to wait for data. Slow |
|
92 connections may need to increase this from the default 500 ms. |
|
93 * [-v|--version]: Show version. |
|
94 |
|
95 |
|
96 **Notes** |
|
97 |
|
98 Nim option parsing might be slightly different than what you're used to. |
|
99 Flags that require arguments must include an '=' or ':' character. |
|
100 |
|
101 * --timeout=1000 *valid* |
|
102 * --timeout:1000 *valid* |
|
103 * --t:1000 *valid* |
|
104 * --timeout 1000 *invalid* |
|
105 * -t 1000 *invalid* |
|
106 |
|
107 All database connection options are passed as a key/val string to the |
|
108 *dbopts* flag. The default is: |
|
109 |
|
110 "host=localhost port=5432 dbname=netdata user=netdata application_name=netdata-tsrelay" |
|
111 |
|
112 Reference |
|
113 https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ- |
|
114 PARAMKEYWORDS for all available options (including how to store |
|
115 passwords in a seperate file, enable SSL mode, etc.) |
|
116 |
|
117 |
|
118 ### Daemonizing |
|
119 |
|
120 Use a tool of your choice to run this at system |
|
121 startup in the background. My personal preference is |
|
122 [daemontools](https://cr.yp.to/daemontools.html), but I won't judge you |
|
123 if you use something else. |
|
124 |
|
125 Here's an example using the simple |
|
126 [daemon](https://www.freebsd.org/cgi/man.cgi?query=daemon&apropos=0&sektion=8&manpath=FreeBSD+11.0-RELEASE+and+Ports&arch=default&format=html) wrapper tool: |
|
127 |
|
128 # daemon \ |
|
129 -o /var/log/netdata_tsrelay.log \ |
|
130 -p /var/run/netdata_tsrelay.pid \ |
|
131 -u nobody -cr \ |
|
132 /usr/local/bin/netdata_tsrelay \ |
|
133 --dbopts="dbname=metrics user=metrics host=db-master port=6432 application_name=netdata-tsrelay" |
|
134 |