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
This commit is contained in:
George Moschovitis 2018-12-13 15:30:21 +02:00 committed by GitHub
parent a1690b4978
commit 6b05a21302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 2 deletions

View File

@ -538,6 +538,7 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed)
|| !strcmp(co->name, CONFIG_SECTION_WEB)
|| !strcmp(co->name, CONFIG_SECTION_STATSD)
|| !strcmp(co->name, CONFIG_SECTION_PLUGINS)
|| !strcmp(co->name, CONFIG_SECTION_CLOUD)
|| !strcmp(co->name, CONFIG_SECTION_REGISTRY)
|| !strcmp(co->name, CONFIG_SECTION_HEALTH)
|| !strcmp(co->name, CONFIG_SECTION_BACKEND)

View File

@ -86,6 +86,7 @@
#define CONFIG_SECTION_WEB "web"
#define CONFIG_SECTION_STATSD "statsd"
#define CONFIG_SECTION_PLUGINS "plugins"
#define CONFIG_SECTION_CLOUD "cloud"
#define CONFIG_SECTION_REGISTRY "registry"
#define CONFIG_SECTION_HEALTH "health"
#define CONFIG_SECTION_BACKEND "backend"

View File

@ -131,8 +131,10 @@ static inline int registry_person_url_callback_verify_machine_exists(void *entry
int registry_request_hello_json(RRDHOST *host, struct web_client *w) {
registry_json_header(host, w, "hello", REGISTRY_STATUS_OK);
buffer_sprintf(w->response.data, ",\n\t\"registry\": \"%s\"",
registry.registry_to_announce);
buffer_sprintf(w->response.data,
",\n\t\"registry\": \"%s\",\n\t\"cloud_base_url\": \"%s\"",
registry.registry_to_announce,
registry.cloud_base_url);
registry_json_footer(w);
return 200;

View File

@ -37,6 +37,7 @@ int registry_init(void) {
registry.persons_expiration = config_get_number(CONFIG_SECTION_REGISTRY, "registry expire idle persons days", 365) * 86400;
registry.registry_domain = config_get(CONFIG_SECTION_REGISTRY, "registry domain", "");
registry.registry_to_announce = config_get(CONFIG_SECTION_REGISTRY, "registry to announce", "https://registry.my-netdata.io");
registry.cloud_base_url = config_get(CONFIG_SECTION_CLOUD, "cloud base url", "https://netdata.cloud");
registry.hostname = config_get(CONFIG_SECTION_REGISTRY, "registry hostname", netdata_configured_hostname);
registry.verify_cookies_redirects = config_get_boolean(CONFIG_SECTION_REGISTRY, "verify browser cookies support", 1);

View File

@ -37,6 +37,7 @@ struct registry {
char *registry_domain;
char *hostname;
char *registry_to_announce;
char *cloud_base_url;
time_t persons_expiration; // seconds to expire idle persons
int verify_cookies_redirects;

View File

@ -9677,6 +9677,7 @@ NETDATA.alarms = {
NETDATA.registry = {
server: null, // the netdata registry server
cloudBaseURL: null, // the netdata cloud base url
person_guid: null, // the unique ID of this browser / user
machine_guid: null, // the unique ID the netdata server that served dashboard.js
hostname: 'unknown', // the hostname of the netdata server that served dashboard.js
@ -9738,6 +9739,7 @@ NETDATA.registry = {
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
if (data) {
NETDATA.registry.server = data.registry;
NETDATA.registry.cloudBaseURL = data.cloud_base_url;
NETDATA.registry.machine_guid = data.machine_guid;
NETDATA.registry.hostname = data.hostname;

View File

@ -3,6 +3,7 @@
NETDATA.registry = {
server: null, // the netdata registry server
cloudBaseURL: null, // the netdata cloud base url
person_guid: null, // the unique ID of this browser / user
machine_guid: null, // the unique ID the netdata server that served dashboard.js
hostname: 'unknown', // the hostname of the netdata server that served dashboard.js
@ -64,6 +65,7 @@ NETDATA.registry = {
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
if (data) {
NETDATA.registry.server = data.registry;
NETDATA.registry.cloudBaseURL = data.cloud_base_url;
NETDATA.registry.machine_guid = data.machine_guid;
NETDATA.registry.hostname = data.hostname;