地址为实例的 IP 和 PORT,可从控制台获取到,例如10.13.20.15:9200。
/_metric/${metric_name}
,${metric_name}
为新建的 metric 的名称。说明:
metric
命名限制请参见 系统限制。
无
参数名称 | 必选 | 类型 | 描述 |
---|---|---|---|
tags | 是 | map | 维度列,用于唯一标识数据,须至少包含一个维度,支持的数据类型:text(带有分词、全文索引的字符串)、string(不分词的字符串)、long、integer、short、byte、double、float、date、boolean。 格式如 {"region": "string","set": "long","host": "string"} |
time | 是 | map | 时间列相关配置,用于存储数据入库的唯一时间,例如{"name": "timestamp", "format": "epoch_second"} ,若不填则系统默认格式为{"name": "timestamp", "format": "epoch_millis"} |
fields | 否 | map | 数据列,用于存储数据,为了节省空间,建议使用最适合实际业务使用的类型,支持的数据类型:string(字符串)、long、integer、short、byte、double、float、date、boolean。 例如 {"cpu_usage":"float"} |
options | 否 | map | 常用的调优配置信息 例如 {"expire_day":7,"refresh_interval":"10s","number_of_shards":5,"number_of_replicas":1,"rolling_period":1,"max_string_length": 256,"default_date_format":"strict_date_optional_time","indexed_fields":["host"]} |
过期时间 | 子表时长 |
---|---|
≤ 7天 | 1天 |
> 7天,≤ 20天 | 3天 |
> 20天,≤ 49天 | 7天 |
> 49天,≤ 3个月 | 15天 |
>3个月 | 30天 |
永不过期 | 30天 |
需要通过 error 字段判断请求是否成功,若返回内容有 error 字段则请求失败,具体错误详情请参照 error 字段描述。
请求:
curl -u root:le201909 -H 'Content-Type:application/json' -X PUT 172.16.345.14:9201/_metric/ctsdb_test -d'
{
"tags":
{
"region":"string"
},
"time":
{
"name":"timestamp",
"format":"epoch_second"
},
"fields":
{
"cpuUsage":"float"
},
"options":
{
"expire_day":7,
"refresh_interval":"10s",
"number_of_shards":5
}
}
'
成功的返回:
{
"acknowledged": true,
"message": "create ctsdb metric ctsdb_test success!"
}
失败的返回:
{
"error": {
"reason": "table ctsdb_test already exist",
"type": "metric_exception"
},
"status": 201
}
本页内容是否解决了您的问题?