@cryptotaxi247 / netdata-1 / commits / 8958da110

Store hidden status when creating / updating dimension metadata (#13869)

Stelios Fragkakis committed Oct 25, 2022 at 01:17 UTC 8958da110e5aad5e518770fceb6e56f2d6ade450
1 file changed +14 -5
database/sqlite/sqlite_metadata.c
+14 -5
@@ -34,8 +34,8 @@ extern DICTIONARY *rrdhost_root_index;
34 "name, family, context, title, unit, plugin, module, priority, update_every , chart_type , memory_mode , " \
35 "history_entries) values (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16);"
36
37 -#define SQL_STORE_DIMENSION "INSERT OR REPLACE INTO dimension (dim_id, chart_id, id, name, multiplier, divisor , algorithm) " \
38 - "VALUES (@dim_id, @chart_id, @id, @name, @multiplier, @divisor, @algorithm);"
37 +#define SQL_STORE_DIMENSION "INSERT OR REPLACE INTO dimension (dim_id, chart_id, id, name, multiplier, divisor , algorithm, options) " \
38 + "VALUES (@dim_id, @chart_id, @id, @name, @multiplier, @divisor, @algorithm, @options);"
39
40 #define SELECT_DIMENSION_LIST "SELECT dim_id, rowid FROM dimension WHERE rowid > @row_id"
41
@@ -595,7 +595,7 @@ bind_fail:
595 */
596 static int sql_store_dimension(
597 uuid_t *dim_uuid, uuid_t *chart_uuid, const char *id, const char *name, collected_number multiplier,
598 - collected_number divisor, int algorithm)
598 + collected_number divisor, int algorithm, bool hidden)
599 {
600 static __thread sqlite3_stmt *res = NULL;
601 int rc, param = 0;
@@ -643,6 +643,13 @@ static int sql_store_dimension(
643 if (unlikely(rc != SQLITE_OK))
644 goto bind_fail;
645
646 + if (hidden)
647 + rc = sqlite3_bind_text(res, ++param, "hidden", -1, SQLITE_STATIC);
648 + else
649 + rc = sqlite3_bind_null(res, ++param);
650 + if (unlikely(rc != SQLITE_OK))
651 + goto bind_fail;
652 +
653 rc = execute_insert(res);
654 if (unlikely(rc != SQLITE_DONE))
655 error_report("Failed to store dimension, rc = %d", rc);
@@ -967,7 +974,8 @@ static bool metadata_scan_host(RRDHOST *host, uint32_t max_count) {
974 string2str(rd->name),
975 rd->multiplier,
976 rd->divisor,
970 - rd->algorithm);
977 + rd->algorithm,
978 + rrddim_option_check(rd, RRDDIM_OPTION_HIDDEN));
979
980 if (unlikely(rc))
981 error_report("METADATA: Failed to store dimension %s", string2str(rd->id));
@@ -1165,7 +1173,8 @@ static void metadata_event_loop(void *arg)
1173 string2str(rd->name),
1174 rd->multiplier,
1175 rd->divisor,
1168 - rd->algorithm);
1176 + rd->algorithm,
1177 + rrddim_option_check(rd, RRDDIM_OPTION_HIDDEN));
1178
1179 if (unlikely(rc))
1180 error_report("Failed to store dimension %s", rrddim_id(rd));