summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c97d5b5)
raw | patch | inline | side by side (parent: c97d5b5)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 18 Dec 2016 18:15:23 +0000 (19:15 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 18 Dec 2016 18:15:23 +0000 (19:15 +0100) |
These may be specified as an array of strings after the time-series
identifier.
identifier.
diff --git a/doc/sysdbql.7.txt b/doc/sysdbql.7.txt
index 587cd6cc72bee0fe71d2f046480bea47aa9f59de..9c8b3057cf062eea4ca7fe9720bd9483cdbe5e39 100644 (file)
--- a/doc/sysdbql.7.txt
+++ b/doc/sysdbql.7.txt
the search and filter conditions.
*TIMESERIES* '<hostname>'.'<metric>' [START '<datetime>'] [END '<datetime>']::
the search and filter conditions.
*TIMESERIES* '<hostname>'.'<metric>' [START '<datetime>'] [END '<datetime>']::
+*TIMESERIES* '<hostname>'.'<metric>'\[<data-source, ...\] [START '<datetime>'] [END '<datetime>']::
Retrieve a time-series for the specified host's metric. The data is retrieved
from a backend data-store based on information provided by the respective
query plugin. The return value includes the actual start and end time of the
Retrieve a time-series for the specified host's metric. The data is retrieved
from a backend data-store based on information provided by the respective
query plugin. The return value includes the actual start and end time of the
-time-series and one or multiple sequences of time-stamp / value pairs. If the
-metric does not exist or if the backend data-store is not supported, an error
-is returned.
+time-series and one or multiple sequences of time-stamp / value pairs. If any
+data-source names have been specified, only those data-sources will be
+returned. If the metric or a specified data-source does not exist or if the
+backend data-store is not supported, an error is returned.
MATCHING clause
~~~~~~~~~~~~~~~
MATCHING clause
~~~~~~~~~~~~~~~
diff --git a/src/frontend/query.c b/src/frontend/query.c
index 51658212e95671d1c5e76d57d8b515f3eb6728a6..2a1954abc9a87ebc966dff97e1af47244f76645a 100644 (file)
--- a/src/frontend/query.c
+++ b/src/frontend/query.c
@@ -247,6 +247,8 @@ exec_timeseries(sdb_ast_timeseries_t *ts, sdb_strbuf_t *buf, sdb_strbuf_t *errbu
fetch.obj_type = SDB_METRIC;
fetch.hostname = strdup(ts->hostname);
fetch.name = strdup(ts->metric);
fetch.obj_type = SDB_METRIC;
fetch.hostname = strdup(ts->hostname);
fetch.name = strdup(ts->metric);
+ opts.data_names = (const char * const *)ts->data_names;
+ opts.data_names_len = ts->data_names_len;
opts.start = ts->start;
opts.end = ts->end;
opts.start = ts->start;
opts.end = ts->end;
index 4272ec04f1285e71f0493b7d216d1be717ecaa66..110ee082a93402d11319ac3b8a63145e8a145b88 100644 (file)
--- a/src/include/parser/ast.h
+++ b/src/include/parser/ast.h
sdb_ast_node_t super;
char *hostname;
char *metric;
sdb_ast_node_t super;
char *hostname;
char *metric;
+ char **data_names;
+ size_t data_names_len;
sdb_time_t start;
sdb_time_t end;
} sdb_ast_timeseries_t;
#define SDB_AST_TIMESERIES(obj) ((sdb_ast_timeseries_t *)(obj))
#define SDB_AST_TIMESERIES_INIT \
sdb_time_t start;
sdb_time_t end;
} sdb_ast_timeseries_t;
#define SDB_AST_TIMESERIES(obj) ((sdb_ast_timeseries_t *)(obj))
#define SDB_AST_TIMESERIES_INIT \
- { { SDB_OBJECT_INIT, SDB_AST_TYPE_TIMESERIES, -1 }, NULL, NULL, 0, 0 }
+ { { SDB_OBJECT_INIT, SDB_AST_TYPE_TIMESERIES, -1 }, NULL, NULL, NULL, 0, 0, 0 }
/*
* AST constructors:
/*
* AST constructors:
/*
* sdb_ast_timeseries_create:
* Creates an AST node representing a TIMESERIES command. The newly created
/*
* sdb_ast_timeseries_create:
* Creates an AST node representing a TIMESERIES command. The newly created
- * node takes ownership of the strings.
+ * node takes ownership of the strings and string vectors.
*/
sdb_ast_node_t *
sdb_ast_timeseries_create(char *hostname, char *metric,
*/
sdb_ast_node_t *
sdb_ast_timeseries_create(char *hostname, char *metric,
+ char **data_names, size_t data_names_len,
sdb_time_t start, sdb_time_t end);
#ifdef __cplusplus
sdb_time_t start, sdb_time_t end);
#ifdef __cplusplus
diff --git a/src/parser/ast.c b/src/parser/ast.c
index 96c05ffa612ab22fb4e28658912b98b48c65bc1a..1db342cadf6e6b796fafd8ed05c39d985efce23b 100644 (file)
--- a/src/parser/ast.c
+++ b/src/parser/ast.c
free(timeseries->hostname);
if (timeseries->metric)
free(timeseries->metric);
free(timeseries->hostname);
if (timeseries->metric)
free(timeseries->metric);
+ if (timeseries->data_names) {
+ size_t i;
+ for (i = 0; i < timeseries->data_names_len; i++)
+ free(timeseries->data_names[i]);
+ free(timeseries->data_names);
+ timeseries->data_names = NULL;
+ }
timeseries->hostname = timeseries->metric = NULL;
} /* timeseries_destroy */
timeseries->hostname = timeseries->metric = NULL;
} /* timeseries_destroy */
sdb_ast_node_t *
sdb_ast_timeseries_create(char *hostname, char *metric,
sdb_ast_node_t *
sdb_ast_timeseries_create(char *hostname, char *metric,
+ char **data_names, size_t data_names_len,
sdb_time_t start, sdb_time_t end)
{
sdb_ast_timeseries_t *timeseries;
sdb_time_t start, sdb_time_t end)
{
sdb_ast_timeseries_t *timeseries;
timeseries->hostname = hostname;
timeseries->metric = metric;
timeseries->hostname = hostname;
timeseries->metric = metric;
+ timeseries->data_names = data_names;
+ timeseries->data_names_len = data_names_len;
timeseries->start = start;
timeseries->end = end;
return SDB_AST_NODE(timeseries);
timeseries->start = start;
timeseries->end = end;
return SDB_AST_NODE(timeseries);
diff --git a/src/parser/grammar.y b/src/parser/grammar.y
index 6654780c185ddcd88ad3d3d8517fc48c1e566813..61891888d18423823141f4086bdb70e80ac55cfa 100644 (file)
--- a/src/parser/grammar.y
+++ b/src/parser/grammar.y
/* empty */ { $$.type = $$.id = NULL; $$.last_update = 0; }
/*
/* empty */ { $$.type = $$.id = NULL; $$.last_update = 0; }
/*
- * TIMESERIES <host>.<metric> [START <datetime>] [END <datetime>];
+ * TIMESERIES <host>.<metric>[<data-source>...] [START <datetime>] [END <datetime>];
*
* Returns a time-series for the specified host's metric.
*/
timeseries_statement:
TIMESERIES STRING '.' STRING start_clause end_clause
{
*
* Returns a time-series for the specified host's metric.
*/
timeseries_statement:
TIMESERIES STRING '.' STRING start_clause end_clause
{
- $$ = sdb_ast_timeseries_create($2, $4, $5, $6);
+ $$ = sdb_ast_timeseries_create($2, $4, NULL, 0, $5, $6);
+ CK_OOM($$);
+ }
+ |
+ TIMESERIES STRING '.' STRING array start_clause end_clause
+ {
+ char **ds;
+ size_t ds_num;
+
+ if ($5.type != (SDB_TYPE_ARRAY | SDB_TYPE_STRING)) {
+ sdb_parser_yyerrorf(&yylloc, scanner, YY_("syntax error, "
+ "unexpected array of type %s; expected STRING"),
+ SDB_TYPE_TO_STRING($5.type));
+ sdb_data_free_datum(&$5);
+ free($2);
+ free($4);
+ YYABORT;
+ }
+
+ ds = $5.data.array.values;
+ ds_num = $5.data.array.length;
+
+ $$ = sdb_ast_timeseries_create($2, $4, ds, ds_num, $6, $7);
CK_OOM($$);
}
;
CK_OOM($$);
}
;