REST API
Added in version 0.13
REST API is supported since version 0.13. Make sure you're using the latest version of Logdy.
This is a documentation of the REST API that is exposed for Logdy instance. The endpoints documented on this page will be only accessible after you define an ApiKey
config parameter, either via CLI or Go Code.
Authorization
API requests made to Uptime API are authorized using a Bearer Authentication standard. That means you'll only need to add a header with Authorization: Bearer $TOKEN
to your requests.
API Token is defined during startup through command line argument or via config object
TIP
If you're running Logdy in the code embedded mode and you're using a path prefix. Then you need to add that prefix to the path. Example: Logdy running on http://localhost:8080/logdy-ui
, the logging endpoint will be http://localhost:8080/logdy-ui/api/log
POST /api/log
Allows you to send log message(s) to Logdy instance.
Request - body parameters
logs
(array of objects) - required
A list of objects, each one representing a log message.
Properties of
logs
ts
string or number By default, the time of the event will be the time of receiving it. You can override this by including a field ts containing the event time either as:
Number UNIX time in milliseconds 1720645064500
String formatted according to RFC 3339. 2024-06-31T23:59:59.123456Z, 2022-12-31 13:45:59.123456+02:00
log
string or object A log message, could be either string or an object.
source
(string)
An identifier that will be appended to every log message and displayed in the source
part (message drawer in the UI). You can use this field to identify messages coming from different sources.
Example body parameters
{
"logs": [
{
"ts": 1720645064500,
"log": {
"foo": "bar"
}
},
{
"ts": 1720645064501,
"log": "string message"
}
],
"source": "machine identifier"
}
Responses
http code | content-type | response |
---|---|---|
202 | application/json | |
400 | application/json | {"error": "error here"} |
401 | application/json | {"error": "error here"} |
405 | application/json | {"error": "error here"} |
500 | application/json | {"error": "error here"} |
Example cURL
Example sending log as a string
TIP
The examples below assume you're running Logdy locally on port 8080
and don't use path prefix.
curl --location --request POST 'localhost:8080/api/log' \
--header 'Authorization: Bearer foobar' \
--header 'Content-Type: application/json' \
--data '{"logs": [{"log": "this is a log message as a string" }],"source":"machine identifier"}'
Example sending log as a string JSON
curl --location --request POST 'localhost:8080/api/log' \
--header 'Authorization: Bearer foobar' \
--header 'Content-Type: application/json' \
--data '{"logs": [{"log": {"value": "json fits here too"} }],"source":"machine identifier"}'