Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


VictoriaMetrics Ingest Historical Data

26 Apr 2021 »

https://stackoverflow.com/questions/65751105/how-to-push-prometheus-metrics-directly-to-victoriametrics https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/README.md#how-to-import-csv-data

import requests
import datetime

url = "http://localhost:8428/api/v1/import/csv"
now = int(datetime.datetime.now().timestamp())*1000)

params = {
	"format": ",".join([
		f"1:label:ServiceID",
		"2:metric:MSGs",
		"3:time:unix_ms",
	])
}

data = f"A,10,{now}"

rs = requests.post(url, params=params, data=data)

print(rs.text) # empty