Sending data to Obics via HTTP
To send logs directly with Obics HTTP REST API, use the following endpoint:
POST ingest.obics.io/api/v1/ingest
Request headers should include x-api-key
with your Ingest API Key.
The body can be a single log object or an array of logs.
Set the following fields:
message: string
- Required. Text or json with the main contents.time: unit time in milliseconds
- Optional. If empty, it will be filled with the time received on the server.level: number
- Optional. If empty, it will be filled3
(INFO). See the log levels reference.- Any other fields you want in your logs.
Tip
See recommended best practices for building a logging schema with Obics.
There's no need to create an initial table. Obics will create a Logs
table if such doesn't exist on first ingestion.
There's no need to define a column schema. Obics will create columns dynamically whenever new columns are sent. Types will be determined automatically.
Examples
1. A request body content with a single log:
{
"message": "Checkout service startup finished",
"level": 3
"time": 1731056050902
"host": "example.com"
"service": "checkout"
}
2. Multiple events body content:
[
{
"level": 3,
"message": "This is the first log event",
"time": 1699440040000,
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"spanId": "00f067aa0ba902b7",
"serviceName": "my-service"
},
{
"level": 4,
"message": "There was an error. Exception message: NullReferenceException",
"time": 1699440040500,
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"spanId": "00f067aa0ba902b7",
"serviceName": "my-service"
},
{
"level": 3,
"message": "Returning null after exception",
"time": 1699440040600,
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"spanId": "00f067aa0ba902b7",
"serviceName": "my-service"
}
]
3. curl
command:
curl -X POST https://ingest.obics.io/api/v1/ingest \
-H "Content-Type: application/json" \
-H "x-api-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
-d '{"message": "Something happened"}'
4. JavaScript code using fetch
:
const response = await fetch(https://ingest.obics.io/api/v1/ingest, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
},
body: JSON.stringify({
message: 'Something happened'
})
});;