当前位置:网站首页>DataKit 作为本地获取数据的 API 服务器
DataKit 作为本地获取数据的 API 服务器
2022-06-29 15:33:00 【InfoQ】
概述
前置条件
交互模型数据查询 “DQL查询”
datakit --dql # 或者 datakit -Q
dql > cpu limit 1
-----------------[1.cpu ]-----------------
cpu 'cpu-total'
host'tan-air.local'
time2022-01-13 16:06:03 +0800 CST
usage_irq 0
usage_idle 56.928839
usage_nice 0
usage_user 19.825218
usage_guest 0
usage_steal 0
usage_total 43.071161
usage_iowait 0
usage_system 23.245943
usage_softirq 0
usage_guest_nice 0
---------
1 rows, cost 13.55119ms单次执行 DQL 查询
# 单次执行一条查询语句
datakit --run-dql 'cpu limit 1'
# 将执行结果写入 CSV 文件
datakit --run-dql 'O::HOST:(os, message)' --csv="path/to/your.csv"
# 强制覆盖已有 CSV 文件
datakit --run-dql 'O::HOST:(os, message)' --csv /path/to/xxx.csv --force
# 将结果写入 CSV 的同时,在终端也显示查询结果
datakit --run-dql 'O::HOST:(os, message)' --csv="path/to/your.csv" --vvvname,active,available,available_percent,free,host,time
mem,2016870400,2079637504,24.210166931152344,80498688,achen.local,1635242524385
mem,2007961600,2032476160,23.661136627197266,30900224,achen.local,1635242534385
mem,2014437376,2077097984,24.18060302734375,73502720,achen.local,1635242544382DQL查询结果JSON化
datakit --run-dql 'O::HOST:(os, message)' --json
datakit -Q --json
# 如果字段值是 JSON 字符串,则自动做 JSON 美化(注意:JSON 模式下(即 --json),`--auto-json` 选项无效)
datakit --run-dql 'O::HOST:(os, message)' --auto-json
-----------------[ r1.HOST.s1 ]-----------------
message ----- json ----- # JSON 开始处有明显标志,此处 message 为字段名
{
"host":{
"meta":{
"host_name":"www",
.... # 此处省略长文本
"config":{
"ip":"10.100.64.120",
"enable_dca": false,
"http_listen":"localhost:9529",
"api_token":"tkn_f2b9920f05d84d6bb5b14d9d39db1dd3"
}
}
----- end of json ----- # JSON 结束处有明显标志
os 'darwin'
time2022-01-13 16:56:22 +0800 CST
---------
8 rows, 1 series, cost 4ms查询特定工作空间的数据
datakit --run-dql 'O::HOST:(os, message)' --token <your-token>
datakit -Q --token <your-token>DataKit API
边栏推荐
- c#Sqlite类库
- MySQL 数据库命名规范.PDF
- 动作捕捉系统用于苹果采摘机器人
- SSL V**技术原理
- Symfony framework security component firewall configuration
- MySQL JSON array operation JSON_ array_ append、json_ array_ insert
- Summary of recent work
- Paging SQL (rownum, row_number, deny_rank, rank)
- MCS: discrete random variable - binomial distribution
- 极化SAR地表分类
猜你喜欢

12.udp protocol -bite

Unity C basic review 28 - delegation with return (p449)

Andorid Jetpack Hilt

Classe d'outils commune de fichier, application liée au flux (enregistrement)

Motion capture system for apple picking robot

Building SQL statements in Excel

MCS: discrete random variable - Hyper geometric distribution

Excel中构建SQL语句

MCS: multivariate random variable polynomial distribution

89.(cesium篇)cesium聚合图(自定义图片)
随机推荐
华为云AOM 2.0版本发布
MySQL development specification pdf
Mingdeyang xilinx-k7-325t/410t core board data manual
深度学习遥感数据集
13.TCP-bite
Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen
欧标插头EN50075测试项目
Neural network for remote sensing image processing
Several imaging modes of polarimetric SAR
"Game engine shallow in shallow out" 98 Substancepainer plug-in development
JD health responded that it planned to acquire JD assets with us $355.4 million: related to pet health product category
如何用好数据科学?
数据挖掘复习
Unity C basic review 27 - delegation example (p448)
复数卷积神经网络:CV-CNN
Imgutil image processing tool class, text extraction, image watermarking
El table column row button anti weight control loading
Unity C # basic review 26 - first acquaintance Commission (p447)
PostgreSQL source code learning (25) -- transaction log ⑥ - wait for log writing to complete
极化SAR地表分类