Code

sysdbql(7): Documented the ‘TIMESERIES’ command.
[sysdb.git] / doc / sysdbql.7.txt
1 sysdbql(7)
2 ==========
3 :doctype: manpage
5 NAME
6 ----
7 sysdbql - the SysDB query language
9 SYNOPSIS
10 --------
12   LIST hosts;
14   FETCH host 'some.host.name';
16   LOOKUP hosts MATCHING attribute.architecture = 'amd64'
17                FILTER :age < 5 * :interval;
19 DESCRIPTION
20 -----------
21 include::sysdb-description.txt[]
23 The SysDB query language is a human-readable format for describing a request
24 to retrieve data from a SysDB daemon. It is very remotely similar to the
25 Standard Query Language (SQL) supported by relational database management
26 systems (RDBMS) but specialized for SysDB's use-case.
28 QUERY COMMANDS
29 --------------
30 Each command is terminated by a semicolon. The following commands are
31 available to retrieve information from SysDB:
33 *LIST* hosts [*FILTER* '<filter_condition>']::
34 Retrieve a sorted (by name) list of all hosts currently stored in SysDB. The
35 return value is a list of hosts where each host specification includes its
36 name, the timestamp of the last update of the object known to SysDB and an
37 approximation of the interval with which the host was updated. If a filter
38 condition is specified, only objects matching that filter will be included in
39 the reply. See the section "FILTER clause" for more details about how to
40 specify the search and filter conditions.
42 *FETCH* host '<hostname>' [*FILTER* '<filter_condition>']::
43 Retrieve detailed information about the specified host object. The return
44 value includes the hostname, a list of services referenced by the host, and a
45 list of attributes for the host and each service. If the host does not exist,
46 an error is returned. If a filter condition is specified, only objects
47 matching that filter will be included in the reply. See the section "FILTER
48 clause" for more details about how to specify the search and filter
49 conditions.
51 *LOOKUP* hosts *MATCHING* '<search_condition>' [*FILTER* '<filter_condition>']::
52 Retrieve detailed information about all host objects matching the specified
53 search condition. The return value is a list of detailed information for each
54 matching host providing the same details as returned by the *FETCH* command.
55 If no host matches the search criteria, it's not considered an error. Instead,
56 an empty list is returned. If a filter condition is specified, only objects
57 matching that filter will be included in the reply. See the sections "MATCHING
58 clause" and "FILTER clause" for more details about how to specify the search
59 and filter conditions.
61 *TIMESERIES* '<hostname>'.'<metric>' [START '<datetime>'] [END '<datetime>']::
62 Retrieve a time-series for the specified host's metric. The data is retrieved
63 from a backend data-store based on information provided by the respective
64 query plugin. The return value includes the actual start and end time of the
65 time-series and one or multiple sequences of time-stamp / value pairs. If the
66 metric does not exist or if the backend data-store is not supported, an error
67 is returned.
69 MATCHING clause
70 ~~~~~~~~~~~~~~~
71 The *MATCHING* clause in a query specifies a boolean expression which is used
72 to match host objects based on their names, their attributes, or services
73 referenced by the host. Each *MATCHING* clause may be made up of one or
74 multiple subexpressions each matching on one criteria. The following
75 subexpressions are supported by SysDB:
77 '<field>' '<operator>' '<value>'::
78         Match a named field against the specified value. See below for what fields
79         and operators are supported.
81 *NOT* '<subexpression>'::
82         Invert the boolean result of the specified subexpression.
84 '<subexpression>' *AND* '<subexpression>'::
85 '<subexpression>' *OR* '<subexpression>'::
86         Combine multiple subexpressions using logical AND or logical OR.
88 The following fields may be queried:
90 *host*::
91         The full name of the host.
93 *service*::
94         The full service name as referenced by the host.
96 *attribute*::
97         The full name of a host attribute.
99 *attribute.*'<name>'::
100         The value of the named host attribute. If an attribute of the specified
101         does not exist, each comparison is treated as if the value does not match.
102         See the documentation for the *IS NULL* and *IS NOT NULL* operators for
103         ways to check if an attribute exists.
105 '<value>' may either be a string (when matching by object names) or match the
106 type of the attribute's value (when matching attribute values). Attribute
107 values may either be a string, integer, decimal number, or a date-time value
108 (booleans and binary data are not supported by the frontend yet).
110 When comparing an attribute's value using a regular expression matcher, the
111 value will be cast to a string before doing so. No other casts are supported
112 at this time.
114 The following operators may be used to match field values:
116 *=*::
117         Evaluates to true if the field value exactly matches the specified value.
119 *!=*::
120         Evaluates to true if the field value does not match the exact specified
121         value.
123 *=~*::
124         Evaluates to true if the field value matches the specified regular
125         expression. SysDB uses POSIX extended regular expressions.
127 *!~*::
128         Evalues to true if the field value does not match the specified regular
129         expression.
131 The following operators may be used, in addition, to match attribute values:
133 *<*, *\<=*, *>=*, *>*::
134         Evaluates to true if the attribute value is less than, less than or equal
135         to, greater than or equal to or greater than the specified value.
137 In addition, a named attribute may be checked for existence using the *IS
138 NULL* and *IS NOT NULL* operators. An attribute is considered to be *NULL* if
139 it is not set for a host.
141 FILTER clause
142 ~~~~~~~~~~~~~
143 The *FILTER* clause in a query specifies a boolean expression which is used to
144 filter objects included in the query's response. The filter is applied to
145 hosts, services, and attributes alike and, thus, will usually be based on the
146 core properties of the stored objects. The basic syntax for filter clauses is
147 the same as for matching clauses (see the description about subexpressions
148 above).
150 The following fields (core properties) of stored objects may be queried:
152 *:last_update*::
153         The timestamp of the last update of the object. This value is based on
154         information provided by the queried backend if possible.
156 *:age*::
157         The amount of time since the last update of the object.
159 *:interval*::
160         The interval with which the object gets updated. This value is determined
161         automatically based on a moving average determined from the update
162         timestamps of an object. It depends on the update timestamps as provided
163         by the backend (if available) and SysDB's query interval.
165 *:backend*::
166         The name of the backend (plugin) providing the data.
168 The type of the *last_update*, *age*, and *interval* fields is date-time and
169 the type of the *backend* field is string. All conditional operators may be
170 used to compare the date-time fields (but not regular expression or *IS NULL*
171 operators). The backend field may only be matched by (in)equality. Each object
172 may be provided by multiple backends. The filter matches if the specified
173 value matches any of them.
175 RESPONSE FORMAT
176 ---------------
177 The JavaScript Object Notation (JSON) format, as specified in RFC 4627, is
178 used in all replies from the server. http://www.ietf.org/rfc/rfc4627.txt
180 EXAMPLES
181 --------
182 The following examples illustrate the use of the commands and what their
183 replies look like. The replies are pretty-printed to more easily follow them.
185   LIST hosts;
186   {"hosts":[{
187       "name": "host1.example.com",
188       "last_update": "2001-02-03 04:05:06 +0700",
189       "update_interval": "5m4s"
190     },{
191       "name": "host2.example.com",
192       "last_update": "2001-02-03 04:05:06 +0700",
193       "update_interval": "5m4s"
194     }]}
196   FETCH host 'host1.example.com';
197   {
198       "name": "host1.example.com",
199       "last_update": "2001-02-03 04:05:06 +0700",
200       "update_interval": "5m4s",
201       "attributes": [{
202           "name": "architecture",
203           "value": "amd64",
204           "last_update": "2001-02-03 04:05:06 +0700",
205           "update_interval": "5m4s"
206         },{
207           ...
208         }],
209       "services": [{
210           "name": "some service",
211           "last_update": "2001-02-03 04:05:06 +0700",
212           "update_interval": "5m4s"
213         },{
214           ...
215         }]}
217   LOOKUP hosts MATCHING attribute.architecture = 'amd64';
218   [{
219       "name": "host1.example.com",
220       "last_update": "2001-02-03 04:05:06 +0700",
221       "update_interval": "5m4s",
222       "attributes": [{
223           "name": "architecture",
224           "value": "amd64",
225           "last_update": "2001-02-03 04:05:06 +0700",
226           "update_interval": "5m4s"
227         },{
228           ...
229         }],
230       "services": [{
231           "name": "some service",
232           "last_update": "2001-02-03 04:05:06 +0700",
233           "update_interval": "5m4s"
234         },{
235           ...
236     }]},{
237       ...
238     }]
240 SEE ALSO
241 --------
242 manpage:sysdb[1], manpage:sysdb[7]
244 The SysDB homepage: http://sysdb.io/
246 AUTHOR
247 ------
248 SysDB was written by Sebastian "tokkee" Harl <sh@tokkee.org>.
250 COPYRIGHT
251 ---------
252 Copyright (C) 2012-2014 Sebastian "tokkee" Harl <sh@tokkee.org>
254 This is free software under the terms of the BSD license, see the source for
255 copying conditions. There is NO WARRANTY; not even for MERCHANTABILITY or
256 FITNESS FOR A PARTICULAR PURPOSE.
258 // vim: set tw=78 sw=4 ts=4 noexpandtab spell spelllang=en_us :