prometheusmetricstelemetryvictoriametrics

VictoriaMetrics importing / backfilling historical data


I am attempting to import/backfill 6 months' worth of data (currently in CSV, but it can be formatted to any line protocol as necessary) files into VictoriaMetrics so that it can be visualized in Grafana. I have tried using to write API to push the historical metrics but the data doesn't show up. There are no errors or exceptions on the VictoriaMetrics logs and I can confirm the data isn't there either.

I created a docker-compose setup in my machine to investigate.

version: '3'
services:
  vmagent:
    image: victoriametrics/vmagent
    depends_on:
      - "victoriametrics"
    volumes:
      - ./docker/vmagent/prometheus.yml:/etc/prometheus/prometheus.yml
    command:
      - "--promscrape.config=/etc/prometheus/prometheus.yml"
      - "--remoteWrite.url=http://victoriametrics:8428/api/v1/write"

  victoriametrics:
    image: victoriametrics/victoria-metrics
    entrypoint: /victoria-metrics-prod -search.disableCache -search.cacheTimestampOffset=1440000m0s -retentionPeriod=1440000m0s
    ports:
      - "8428:8428"

  grafana:
    image: grafana/grafana-enterprise
    environment:
      GF_AUTH_DISABLE_LOGIN_FORM: "true"
      GF_AUTH_ANONYMOUS_ENABLED: "true"
      GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
    volumes:
      - ./docker/grafana/provisioning/:/etc/grafana/provisioning/
      - ./docker/grafana/dashboards/:/var/lib/grafana/dashboards/
    ports:
      - '3000:3000'

Example of API call

curl -X POST 'http://localhost:8428/write' -d 'measurement,label1="value1" lable2=32 1669258451474'
curl 'http://localhost:8428/internal/resetRollupResultCache'

Is this a valid approach?


Solution

  • Yes, this is valid approach, except that timestamps in Influx line protocol must be passed in nanoseconds by default acording to the specs. Just add 6 zeroes to the timestamp in the example above.

    You can ingest historical data into VictoriaMetrics via supported data ingestion protocols listed here. See docs below with examples on how to ingest data into VictoriaMetrics via supported protocols:

    You can check whether the data is successfully ingested by querying it via export API - see these docs.

    VictoriaMetrics returns "success" response when some ingested lines contain improperly formatted data, since other lines may contain correct data, so they are successfully ingested into VictoriaMetrics. So it is also recommended looking into VictoriaMetrics logs during data ingestion, since VictoriaMetrics logs all data ingestion errors there.