VictoriaMetrics集群中CSV格式的增加和删除应用实例

=================csv格式数据导入VM和查询指导=====================
注意:记得将IP、端口和索引根据实际情况要变动一下,实例中使用的索引为:55,端口为:8999

数据导入命令:
例:将metric名为:testforcsv,携带标签和值对:ticker:suibian,本指标值为:8 的一条数据导入VM中(注意前后数据或值要一一对应)
curl -d "suibian,8" 'http://x.x.x.x:8999/insert/55/prometheus/api/v1/import/csv?format=1:label:ticker,2:metric:testforcsv'
查询:
curl -G 'http://x.x.x.x:8999/select/55/prometheus/api/v1/export' -d 'match[]={ticker!=""}'
获得结果:
{"metric":{"__name__":"testforcsv","ticker":"suibian"},"values":[8],"timestamps":[1592368322384]}

导入携带时间的数据:(时间为毫秒级)
curl -d "renyi,6,1592300000000" 'http://x.x.x.x:8999/insert/55/prometheus/api/v1/import/csv?format=1:label:ticker,2:metric:testforcsv2,3:time:unix_ms'
查询:
curl -g 'http://x.x.x.x:8999/select/55/prometheus/api/v1/export' --data-urlencode 'match[]=testforcsv2'

升级用法:多个指标、多个标签的导入
curl -d "GOOG,1.23,4.56,NYSE" 'http://x.x.x.x:8999/insert/55/prometheus/api/v1/import/csv?format=2:metric:ask,3:metric:bid,1:label:ticker,4:label:market'
查询:
curl -G 'http://x.x.x.x:8999/select/55/prometheus/api/v1/export' -d 'match[]={ticker!=""}'
获得结果:
{"metric":{"__name__":"bid","market":"NYSE","ticker":"GOOG"},"values":[4.56],"timestamps":[1592367647023]}
{"metric":{"__name__":"ask","market":"NYSE","ticker":"GOOG"},"values":[1.23],"timestamps":[1592367647023]}
或指定metric名进行查询
curl -g 'http://x.x.x.x:8999/select/55/prometheus/api/v1/export' --data-urlencode 'match[]=bid'

猜你喜欢

转载自www.cnblogs.com/qinshizhishi/p/13163027.html