package
0.1.0
Repository: https://github.com/nanopack/logvac.git
Documentation: pkg.go.dev

# README

logvac logo
Build Status

Logvac

Simple, lightweight, api-driven log aggregation service with realtime push capabilities and historical persistence.

Routes:

RouteDescriptionPayloadOutput
Get /remove-tokenRemove a log read/write token*'X-USER-TOKEN' and 'X-AUTH-TOKEN' headerssuccess message string
Get /add-tokenAdd a log read/write token*'X-USER-TOKEN' and 'X-AUTH-TOKEN' headerssuccess message string
Post /Post a log*'X-USER-TOKEN' header and json Log objectsuccess message string
Get /List all services*'X-USER-TOKEN' headerjson array of Log objects
Note: * = only if 'auth-address' configured

Query Parameters:

ParameterDescription
authReplacement for 'X-USER-TOKEN'
idFilter by id
tagFilter by tag
typeFilter by type
startStart time (unix epoch(nanoseconds)) at which to view logs older than (defaults to now)
endEnd time (unix epoch(nanoseconds)) at which to view logs newer than (defaults to 0)
limitNumber of logs to read (defaults to 100)
levelSeverity of logs to view (defaults to 'trace')
?id=my-app&tag=apache%5Berror%5D&type=deploy&start=0&limit=5

Data types:

Log:

{
  "id": "my-app",
  "tag": "build-1234",
  "type": "deploy",
  "priority": "4",
  "message": "$ mv nanobox/.htaccess .htaccess\n[✓] SUCCESS"
}
FieldDescription
timeTimestamp of log (time.Now() on post)
idId or hostname of sender
tagTag for log
typeLog type (commonly 'app' or 'deploy'. default value configured via log-type)
prioritySeverity of log (0(trace)-5(fatal))
message*Log data
Note: * = required on submit

Usage

add auth key - attempt

$ curl -ik https://localhost:1234/add-key -H 'X-USER-TOKEN: user'
HTTP/1.1 401 Unauthorized

add auth key - success

$ curl -ik https://localhost:1234/add-key -H 'X-USER-TOKEN: user' -H 'X-AUTH-TOKEN: secret'
HTTP/1.1 200 OK

publish log - attempt

$ curl -ik https://localhost:1234 -d '{"id":"my-app","type":"deploy","message":"$ mv nanobox/.htaccess .htaccess\n[✓] SUCCESS"}'
HTTP/1.1 401 Unauthorized

publish log - success

$ curl -ik https://localhost:1234 -H 'X-USER-TOKEN: user' -d '{"id":"my-app","type":"deploy","message":"$ mv nanobox/.htaccess .htaccess\n[✓] SUCCESS"}'
sucess!
HTTP/1.1 200 OK

get deploy logs

$ curl -k https://localhost:1234?kind=deploy -H 'X-USER-TOKEN: user'
[{"time":"2016-03-07T15:48:57.668893791-07:00","id":"my-app","tag":"","type":"deploy","priority":0,"message":"$ mv nanobox/.htaccess .htaccess\n[✓] SUCCESS"}]

get app logs

$ curl -k https://localhost:1234 -H 'X-USER-TOKEN: user'
[]

Contributing

Contributions to the logvac project are welcome and encouraged. Logvac is a Nanobox project and contributions should follow the Nanobox Contribution Process & Guidelines.

Licence

Mozilla Public License Version 2.0

open source

# Functions

GenerateArchiveEndpoint generates the endpoint for fetching filtered logs note: javascript number precision may cause unexpected results (missing logs within 100 nanosecond window).
Start starts the web server with the logvac functions.