Time series databases
-
Upload
source-ministry -
Category
Software
-
view
414 -
download
0
Transcript of Time series databases
2016-04-11 02:00:00 45 2016-04-11 03:00:00 42 2016-04-11 04:00:00 30 2016-04-11 05:00:00 46 2016-04-11 06:00:00 70 2016-04-11 07:00:00 120
Software system that’s optimized for handling arrays of numbers indexed by time
Wikipedia definition
INSERT clicks,type=cpc,source=ad-partner-1,paid=yes,widget=promo-box value=0.43INSERT clicks,type=cpc,source=ad-partner-2,paid=yes,widget=promo-box value=0.50INSERT clicks,type=cpc,source=ad-partner-1,paid=yes,widget=top value=0.62INSERT clicks,type=cpm,source=ad-partner-1,paid=yes,widget=top value=0.80
SELECT * FROM clicks name: clicks ------------ time paid source type value widget 1459850636770890539 yes ad-partner-1 cpc 0.43 promo-box 1459850643866389522 yes ad-partner-2 cpc 0.50 promo-box 1459850656407067481 yes ad-partner-1 cpc 0.62 top 1459850668781668282 yes ad-partner-1 cpm 0.80 top
SELECT COUNT(value), MEAN(value), MEDIAN(value) FROM clicks WHERE time > NOW() - 2m GROUP BY time(5s) name: clicks ------------ time count mean median 1459851275000000000 0 1459851280000000000 0 1459851285000000000 3 0.330 0.33 1459851290000000000 0 1459851295000000000 2 0.420 0.420 1459851300000000000 2 0.365 0.365 1459851305000000000 3 0.446 0.43 1459851310000000000 0 1459851315000000000 0
SELECT COUNT(value), MEAN(value), MEDIAN(value) FROM clicks WHERE time > NOW() - 2m GROUP BY time(5s) FILL(0) name: clicks ------------ time count mean median 1459851275000000000 0 0 0 1459851280000000000 0 0 0 1459851285000000000 3 0.330 0.33 1459851290000000000 0 0 0 1459851295000000000 2 0.420 0.420 1459851300000000000 2 0.365 0.365 1459851305000000000 3 0.446 0.43 1459851310000000000 0 0 0 1459851315000000000 0 0 0
FunctionsAggregrations COUNT DISTINCT INTEGRAL MEAN MEDIAN SPREAD SUM
Selectors BOTTOM FIRST LAST MAX PERCENTILE TOP
Transformations CEILING DERIVATIVE DIFFERENCE FLOOR HISTOGRAM MOVING_AVERAGE STDDEV
curl -i -XPOST 'http://localhost:8086/write?db=test' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000’
HTTP/1.1 204 No Content Request-Id: 02e7757f-fb1e-11e5-809d-000000000000 X-Influxdb-Version: 0.11.0 Date: Tue, 05 Apr 2016 11:03:22 GMT
curl -G 'http://localhost:8086/query' --data-urlencode "db=test" --data-urlencode "q=SELECT value FROM cpu_load_short WHERE region='us-west'"
{"results":[{"series":[{"name":"cpu_load_short","columns":["time","value"],"values":[["2015-06-11T20:46:02Z",0.64]]}]}]}
// create an array of points$points = array( new Point( 'test_metric', // name of the measurement 0.64, // the measurement value ['host' => 'server01', 'region' => 'us-west'], // optional tags ['cpucount' => 10], // optional additional fields 1435255849 // Time precision has to be set to seconds! ), new Point( 'test_metric', // name of the measurement 0.84, // the measurement value ['host' => 'server01', 'region' => 'us-west'], // optional tags ['cpucount' => 10], // optional additional fields 1435255849 // Time precision has to be set to seconds! ));// we are writing unix timestamps, which have a second precision $result = $database->writePoints($points, Database::PRECISION_SECONDS);
$statsd = new League\StatsD\Client();$statsd->increment('web.pageview');$statsd->decrement('storage.remaining');$statsd->increment(array( 'first.metric', 'second.metric'), 2);$statsd->increment('web.clicks', 1, 0.5);
Counters
CREATE CONTINUOUS QUERY <cq_name> ON <database_name> [RESAMPLE [EVERY <interval>] [FOR <interval>]] BEGIN SELECT <function>(<stuff>)[,<function>(<stuff>)] INTO <different_measurement> FROM <current_measurement> [WHERE <stuff>] GROUP BY time(<interval>)[,<stuff>] END