forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
64 lines (39 loc) · 1.97 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Package influxql implements a parser for the InfluxDB query language.
InfluxQL is a DML and DDL language for the InfluxDB time series database.
It provides the ability to query for aggregate statistics as well as create
and configure the InfluxDB server.
Selecting data
The SELECT query is used for retrieving data from one or more series. It allows
for a list of columns followed by a list of series to select from.
SELECT value FROM cpu_load
You can also add a a conditional expression to limit the results of the query:
SELECT value FROM cpu_load WHERE host = 'influxdb.com'
Two or more series can be combined into a single query and executed together:
SELECT cpu0.value + cpu1.value
FROM cpu_load AS cpu0 INNER JOIN cpu_load cpu1 ON cpu0.host = cpu1.host
Limits and ordering can be set on selection queries as well:
SELECT value FROM cpu_load LIMIT 100 ORDER DESC;
Removing data
The DELETE query is available to remove time series data points from the
database. This query will delete "cpu_load" values older than an hour:
DELETE FROM cpu_load WHERE time < now() - 1h
Continuous Queries
Queries can be run indefinitely on the server in order to generate new series.
This is done by running a "SELECT INTO" query. For example, this query computes
the hourly mean for cpu_load and stores it into a "cpu_load" series in the
"daily" shard space.
SELECT mean(value) AS value FROM cpu_load GROUP BY 1h
INTO daily.cpu_load
If there is existing data on the source series then this query will be run for
all historic data. To only execute the query on new incoming data you can append
"NO BACKFILL" to the end of the query:
SELECT mean(value) AS value FROM cpu_load GROUP BY 1h
INTO daily.cpu_load NO BACKFILL
Continuous queries will return an id that can be used to remove them in the
future. To remove a continous query, use the DROP CONTINUOUS QUERY statement:
DROP CONTINUOUS QUERY 12
You can also list all continuous queries by running:
LIST CONTINUOUS QUERIES
*/
package influxql