Skip to content
Lukas Rytz edited this page May 26, 2017 · 7 revisions

Connect to our instance

Curl

> curl -G 'https://scala-ci.typesafe.com/influx/query?pretty=true' --data-urlencode "u=scala" --data-urlencode "p=<>" --data-urlencode "db=scala_benchmark" --data-urlencode "q=SELECT * FROM result WHERE time > now() - 1d"
...

SSH and CLI

> ssh [email protected]
> influx -username scala -password <>
> use scala_benchmark
> SELECT * FROM result WHERE time > now() - 1d
...

Web UI

> ssh [email protected] -L 8086:localhost:8086 -N &
> ssh [email protected] -L 8083:localhost:8083 -N &

Open http://localhost:8083. Host: localhost, port: 8086, no SSL.

In principle, it should work without the first tunnel (host: scala-ci.typesafe.com/influx, port: 443, with SSL), but I couldn't get it to work.

Try with query SELECT * FROM result WHERE time > now() - 1d.

InfluxDB schema

Measurement

  • Similar to an sql table
  • Examples in scala_benchmark: result, commit
  • Query: SHOW MEASUREMENTS

Tags

  • Similar to an indexed column in sql
  • Examples: benchmark, branch, source, ...
  • Use for commonly queried meta-data
  • Tag values are always strings
  • Queries: SHOW TAG KEYS FROM result, SHOW TAG VALUES FROM result WITH KEY = benchmark

Fields

  • Similar to non-indexed columns in sql
  • Data and metadata
  • Examples: javaVersion, score, ...
  • Query: SHOW FIELD KEYS FROM result

Point

  • A data entry, similar to a row in sql
  • Contains a timestamp, values for all tag keys, values for some field keys (sparse)

Series

  • A measurement with a unique "tag set" (a set of tag key-value pairs)
  • Example: result,benchmark=HotScalacBenchmark.compile,branch=2.12.x,source=better-files

Writing the same (measurement,timestamp,tagSet) twice overwrites the existing point. We can exploit this to re-run a benchmark.

Working with data

Querying

https://docs.influxdata.com/influxdb/v1.2/query_language/data_exploration/

  • A query requires at least one field key in the SELECT clause to return data
  • Tag and field keys can be quoted in double quotes (if necessary)
  • String literals need to be in single quotes
    • Example: SELECT * FROM result WHERE "benchmark" = 'HotScalacBenchmark.compile' LIMIT 5
  • Regex matching: WHERE tagName =~ /regex/
  • Query by time: SELECT * FROM result WHERE time > now() - 7d
    • now() is the current time in nanoseconds

Entering data

InfluxDB is a schemaless database: measurements, tags, and fields are created on demand.

Write commands

Types

  • Measurements, tag keys, tag values and field keys are strings. Don't double-quote!
    • If a tag is not provided, its value is ''. If a write introduces a new tag, all existing points get tag value ''.
  • Timestamps are unix timestamps in nanos (365199550781253)
  • Types for field values:
    • 1, 1.0 are Double
    • 1i is Int
    • t, F, true, False, TRUE are Boolean
    • "s" is String

Writing with curl

curl -i -XPOST 'https://scala-ci.typesafe.com/influx/write?db=scala_benchmark' --data-binary 'result,benchmark=<>,branch=<>... javaVersion=<>,score=<>,... 1434055562000000000'

Back up / copy a measurement

SELECT * INTO new_name FROM old_name GROUP BY *

Deleting data

Delete one or multiple series from a measurement: DROP SERIES

  • Can be used to drop a tag that's no longer in use

Delete an entire measurement: DROP MEASUREMENT

Fields cannot be deleted, need to copy into a new measurement

Clone this wiki locally