溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

InfluxDB學習之InfluxDB的基本操作

發布時間:2020-06-24 22:45:24 來源:網絡 閱讀:3037 作者:DBAspace 欄目:數據庫

InfluxDB 是一個開源分布式時序、事件和指標數據庫。

使用 Go 語言編寫,無需外部依賴。其設計目標是實現分布式和水平伸縮擴展。


它有三大特性:

1. Time Series (時間序列):你可以使用與時間有關的相關函數(如最大,最小,求和等)

2. Metrics(度量):你可以實時對大量數據進行計算

3. Eevents(事件):它支持任意的事件數據

特點

schemaless(無結構),可以是任意數量的列

Scalable

min, max, sum, count, mean, median 一系列函數,方便統計

Native HTTP API, 內置http支持,使用http讀寫

Powerful Query Language 類似sql

Built-in Explorer 自帶管理工具


安裝好influxdb后通過終端登錄到數據庫,http api over 8086,頁面為8083

[root@mycat ~]# inf

influx          influx_inspect  influx_tsm      infocmp         infotocap

influxd         influx_stress   info            infokey     


通過influx登陸終端

[root@mycat ~]# influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 0.13.0

InfluxDB shell version: 0.13.0

1、Creating a database,注意關鍵詞的大小寫

> CREATE DATABASE mydb;

> SHOW DATABASES;

name: databases

---------------

name

telegraf

_internal

mytab

mydb

2、切換庫,有的關鍵字也沒那么規范

> use mydb

Using database mydb

> USE mydb

Using database mydb

3、Writing and exploring data,寫入一條數據需要基礎格式

1、a short primer on the datastore#存放數據的實體對象,相當在關系型數據的表名

數據在時序數據庫(influxDB)是有組織的時間序列,包含一個 測量值(即在RMDB中的字段),在INFLUXDB中如cpu_load或者temperature,


Points are written to InfluxDB using the Line Protocol, which follows the following format:

<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp]


The following lines are all examples of points that can be written to InfluxDB:


cpu,host=serverA,region=us_west value=0.64

payment,device=mobile,product=Notepad,method=credit billed=33,licenses=3i 1434067467100293230

stock,symbol=AAPL bid=127.46,ask=127.48

temperature,machine=unit42,type=assembly external=25,internal=37 1434067467000000000

這3條例子具體寫法:


InfluxDB中沒有顯式的新建表的語句,只能通過insert數據的方式來建立新表。如下所示:

insert disk_free,hostname=server01 value=442221834240i 1435362189575692182

其中 disk_free 就是表名,hostname是索引,value=xx是記錄值,記錄值可以有多個,最后是指定的時間

> insert cpu,host=serverA,region=us_west value=0.64

> select host,region ,value from cpu ##官方寫法是把這些測量值加引號

name: cpu

---------

timehostregionvalue

1481203149917071248serverAus_west0.64


insert disk_free,hostname=server01 value=442221834240i 1435362189575692182

在這條語句中,disk_free是表名,hostname=server01是tag,屬于索引,value=xx是field,這個可以隨意寫,隨意定義。


A point with the measurement name of cpu and tags host and region has now been written to the database, with the measured value of 0.64.


另一種類型的數據存儲,在相同的測量兩個字段:

相同的測量值包含兩個字段類型的數據

INSERT temperature,machine=unit42,type=assembly external=25,internal=37

> select * from temperature

name: temperature

-----------------

timeexternalinternalmachinetype

14812037975306309012537unit42assembly

刪除一個度量值

delete from cpu

show 支持的方法

 CONTINUOUS, DATABASES, DIAGNOSTICS, FIELD, GRANTS, MEASUREMENTS, QUERIES, 

RETENTION, SERIES, SHARD, SHARDS, STATS, SUBSCRIPTIONS, TAG, USERS


SHOW TAG KEYS FROM "temperature" 顯示度量值的標簽===show create table aa

influxdb支持正則



series操作

series表示這個表里面的數據,可以在圖表上畫成幾條線,series主要通過tags排列組合算出來

show series from mem


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女