@cryptotaxi247 / netdata-1 / commits / d5a25e8cb

added options match-ids and match-names

Costa Tsaousis (ktsaou) committed Dec 23, 2017 at 15:01 UTC d5a25e8cbf78470e4c2662975fb67c64229ff0d3
5 files changed +25 -5
src/rrd2json.c
+15 -3
@@ -466,12 +466,24 @@ void rrdr_disable_not_selected_dimensions(RRDR *r, uint32_t options, const char
466
467 if(unlikely(!dims || !*dims || (dims[0] == '*' && dims[1] == '\0'))) return;
468
469 - long c, dims_selected = 0, dims_not_hidden_not_zero = 0;
470 - RRDDIM *d;
469 + int match_ids = 0, match_names = 0;
470 +
471 + if(unlikely(options & RRDR_OPTION_MATCH_IDS))
472 + match_ids = 1;
473 + if(unlikely(options & RRDR_OPTION_MATCH_NAMES))
474 + match_names = 1;
475 +
476 + if(likely(!match_ids && !match_names))
477 + match_ids = match_names = 1;
478
479 SIMPLE_PATTERN *pattern = simple_pattern_create(dims, ",|\t\r\n\f\v", SIMPLE_PATTERN_EXACT);
480 +
481 + RRDDIM *d;
482 + long c, dims_selected = 0, dims_not_hidden_not_zero = 0;
483 for(c = 0, d = r->st->dimensions; d ;c++, d = d->next) {
474 - if(simple_pattern_matches(pattern, d->id) || simple_pattern_matches(pattern, d->name)) {
484 + if( (match_ids && simple_pattern_matches(pattern, d->id))
485 + || (match_names && simple_pattern_matches(pattern, d->name))
486 + ) {
487 r->od[c] |= RRDR_SELECTED;
488 if(unlikely(r->od[c] & RRDR_HIDDEN)) r->od[c] &= ~RRDR_HIDDEN;
489 dims_selected++;
src/rrd2json.h
+2
@@ -62,6 +62,8 @@
62 #define RRDR_OPTION_PERCENTAGE 0x00000800 // give values as percentage of total
63 #define RRDR_OPTION_NOT_ALIGNED 0x00001000 // do not align charts for persistant timeframes
64 #define RRDR_OPTION_DISPLAY_ABS 0x00002000 // for badges, display the absolute value, but calculate colors with sign
65 +#define RRDR_OPTION_MATCH_IDS 0x00004000 // when filtering dimensions, match only IDs
66 +#define RRDR_OPTION_MATCH_NAMES 0x00008000 // when filtering dimensions, match only names
67
68 extern void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb);
69 extern void rrd_stats_api_v1_charts(RRDHOST *host, BUFFER *wb);
src/web_api_v1.c
+4
@@ -40,6 +40,10 @@ static struct {
40 , {"google-json" , 0 , RRDR_OPTION_GOOGLE_JSON}
41 , {"percentage" , 0 , RRDR_OPTION_PERCENTAGE}
42 , {"unaligned" , 0 , RRDR_OPTION_NOT_ALIGNED}
43 + , {"match_ids" , 0 , RRDR_OPTION_MATCH_IDS}
44 + , {"match-ids" , 0 , RRDR_OPTION_MATCH_IDS}
45 + , {"match_names" , 0 , RRDR_OPTION_MATCH_NAMES}
46 + , {"match-names" , 0 , RRDR_OPTION_MATCH_NAMES}
47 , { NULL, 0, 0}
48 };
49
web/netdata-swagger.json
+3 -1
@@ -177,7 +177,9 @@
177 "objectrows",
178 "google_json",
179 "percentage",
180 - "unaligned"
180 + "unaligned",
181 + "match-ids",
182 + "match-names"
183 ],
184 "collectionFormat": "pipes"
185 },
web/netdata-swagger.yaml
+1 -1
@@ -110,7 +110,7 @@ paths:
110 type: array
111 items:
112 type: string
113 - enum: [ 'nonzero', 'flip', 'jsonwrap', 'min2max', 'seconds', 'milliseconds', 'abs', 'absolute', 'absolute-sum', 'null2zero', 'objectrows', 'google_json', 'percentage', 'unaligned' ]
113 + enum: [ 'nonzero', 'flip', 'jsonwrap', 'min2max', 'seconds', 'milliseconds', 'abs', 'absolute', 'absolute-sum', 'null2zero', 'objectrows', 'google_json', 'percentage', 'unaligned', 'match-ids', 'match-names' ]
114 collectionFormat: pipes
115 default: [seconds, jsonwrap]
116 allowEmptyValue: false