2014-11-25 22:27:34 +00:00
|
|
|
# Select
|
|
|
|
|
2014-12-09 15:24:35 +00:00
|
|
|
```sql
|
2014-12-09 16:09:33 +00:00
|
|
|
-- get the top 10 host measurements for the last hour (same host can appear multiple times)
|
|
|
|
SELECT top(10, value), host FROM cpu WHERE time > now() - 1h
|
2014-11-25 22:27:34 +00:00
|
|
|
|
2014-12-09 16:09:33 +00:00
|
|
|
-- get the top 10 unique hosts for the last hour
|
|
|
|
SELECT top(10, value), distinct(host) FROM cpu WHERE time > now() - 1h
|
2014-12-09 15:24:35 +00:00
|
|
|
```
|
2014-11-25 22:27:34 +00:00
|
|
|
|
|
|
|
## Group By
|
|
|
|
|
|
|
|
# Delete
|
|
|
|
|
|
|
|
# Series
|
|
|
|
|
|
|
|
## Destroy
|
|
|
|
|
|
|
|
DROP SERIES <name>
|
|
|
|
|
|
|
|
## List
|
|
|
|
|
2014-12-09 15:49:42 +00:00
|
|
|
List series queries are for pulling out individual series from measurement names and tag data. They're useful for discovery.
|
|
|
|
|
|
|
|
```sql
|
|
|
|
-- list all series across all measurements/tagsets
|
|
|
|
LIST SERIES
|
|
|
|
|
|
|
|
-- get a list of all series for any measurements where tag key region = tak value 'uswest'
|
|
|
|
LIST SERIES WHERE region = 'uswest'
|
|
|
|
|
|
|
|
-- get a list of all tag keys across all measurements
|
|
|
|
LIST KEYS
|
|
|
|
|
|
|
|
-- list all the tag keys for a given measurement
|
|
|
|
LIST KEYS WHERE measurement = 'cpu'
|
|
|
|
LIST KEYS WHERE measurement = 'temperature' or measurement = 'wind_speed'
|
|
|
|
|
|
|
|
-- list all the tag values. note that at least one WHERE key = '...' clause is required
|
|
|
|
LIST VALUES WHERE key = 'region'
|
|
|
|
LIST VALUES WHERE measurement = 'cpu' and region = 'uswest' and key = 'host'
|
|
|
|
|
|
|
|
-- or maybe like this?
|
|
|
|
LIST VALUES("host") WHERE measurement = 'cpu'
|
|
|
|
-- or?
|
|
|
|
LIST host WHERE measurement = 'cpu'
|
|
|
|
-- or just use the select syntax
|
|
|
|
SELECT DISTINCT("host") from cpu
|
|
|
|
-- but then it would be tricky to show all values of host across
|
|
|
|
-- all measurements, which we need to be able to do
|
|
|
|
```
|
|
|
|
|
|
|
|
And the list series output looks like this:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "cpu",
|
|
|
|
"columns": ["id", "region", "host"],
|
|
|
|
"values": [
|
|
|
|
1, "uswest", "servera",
|
|
|
|
2, "uswest", "serverb"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "reponse_time",
|
|
|
|
"columns": ["id", "application", "host"],
|
|
|
|
"values": [
|
|
|
|
3, "myRailsApp", "servera"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
2014-11-25 22:27:34 +00:00
|
|
|
|
|
|
|
# Continuous Queries
|
|
|
|
|
|
|
|
Continous queries are going to be inspired by MySQL `TRIGGER` syntax:
|
|
|
|
|
|
|
|
http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html
|
|
|
|
|
|
|
|
Instead of having automatically-assigned ids, named continuous queries allows for some level of duplication prevention,
|
|
|
|
particularly in the case where creation is scripted.
|
|
|
|
|
|
|
|
## Create
|
|
|
|
|
|
|
|
CREATE CONTINUOUS QUERY <name> AS SELECT ... FROM ...
|
|
|
|
|
|
|
|
## Destroy
|
|
|
|
|
|
|
|
DROP CONTINUOUS QUERY <name>
|
|
|
|
|
|
|
|
## List
|
|
|
|
|
|
|
|
LIST CONTINUOUS QUERIES
|