summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2022-04-06 13:42:41 +0300
committerGitHub <noreply@github.com>2022-04-06 13:42:41 +0300
commitc98fcf5754f5cce226f8401b6a1e007703af9b20 (patch)
treec6e6b7fa5c09f0f5015789ae87e25e0e87e08c4c /database
parent989121a5a4428e9088d4119b27c1172c9a14a4da (diff)
feat: add support for cloud providers info to /api/v1/info (#12613)
Diffstat (limited to 'database')
-rw-r--r--database/rrd.h4
-rw-r--r--database/rrdhost.c27
2 files changed, 31 insertions, 0 deletions
diff --git a/database/rrd.h b/database/rrd.h
index afaf59245c..a305d8b4d3 100644
--- a/database/rrd.h
+++ b/database/rrd.h
@@ -732,6 +732,10 @@ typedef struct alarm_log {
// RRD HOST
struct rrdhost_system_info {
+ char *cloud_provider_type;
+ char *cloud_instance_type;
+ char *cloud_instance_region;
+
char *host_os_name;
char *host_os_id;
char *host_os_id_like;
diff --git a/database/rrdhost.c b/database/rrdhost.c
index 4bfb9519d8..df917971f5 100644
--- a/database/rrdhost.c
+++ b/database/rrdhost.c
@@ -806,6 +806,9 @@ void rrdhost_system_info_free(struct rrdhost_system_info *system_info) {
info("SYSTEM_INFO: free %p", system_info);
if(likely(system_info)) {
+ freez(system_info->cloud_provider_type);
+ freez(system_info->cloud_instance_type);
+ freez(system_info->cloud_instance_region);
freez(system_info->host_os_name);
freez(system_info->host_os_id);
freez(system_info->host_os_id_like);
@@ -1034,6 +1037,18 @@ static struct label *rrdhost_load_auto_labels(void)
{
struct label *label_list = NULL;
+ if (localhost->system_info->cloud_provider_type)
+ label_list =
+ add_label_to_list(label_list, "_cloud_provider_type", localhost->system_info->cloud_provider_type, LABEL_SOURCE_AUTO);
+
+ if (localhost->system_info->cloud_instance_type)
+ label_list =
+ add_label_to_list(label_list, "_cloud_instance_type", localhost->system_info->cloud_instance_type, LABEL_SOURCE_AUTO);
+
+ if (localhost->system_info->cloud_instance_region)
+ label_list =
+ add_label_to_list(label_list, "_cloud_instance_region", localhost->system_info->cloud_instance_region, LABEL_SOURCE_AUTO);
+
if (localhost->system_info->host_os_name)
label_list =
add_label_to_list(label_list, "_os_name", localhost->system_info->host_os_name, LABEL_SOURCE_AUTO);
@@ -1543,6 +1558,18 @@ int rrdhost_set_system_info_variable(struct rrdhost_system_info *system_info, ch
if (!strcmp(name, "NETDATA_PROTOCOL_VERSION"))
return res;
+ else if(!strcmp(name, "NETDATA_INSTANCE_CLOUD_TYPE")){
+ freez(system_info->cloud_provider_type);
+ system_info->cloud_provider_type = strdupz(value);
+ }
+ else if(!strcmp(name, "NETDATA_INSTANCE_CLOUD_INSTANCE_TYPE")){
+ freez(system_info->cloud_instance_type);
+ system_info->cloud_instance_type = strdupz(value);
+ }
+ else if(!strcmp(name, "NETDATA_INSTANCE_CLOUD_INSTANCE_REGION")){
+ freez(system_info->cloud_instance_region);
+ system_info->cloud_instance_region = strdupz(value);
+ }
else if(!strcmp(name, "NETDATA_CONTAINER_OS_NAME")){
freez(system_info->container_os_name);
system_info->container_os_name = strdupz(value);