master
h 99 lines 4.36 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_FUNCTIONS_FIELDS_H
4 #define NETDATA_FUNCTIONS_FIELDS_H 1
5
6 #include "../libnetdata.h"
7 #include "buffer.h"
8 #include "../template-enum.h"
9
10 typedef enum __attribute__((packed)) {
11 RRDF_FIELD_OPTS_NONE = 0,
12 RRDF_FIELD_OPTS_UNIQUE_KEY = (1 << 0), // the field is the unique key of the row
13 RRDF_FIELD_OPTS_VISIBLE = (1 << 1), // the field should be visible by default
14 RRDF_FIELD_OPTS_STICKY = (1 << 2), // the field should be sticky
15 RRDF_FIELD_OPTS_FULL_WIDTH = (1 << 3), // the field should get full width
16 RRDF_FIELD_OPTS_WRAP = (1 << 4), // the field should wrap
17 RRDF_FIELD_OPTS_DUMMY = (1 << 5), // not a presentable field
18 RRDF_FIELD_OPTS_EXPANDED_FILTER = (1 << 6), // show the filter expanded
19 } RRDF_FIELD_OPTIONS;
20
21 typedef enum __attribute__((packed)) {
22 RRDF_FIELD_TYPE_NONE,
23 RRDF_FIELD_TYPE_INTEGER,
24 RRDF_FIELD_TYPE_BOOLEAN,
25 RRDF_FIELD_TYPE_STRING,
26 RRDF_FIELD_TYPE_DETAIL_STRING,
27 RRDF_FIELD_TYPE_BAR_WITH_INTEGER,
28 RRDF_FIELD_TYPE_DURATION,
29 RRDF_FIELD_TYPE_TIMESTAMP,
30 RRDF_FIELD_TYPE_ARRAY,
31 } RRDF_FIELD_TYPE;
32
33 // Declare enum string mapping functions
34 ENUM_STR_DEFINE_FUNCTIONS_EXTERN(RRDF_FIELD_TYPE)
35
36 // Convert an RRDF_FIELD_TYPE to a simplified JSON scalar type string
37 // for easier LLM comprehension
38 const char *field_type_to_json_scalar_type(RRDF_FIELD_TYPE type);
39
40 typedef enum __attribute__((packed)) {
41 RRDF_FIELD_VISUAL_VALUE, // show the value, possibly applying a transformation
42 RRDF_FIELD_VISUAL_BAR, // show the value and a bar, respecting the max field to fill the bar at 100%
43 RRDF_FIELD_VISUAL_PILL, //
44 RRDF_FIELD_VISUAL_RICH, //
45 RRDR_FIELD_VISUAL_ROW_OPTIONS, // this is a dummy column that is used for row options
46 } RRDF_FIELD_VISUAL;
47
48 ENUM_STR_DEFINE_FUNCTIONS_EXTERN(RRDF_FIELD_VISUAL)
49
50 typedef enum __attribute__((packed)) {
51 RRDF_FIELD_TRANSFORM_NONE, // show the value as-is
52 RRDF_FIELD_TRANSFORM_NUMBER, // show the value respecting the decimal_points
53 RRDF_FIELD_TRANSFORM_DURATION_S, // transform as duration in second to a human-readable duration
54 RRDF_FIELD_TRANSFORM_DATETIME_MS, // UNIX epoch timestamp in ms
55 RRDF_FIELD_TRANSFORM_DATETIME_USEC, // UNIX epoch timestamp in usec
56 RRDF_FIELD_TRANSFORM_XML, // format the field with an XML prettifier
57 } RRDF_FIELD_TRANSFORM;
58
59 ENUM_STR_DEFINE_FUNCTIONS_EXTERN(RRDF_FIELD_TRANSFORM)
60
61 typedef enum __attribute__((packed)) {
62 RRDF_FIELD_SORT_ASCENDING = (1 << 0),
63 RRDF_FIELD_SORT_DESCENDING = (1 << 1),
64
65 RRDF_FIELD_SORT_FIXED = (1 << 7),
66 } RRDF_FIELD_SORT;
67
68 ENUM_STR_DEFINE_FUNCTIONS_EXTERN(RRDF_FIELD_SORT)
69
70 typedef enum __attribute__((packed)) {
71 RRDF_FIELD_SUMMARY_UNIQUECOUNT, // Finds the number of unique values of a group of rows
72 RRDF_FIELD_SUMMARY_SUM, // Sums the values of a group of rows
73 RRDF_FIELD_SUMMARY_MIN, // Finds the minimum value of a group of rows
74 RRDF_FIELD_SUMMARY_MAX, // Finds the maximum value of a group of rows
75 // RRDF_FIELD_SUMMARY_EXTENT, // Finds the minimum and maximum values of a group of rows
76 RRDF_FIELD_SUMMARY_MEAN, // Finds the mean/average value of a group of rows
77 RRDF_FIELD_SUMMARY_MEDIAN, // Finds the median value of a group of rows
78 // RRDF_FIELD_SUMMARY_UNIQUE, // Finds the unique values of a group of rows
79 RRDF_FIELD_SUMMARY_COUNT, // Calculates the number of rows in a group
80 } RRDF_FIELD_SUMMARY;
81
82 ENUM_STR_DEFINE_FUNCTIONS_EXTERN(RRDF_FIELD_SUMMARY)
83
84 typedef enum __attribute__((packed)) {
85 RRDF_FIELD_FILTER_NONE = 0,
86 RRDF_FIELD_FILTER_RANGE,
87 RRDF_FIELD_FILTER_MULTISELECT,
88 RRDF_FIELD_FILTER_FACET,
89 } RRDF_FIELD_FILTER;
90
91 ENUM_STR_DEFINE_FUNCTIONS_EXTERN(RRDF_FIELD_FILTER)
92
93 void buffer_rrdf_table_add_field(BUFFER *wb, size_t field_id, const char *key, const char *name, RRDF_FIELD_TYPE type,
94 RRDF_FIELD_VISUAL visual, RRDF_FIELD_TRANSFORM transform, size_t decimal_points,
95 const char *units, NETDATA_DOUBLE max, RRDF_FIELD_SORT sort, const char *pointer_to,
96 RRDF_FIELD_SUMMARY summary, RRDF_FIELD_FILTER filter, RRDF_FIELD_OPTIONS options,
97 const char *default_value);
98
99 #endif /* NETDATA_FUNCTIONS_FIELDS_H */