Pass cloud_base_url from daemon to web/gui through hello endpoint #4980 (#4982)
* Pass cloud_base_url from daemon to web/gui through hello endpoint #4980 * Make sure the [cloud] section goes into the general part of netdata.conf #4980
George Moschovitis committed
Dec 13, 2018 at 15:30 UTC
6b05a213029d0097a98e26b6c2aa4ff635f37182
7 files changed
+12
-2
libnetdata/config/appconfig.c
+1
@@ -538,6 +538,7 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed)
538
|| !strcmp(co->name, CONFIG_SECTION_WEB)
539
|| !strcmp(co->name, CONFIG_SECTION_STATSD)
540
|| !strcmp(co->name, CONFIG_SECTION_PLUGINS)
541
+ || !strcmp(co->name, CONFIG_SECTION_CLOUD)
542
|| !strcmp(co->name, CONFIG_SECTION_REGISTRY)
543
|| !strcmp(co->name, CONFIG_SECTION_HEALTH)
544
|| !strcmp(co->name, CONFIG_SECTION_BACKEND)
libnetdata/config/appconfig.h
+1
@@ -86,6 +86,7 @@
86
#define CONFIG_SECTION_WEB "web"
87
#define CONFIG_SECTION_STATSD "statsd"
88
#define CONFIG_SECTION_PLUGINS "plugins"
89
+#define CONFIG_SECTION_CLOUD "cloud"
90
#define CONFIG_SECTION_REGISTRY "registry"
91
#define CONFIG_SECTION_HEALTH "health"
92
#define CONFIG_SECTION_BACKEND "backend"
registry/registry.c
+4
-2
@@ -131,8 +131,10 @@ static inline int registry_person_url_callback_verify_machine_exists(void *entry
131
int registry_request_hello_json(RRDHOST *host, struct web_client *w) {
132
registry_json_header(host, w, "hello", REGISTRY_STATUS_OK);
133
134
- buffer_sprintf(w->response.data, ",\n\t\"registry\": \"%s\"",
135
- registry.registry_to_announce);
134
+ buffer_sprintf(w->response.data,
135
+ ",\n\t\"registry\": \"%s\",\n\t\"cloud_base_url\": \"%s\"",
136
+ registry.registry_to_announce,
137
+ registry.cloud_base_url);
138
139
registry_json_footer(w);
140
return 200;
registry/registry_init.c
+1
@@ -37,6 +37,7 @@ int registry_init(void) {
37
registry.persons_expiration = config_get_number(CONFIG_SECTION_REGISTRY, "registry expire idle persons days", 365) * 86400;
38
registry.registry_domain = config_get(CONFIG_SECTION_REGISTRY, "registry domain", "");
39
registry.registry_to_announce = config_get(CONFIG_SECTION_REGISTRY, "registry to announce", "https://registry.my-netdata.io");
40
+ registry.cloud_base_url = config_get(CONFIG_SECTION_CLOUD, "cloud base url", "https://netdata.cloud");
41
registry.hostname = config_get(CONFIG_SECTION_REGISTRY, "registry hostname", netdata_configured_hostname);
42
registry.verify_cookies_redirects = config_get_boolean(CONFIG_SECTION_REGISTRY, "verify browser cookies support", 1);
43
registry/registry_internals.h
+1
@@ -37,6 +37,7 @@ struct registry {
37
char *registry_domain;
38
char *hostname;
39
char *registry_to_announce;
40
+ char *cloud_base_url;
41
time_t persons_expiration; // seconds to expire idle persons
42
int verify_cookies_redirects;
43
web/gui/dashboard.js
+2
@@ -9677,6 +9677,7 @@ NETDATA.alarms = {
9677
9678
NETDATA.registry = {
9679
server: null, // the netdata registry server
9680
+ cloudBaseURL: null, // the netdata cloud base url
9681
person_guid: null, // the unique ID of this browser / user
9682
machine_guid: null, // the unique ID the netdata server that served dashboard.js
9683
hostname: 'unknown', // the hostname of the netdata server that served dashboard.js
@@ -9738,6 +9739,7 @@ NETDATA.registry = {
9739
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
9740
if (data) {
9741
NETDATA.registry.server = data.registry;
9742
+ NETDATA.registry.cloudBaseURL = data.cloud_base_url;
9743
NETDATA.registry.machine_guid = data.machine_guid;
9744
NETDATA.registry.hostname = data.hostname;
9745
web/gui/src/dashboard.js/registry.js
+2
@@ -3,6 +3,7 @@
3
4
NETDATA.registry = {
5
server: null, // the netdata registry server
6
+ cloudBaseURL: null, // the netdata cloud base url
7
person_guid: null, // the unique ID of this browser / user
8
machine_guid: null, // the unique ID the netdata server that served dashboard.js
9
hostname: 'unknown', // the hostname of the netdata server that served dashboard.js
@@ -64,6 +65,7 @@ NETDATA.registry = {
65
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
66
if (data) {
67
NETDATA.registry.server = data.registry;
68
+ NETDATA.registry.cloudBaseURL = data.cloud_base_url;
69
NETDATA.registry.machine_guid = data.machine_guid;
70
NETDATA.registry.hostname = data.hostname;
71