Mais conteúdo relacionado
Semelhante a WRITING QUERIES (INFLUXQL AND TICK) (20)
WRITING QUERIES (INFLUXQL AND TICK)
- 5. © 2018 InfluxData. All rights reserved.5
The InfluxDB Query Language (InfluxQL) is a SQL-like query language tailored
for querying ranges of time.
InfluxQL
SELECT <field_key>[,<field_key>,<tag_key>]
FROM <measurement_name>[,<measurement_name>]
Example:
SELECT "usage_user" FROM “cpu"
- 6. © 2018 InfluxData. All rights reserved.6
Tips for performant queries:
• Single queries are more expensive than batches
• Convert continuous queries to Kapacitor tasks
• Persist highly dynamic values as fields, and restrict tags for GROUP BY
and InfluxQL functions
– memory usage grows w/cardinality
• Schema on write still calls for schema design
Optimization
- 7. © 2018 InfluxData. All rights reserved.7
DSL used to define tasks (stream or batch) for processing data in Kapacitor.
TICKscript
stream
// Select just the cpu measurement from our example database.
|from()
.measurement('cpu')
|alert()
.crit(lambda: int("usage_idle") < 90)
// Whenever we get an alert write it to a file.
.log('/tmp/alerts.log')
- 8. © 2018 InfluxData. All rights reserved.8
Reading and Writing Data with the API
• Create a new database using the API
• Write data to “mydb”
curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary
'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
measurement tag field timestamp