Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A TSDB queries tour (DevOps Italia - Bologne)

A TSDB queries tour (DevOps Italia - Bologne)

Starting from zero how to query time series data, what the best practices are and where stands each database in the queries field. A quick introduction to time series language is also given with flux and tsl (over Warp 10).
This talk was given in english @DevOps Italia (https://2019.incontrodevops.it/) 2019:
- [video](https://vimeo.com/334066590)

Avatar for Aurélien HÉBERT

Aurélien HÉBERT

March 08, 2019

More Decks by Aurélien HÉBERT

Other Decks in Programming

Transcript

  1. @IncontroDevOps @AurrelH95 Many open source out there ❖ Steven Acreman

    (Outlier) ❖ Top 10 Time Series Databases 11
  2. @IncontroDevOps @AurrelH95 Server data CPU disk disk I/O load kernel

    memory network I/O temperature system swap ... 13
  3. @IncontroDevOps @AurrelH95 Graphite At configuration, using aggregation-rules cpu.usage_system (120) =

    avg cpu.usage_system Main down-samplers are: sum, avg, min, max, percentiles and count 36
  4. @IncontroDevOps @AurrelH95 OpenTSDB ➢ Main aggregators are: avg, count, dev,

    percentiles, min, max, mimmin, mimmax, sum, none (raw data) and zimsum (Difference between mimmin and min are missing values interpolation, same for mimmax and max and zimsum and sum) 40
  5. @IncontroDevOps @AurrelH95 PromQL ➢ Grouping operator can be one of:

    sum, avg, min, max, stddev, stdvar, count, topk, bottomk and quantile 42
  6. @IncontroDevOps @AurrelH95 Graphite ➢ Main aggregators are avg, median, sum,

    min, max, diff, stddev, count, range, multiply and last 44
  7. @IncontroDevOps @AurrelH95 Graphite functions TimeSlice, TimeShift Integral, Interpolate, derivative More

    than 100 functions Unique, sort LinearRegression, exponential smoothing PieAverage, legendValue MovingMean, MovingMax 54
  8. @IncontroDevOps @AurrelH95 Data model structure ❖ Labels with Key/Value map

    attached to each metrics with Prometheus ❖ Name with dot separated component for Graphite 60
  9. @IncontroDevOps @AurrelH95 Languages review PromQL: ❖ Structured ❖ Easier to

    compute operation on multiple series Graphite: ❖ More Time series functions ➢ stats ➢ maths ➢ graphs 61
  10. @IncontroDevOps @AurrelH95 Warp 10 api/v0/exec: [ "token" "cpu.average" { "cpu"

    "~cpu[0-9]+" } 1535818770 10 h ] FETCH [ SWAP bucketizer.mean 0 2 m 0 ] BUCKETIZE [ SWAP [ "host" ] reducer.max ] REDUCE 63
  11. @IncontroDevOps @AurrelH95 Warp 10 review ❖ Dedicated language ❖ A

    time series workflow ❖ Queries complexity ❖ Abstraction needed to end user 67
  12. @IncontroDevOps @AurrelH95 Does the job ❖ Mix of visualization ❖

    Multiple series ❖ Lof of functions (functions) ❖ Less control on data ❖ Need a graphical tool (Timelion on Kibana) ❖ Lower query performance 70
  13. @IncontroDevOps @AurrelH95 M3 TSDB POST /query { "namespace": "test", "query":

    { "regexp": { "field": "city", "regexp": ".*" } }, "rangeStart": 0, "rangeEnd":'"$(date +"%s")"' } 71
  14. @IncontroDevOps @AurrelH95 From InfluxQL SELECT max("usage_system") FROM "telegraf".."cpu" WHERE "host"

    = 'ahe-XPS-13-9360' AND time > now() - 12h GROUP BY time(10m) ❖ First iteration ❖ Database queries ❖ Familiar SQL user 76
  15. @IncontroDevOps @AurrelH95 InfluxQL drawback Time series data are NOT relational

    InfluxQL had limitations for advanced use cases 77
  16. @IncontroDevOps @AurrelH95 And flux POST query= from(bucket:"telegraf") |> filter(fn: (r)

    => r._measurement == "cpu" AND r._field == "usage_system") |> range(start:-12h) |> group(by: ["host"]) |> window(every: 2m) |> max() ❖ Data language ❖ Lot of native functions ❖ User defined function ❖ A usable language 79
  17. @IncontroDevOps @AurrelH95 And Flux as a proxy Run the same

    flux operation on data loaded in memory Any LTS
  18. @IncontroDevOps @AurrelH95 Flux as proxy - from Flux FromProm Parameters

    Query, Matcher, Step, Basic auth FromRange Rewrite prom query with start and end FilterSpec Update prom query with flux filters Connect Connect flux to a Prometheus database Fetch Execute a Prom query or a Remote read and parse result as Influx data
  19. @IncontroDevOps @AurrelH95 Flux - From Prometheus fromProm(query: "max(my.series{dc=\"test\"})", step: 120s)

    |> range(start: -5m) fromProm(name:"my.series") |> filter(fn: (r) => r.host == "my.host" and r.dc == "test") |> range(start: -5m) |> max() ❖ Prometheus queries ❖ Prometheus Remote read
  20. @IncontroDevOps @AurrelH95 A time series language? ❖ Quick access to

    the data ❖ Times series native features ❖ Back-end agnostic ❖ Simplify user experience 84
  21. @IncontroDevOps @AurrelH95 TSL aims 86 ❖ A clear analytics syntax

    ❖ Making it developer friendly ❖ Support data flow and complex queries ❖ Keep it simple
  22. @IncontroDevOps @AurrelH95 A simple TSL query 87 select("cpu.usage_system") .where("cpu~cpu[0-7]*") .last(12h)

    .sampleBy(5m,max) .groupBy(mean) .rate() Select Where* Last? From? Sampling? GroupBy? Operations*
  23. @IncontroDevOps @AurrelH95 More complex query 88 ❖ Declare and use

    variables ❖ Times series sets operators ❖ Custom operators: meta, transform, arithmetic, windows, filters...
  24. @IncontroDevOps @AurrelH95 HEW use case with TSL sample = select('sap.flux')

    .where('KEPLERID=6541920') .from("2009-05-02T00:56:10.000000Z", to="2013-05-11T12:02:06.000000Z") .timesplit(6h,100,"record") .filterByLabels('record~[2-5]') .sampleBy(2h, min, false, "none") trend = sample.window(mean, 5, 5) sub(sample,trend) .on('KEPLERID','record') .lessThan(-20.0) ❖ Support complex use cases 89