influxdb 的简单安装/配置/使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huitailang1991/article/details/79742756

数据源是通过influxdb-python写入到influxdb的,展示用的是grafana。

安装

for debian 9 strech version,这样才能是最新版本:

curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/os-release
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

sudo apt-get update && sudo apt-get install influxdb
sudo service influxdb start

配置

将默认配置导出到文件,influxd -config /etc/influxdb/influxdb.conf在创建数据库后用户后再打开认证,修改配置信息,打开认证。

[http]
  enabled = true
  bind-address = ":8086"
  auth-enabled = true # ✨

规则

Downsampling and data retention

retention policy

保留多久的数据

continuous query

按什么频率采样

4. Create the CQ

Now that we’ve set up our RPs, we want to create a CQ that will automatically and periodically downsample the ten-second resolution data to the 30-minute resolution, and store those results in a different measurement with a different retention policy.

Use the CREATE CONTINUOUS QUERY statement to generate a CQ:

> CREATE CONTINUOUS QUERY "cq_30m" ON "food_data" BEGIN
  SELECT mean("website") AS "mean_website",mean("phone") AS "mean_phone"
  INTO "a_year"."downsampled_orders"
  FROM "orders"
  GROUP BY time(30m)
END

That query creates a CQ called cq_30m in the database food_data. cq_30m tells InfluxDB to calculate the 30-minute average of the two fields website and phone in the measurement orders and in the DEFAULT RP two_hours. It also tells InfluxDB to write those results to the measurement downsampled_orders in the retention policy a_year with the field keys mean_website and mean_phone. InfluxDB will run this query every 30 minutes for the previous 30 minutes.

    Note: Notice that we fully qualify (that is, we use the syntax "<retention_policy>"."<measurement>") the measurement in the INTO clause. InfluxDB requires that syntax to write data to an RP other than the DEFAULT RP. 

实际使用说明

continuous query

CREATE CONTINUOUS QUERY org_stream_30m ON testdb BEGIN SELECT sum(value) INTO org_stream_30m FROM org_stream GROUP BY time(30m) END

org_stream按照30m分钟的频率采样插入org_stream_30m,group by time(30m),每30分钟执行一次。

select * from org_stream where time >= ‘2017-11-01T00:00:00Z’

CLI

时间 pretty

进入influx后,输入precision rfc3339

备份

backing and restore

猜你喜欢

转载自blog.csdn.net/huitailang1991/article/details/79742756
今日推荐