| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_JSON_KEYS_H |
| 4 | #define NETDATA_JSON_KEYS_H |
| 5 | |
| 6 | #include "../libnetdata.h" |
| 7 | |
| 8 | // JSON key names struct for short vs long key support |
| 9 | typedef struct json_key_names { |
| 10 | // Status and statistics |
| 11 | const char *selected; // "sl" / "selected" |
| 12 | const char *excluded; // "ex" / "excluded" |
| 13 | const char *queried; // "qr" / "queried" |
| 14 | const char *failed; // "fl" / "failed" |
| 15 | |
| 16 | // Object types |
| 17 | const char *dimensions; // "ds" / "dimensions" |
| 18 | const char *instances; // "is" / "instances" |
| 19 | const char *contexts; // "ctx" / "contexts" |
| 20 | const char *alerts; // "al" / "alerts" |
| 21 | const char *statistics; // "sts" / "statistics" |
| 22 | |
| 23 | const char *node_id; // "nd" / "node_id" |
| 24 | const char *machine_guid; // "mg" / "machine_guid" |
| 25 | |
| 26 | // metadata by name |
| 27 | const char *name; // "nm" / "name" |
| 28 | const char *hostname; // "nm" / "hostname" |
| 29 | const char *alert_name; // "nm" / "alert_name" |
| 30 | const char *context; // "ctx" / "context" |
| 31 | const char *instance_id; // "ch" / "instance_id" |
| 32 | const char *instance_name; // "ch_n" / "instance" |
| 33 | const char *family; // "fami" / "family" |
| 34 | |
| 35 | // Values |
| 36 | const char *value; // "vl" / "value" |
| 37 | const char *label_values; // "vl" / "label_values" |
| 38 | |
| 39 | // Alert levels |
| 40 | const char *clear; // "cl" / "clear" |
| 41 | const char *warning; // "wr" / "warning" |
| 42 | const char *critical; // "cr" / "critical" |
| 43 | const char *error; // "er" / "error" |
| 44 | const char *other; // "ot" / "other" |
| 45 | |
| 46 | // Storage Points |
| 47 | const char *count; // "cnt" / "count" |
| 48 | const char *volume; // "vol" / "volume" |
| 49 | const char *anomaly_rate; // "arp" / "anomaly_rate_percent" |
| 50 | const char *anomaly_count; // "arc" / "anomalous_points_count" |
| 51 | const char *contribution; // "con" / "contribution_percent" |
| 52 | const char *point_annotations; // "pa" / "point_annotations_bitmap" |
| 53 | const char *point_schema; // "point" / "point_schema" |
| 54 | |
| 55 | // Other fields |
| 56 | const char *priority; // "pri" / "priority" |
| 57 | const char *update_every; // "ue" / "update_every" |
| 58 | const char *tier; // "tr" / "tier" |
| 59 | const char *after; // "af" / "after" |
| 60 | const char *before; // "bf" / "before" |
| 61 | const char *status; // "st" / "status" |
| 62 | const char *first_entry; // "fe" / "first_entry" |
| 63 | const char *last_entry; // "le" / "last_entry" |
| 64 | const char *units; // "un" / "units" |
| 65 | const char *weight; // "wg" / "weight" |
| 66 | |
| 67 | // indexes |
| 68 | const char *agent_index; // "ai" / "agents_array_index" |
| 69 | const char *node_index; // "ni" / "nodes_array_index" |
| 70 | const char *alerts_index_id; // "ati" / "alerts_array_index_id" |
| 71 | |
| 72 | // alerts fields |
| 73 | const char *summary; // "sum" / "summary" |
| 74 | const char *nodes_count; // "nd" / "nodes_count" |
| 75 | const char *instances_count; // "in" / "instances_count" |
| 76 | const char *configurations_count; // "cfg" / "configurations_count" |
| 77 | |
| 78 | const char *alert_global_id; // "gi" / "global_id" |
| 79 | const char *last_transition_id; // "tr_i" / "last_transition_id" |
| 80 | const char *last_transition_value; // "tr_v" / "last_transition_value" |
| 81 | const char *last_transition_timestamp; // "tr_t" / "last_transition_timestamp" |
| 82 | const char *last_updated_value; // "v" / "last_updated_value" |
| 83 | const char *last_updated_timestamp; // "t" / "last_updated_timestamp" |
| 84 | |
| 85 | const char *classification; // "cl" / "classification" |
| 86 | const char *classifications; // "cls" / "classifications" |
| 87 | const char *component; // "cm" / "component" |
| 88 | const char *components; // "cp" / "components" |
| 89 | const char *type; // "tp" / "type" |
| 90 | const char *types; // "ty" / "types" |
| 91 | const char *recipients; // "to" / "recipients" |
| 92 | |
| 93 | const char *source; // "src" / "source" |
| 94 | const char *config_hash_id; // "cfg" / "configuration_hash" |
| 95 | } JSON_KEY_NAMES; |
| 96 | |
| 97 | // Options type for controlling key format |
| 98 | typedef enum { |
| 99 | JSON_KEYS_OPTION_LONG_KEYS = (1 << 0), |
| 100 | } JSON_KEYS_OPTIONS; |
| 101 | |
| 102 | // Thread-local pointer to the current key names |
| 103 | extern __thread const JSON_KEY_NAMES *json_keys; |
| 104 | |
| 105 | // Macro for clean key access |
| 106 | #define JSKEY(member) (json_keys->member) |
| 107 | |
| 108 | // Key name initialization |
| 109 | void json_keys_init(JSON_KEYS_OPTIONS options); |
| 110 | void json_keys_reset(void); |
| 111 | |
| 112 | // Check if long keys are enabled |
| 113 | bool json_keys_are_long(void); |
| 114 | |
| 115 | #endif //NETDATA_JSON_KEYS_H |