VictoriaMetric cluster版本试用

1、下载代码

2、对vminsert、vmstroage、vmselect分别go build后启动(使用默认端口号)

 ./vmstorage -storageDataPath=/mnt/d/test/vm(对外端口8482)
 ./vminsert -storageNode=127.0.0.1:8400(对外端口8480)
 ./vmselect -storageNode=127.0.0.1:8401(对外端口8481)

3、prometheus配置:

remote_write:
  - url: "http://localhost:8480/insert/0/prometheus/api/v1/write"

远程写入后本地仍然可以看到:http://localhost:9090/

本地prometheus启动:

 ./prometheus.exe --log.level=debug

(建议打开debug,上报格式错误的提示打印级别是debug)
另外需要注意promrtheus不认识回车符,如果信息里存在\r会提示:

invalid metric type \"summary\\r\""

需要手动去除(我是从文件读取的测试数据,所以存在回车符):

//pushgateway不认识\r
		replacedBuff := bytes.ReplaceAll(buff[:rlen], []byte{'\r'}, []byte{})

4、查询
从vmselect查询:

http://localhost:8481/select/0/prometheus/api/v1/query?query=go_goroutines

格式为http://:8481/select//prometheus/

从vmstorage查询:http://localhost:8482/metrics

5、其他方式写入
如果是prometheus客户端的格式直接写入的,比如:

# HELP vpp_interfaces_rx_errors RX errors
# TYPE vpp_interfaces_rx_errors gauge
vpp_interfaces_rx_errors{agent="vpp1",index="0",name="local0"} 0
vpp_interfaces_rx_errors{agent="vpp1",index="1",name="GigabitEthernet0/9/0"} 100
vpp_interfaces_rx_errors{agent="vpp1",index="2",name="loop0"} 20
vpp_interfaces_rx_errors{agent="vpp1",index="3",name="tap0"} 0
# HELP vpp_interfaces_tx_packets TX packets
# TYPE vpp_interfaces_tx_packets gauge
vpp_interfaces_tx_packets{agent="vpp1",index="0",name="local0"} 0
vpp_interfaces_tx_packets{agent="vpp1",index="1",name="GigabitEthernet0/9/0"} 25199
vpp_interfaces_tx_packets{agent="vpp1",index="2",name="loop0"} 1254
vpp_interfaces_tx_packets{agent="vpp1",index="3",name="tap0"} 37098

则使用:

http://localhost:8480/insert/0/prometheus/api/v1/import/prometheus

可以根据需要增加标签:

http://localhost:8480/insert/0/prometheus/api/v1/import/prometheus?extra_label=sn=123456

prometheus的remote write是snappy格式,使用如3所述url

对应查询使用:

http://localhost:8481/select/0/prometheus/api/v1/query?query=vpp_buffers_num_free

查询结果:

{"status":"success","isPartial":false,"data":{"resultType":"vector","result":[{"metric":{"__name__":"vpp_buffers_num_free","agent":"vpp1","index":"0","item":"default-numa-0","sn":"123456","threadID":"0"},"value":[1615972656,"0"]}]}}

注意:时间戳是victoriaMetrics打上的,即victoriaMetrics收到该结果的时间(猜测应该是vminsert干的)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值