Send data
Other languages
Send logs to the HTTP ingest API from shell, Python, Go, Ruby and PHP with the standard library only.
There is an official SDK for Node.js only. Every other language can use the HTTP ingest API directly, or an OpenTelemetry logs exporter if you already use OpenTelemetry.
Each example sends one batch with an Idempotency-Key, so retrying the same request is safe. In production, buffer lines and send them in batches of up to 5,000 events or 5 MiB, once a second or so. See Limits and batching.
All examples read the token from ZEVSIGHT_INGEST_KEY.
Shell (curl)
curl -fsS -X POST https://ingest.zevsight.com/v1/ingest/events \
-H "Authorization: Bearer $ZEVSIGHT_INGEST_KEY" \
-H "Content-Type: application/x-ndjson" \
--data-binary @- <<'NDJSON'
{"service":"backup","environment":"production","type":"log","severity":"info","body":{"message":"backup started"}}
{"service":"backup","environment":"production","type":"log","severity":"info","body":{"message":"backup finished"},"attrs":{"size_mb":"812"}}
NDJSON
Python
import json, os, uuid, urllib.request
events = [{
"service": "worker",
"environment": "production",
"type": "log",
"severity": "error",
"attrs": {"queue": "emails"},
"body": {"message": "job failed", "fields": {"job_id": 1234}},
}]
req = urllib.request.Request(
"https://ingest.zevsight.com/v1/ingest/events",
data=json.dumps({"events": events}).encode(),
headers={
"Authorization": "Bearer " + os.environ["ZEVSIGHT_INGEST_KEY"],
"Content-Type": "application/json",
"Idempotency-Key": str(uuid.uuid4()),
},
method="POST",
)
with urllib.request.urlopen(req, timeout=15) as res:
print(res.status, json.load(res)) # 202 {'accepted': 1, 'rejected': []}
Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
"time"
)
func main() {
payload, _ := json.Marshal(map[string]any{
"events": []map[string]any{{
"service": "api",
"environment": "production",
"type": "log",
"severity": "warn",
"ts": time.Now().UTC().Format(time.RFC3339Nano),
"attrs": map[string]string{"route": "/v1/pay"},
"body": map[string]any{"message": "slow upstream", "fields": map[string]any{"ms": 2300}},
}},
})
req, _ := http.NewRequest("POST", "https://ingest.zevsight.com/v1/ingest/events", bytes.NewReader(payload))
req.Header.Set("Authorization", "Bearer "+os.Getenv("ZEVSIGHT_INGEST_KEY"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Idempotency-Key", fmt.Sprintf("api-%d", time.Now().UnixNano()))
res, err := (&http.Client{Timeout: 15 * time.Second}).Do(req)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
defer res.Body.Close()
fmt.Println(res.Status) // 202 Accepted
}
Ruby
require "json"
require "net/http"
require "securerandom"
uri = URI("https://ingest.zevsight.com/v1/ingest/events")
body = { events: [{
service: "web", environment: "production", type: "log", severity: "info",
attrs: { controller: "orders" },
body: { message: "order placed", fields: { order_id: 42 } }
}] }
res = Net::HTTP.post(uri, body.to_json,
"Authorization" => "Bearer #{ENV.fetch('ZEVSIGHT_INGEST_KEY')}",
"Content-Type" => "application/json",
"Idempotency-Key" => SecureRandom.uuid)
puts res.code # 202
PHP
<?php
$payload = json_encode(['events' => [[
'service' => 'web',
'environment' => 'production',
'type' => 'log',
'severity' => 'error',
'attrs' => ['route' => '/checkout'],
'body' => ['message' => 'card declined', 'fields' => ['code' => 'do_not_honor']],
]]]);
$ch = curl_init('https://ingest.zevsight.com/v1/ingest/events');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ZEVSIGHT_INGEST_KEY'),
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
]);
$body = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), ' ', $body, PHP_EOL; // 202 {"accepted":1,...}
Docker containers (Vector)
To ship every container’s output without changing the apps, run Vector with an NDJSON HTTP sink:
[sources.docker]
type = "docker_logs"
[transforms.zevsight_shape]
type = "remap"
inputs = ["docker"]
source = '''
. = {
"service": replace(string!(.container_name), r'^/', ""),
"environment": "production",
"type": "log",
"severity": "info",
"body": { "message": .message },
"attrs": { "image": .image, "stream": .stream }
}
'''
[sinks.zevsight]
type = "http"
inputs = ["zevsight_shape"]
uri = "https://ingest.zevsight.com/v1/ingest/events"
method = "post"
encoding.codec = "json"
framing.method = "newline_delimited"
request.headers.Content-Type = "application/x-ndjson"
auth.strategy = "bearer"
auth.token = "${ZEVSIGHT_INGEST_KEY}"
Retry rules for your own client
- Retry on network errors,
408,429,5xx. Wait forRetry-Afterwhen it is present, otherwise back off exponentially. - Do not retry
400,401or413. Fix the request instead. - On
421 WRONG_REGION, switch to the host in the response’sendpointfield. - Keep the same
Idempotency-Keyor eventids when you retry.
Built 29 November 2026 · View as Markdown