huksley / prometheus-remote-write

Send samples to prometheus via remote_write from NodeJS
MIT License
20 stars 6 forks source link

Failed successfully #6

Closed vinistoisr closed 6 months ago

vinistoisr commented 6 months ago

with verbose and timing set to true, I get the following response when writing timeseries data:

Failed to send write request, error 204 No Content  { timeseries: [ { labels: [Array], samples: [Array] } ] }
Serialized in 1 ms

but the data is indeed written successfully to the db.

index.js seems to treat http status 204 as a failure.

Changing the segment to include status 204 along with 200 as a successful response might be a fix?

if (options?.verbose && r.status != 200 && r.status != 204) {
    logger.warn("Failed to send write request, error", r.status + " " + r.statusText + " " + text, writeRequest);
} else if (options?.verbose) {
    if (options?.timing) {
        logger.info(
            "Write request sent",
            r.status + " " + r.statusText + " in",
            Date.now() - start2,
            "ms",
            writeRequest
        );
    } else {
        logger.info("Write request sent", r.status + " " + r.statusText + " " + text, writeRequest);
    }
}

https://github.com/huksley/prometheus-remote-write/blob/63a391dfcd6daf12e013acf3bf7d6288b79440af/index.js#L111

huksley commented 6 months ago

hmm, which provider you use?

vinistoisr commented 6 months ago

I'm writing to VictoriaMetrics vm_agent according to these docs https://docs.victoriametrics.com/vmagent/#prometheus-remote_write-proxy

huksley commented 6 months ago

Published npmjs package 0.4.1, could you test?

vinistoisr commented 6 months ago

thank you, that solved the issue.