influxdb基本操做

數據庫與表的操做數據庫

#建立數據庫
create database "db_name"
 
#顯示全部的數據庫
show databases
 
#刪除數據庫
drop database "db_name"
 
#使用數據庫
use db_name
 
#顯示該數據庫中全部的表
show measurements
 
#建立表,直接在插入數據的時候指定表名
insert test,host=127.0.0.1,monitor_name=test count=1
 
#刪除表
drop measurement "measurement_name"

#刪除數據
show series from  measurement_name
delete from /.*/  where host =~ /elcndc5dsj\d\d/

code

> use metrics
Using database metrics
> select * from test order by time desc

數據保存策略(Retention Policies)flux

#查看當前數據庫Retention Policies
show retention policies on "db_name"

#建立新的Retention Policies
create retention policy "rp_name" on "db_name" duration 3w replication 1 default

rp_name:策略名
db_name:具體的數據庫名
3w:保存3周,3周以前的數據將被刪除,influxdb具備各類事件參數,好比:h(小時),d(天),w(星期)
replication 1:副本個數,通常爲1就能夠了
default:設置爲默認策略

#修改Retention Policies
alter retention policy "rp_name" on "db_name" duration 30d default

#刪除Retention Policies
drop retention policy "rp_name"

用戶管理事件

#顯示用戶
show users
 
#建立用戶
create user "username" with password 'password'
 
#建立管理員權限用戶
create user "username" with password 'password' with all privileges
 
#刪除用戶
drop user "username"
相關文章
相關標籤/搜索