package
1.5.2
Repository: https://github.com/vogo/logtail.git
Documentation: pkg.go.dev

# README

logtail web API

1. Transfer API

1.1 list transfer types

curl --request GET 'http://localhost:54321/manage/transfer/types'

# ["null","console","file","webhook","ding","lark"]

1.2 list transfers

curl --request GET 'http://localhost:54321/manage/transfer/list'

1.3 add transfer

# add null transfer
curl --request POST 'http://localhost:54321/manage/transfer/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "null",
    "type": "null"
}'

# add console transfer
curl --request POST 'http://localhost:54321/manage/transfer/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "console",
    "type": "console"
}'

# add file transfer
curl --request POST 'http://localhost:54321/manage/transfer/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "logtail-file",
    "type": "file",
    "dir": "/opt/logs"
}'

# add dingtalk transfer
curl --request POST 'http://localhost:54321/manage/transfer/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "ding-notice-robot",
    "type": "ding",
    "url": "https://oapi.dingtalk.com/robot/send?access_token=<token>"
}'

# add lark(known as feisu) transfer
curl --request POST 'http://localhost:54321/manage/transfer/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "lark-notice-robot",
    "type": "lark",
    "url": "https://oapi.dingtalk.com/robot/send?access_token=<token>"
}'

# add webhook transfer
curl --request POST 'http://localhost:54321/manage/transfer/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "my-webhook-service",
    "type": "webhook",
    "url": "http://127.0.0.1:9000/logtail"
}'

1.4 delete transfer

delete transfer by given name:

curl --request POST 'http://localhost:54321/manage/transfer/delete' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "console",
}'

2. Router API

2.1 list routers

curl --request GET 'http://localhost:54321/manage/router/list'

2.2 add router

add a router, if message contains ERROR, while not contains Invalid and NotFound, then transfer the message to these transfers console and logtail-file.

curl --request POST 'http://localhost:54321/manage/router/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "error-router",
    "matchers": [
         {
            "contains": ["ERROR"], 
            "not_contains":["Invalid","NotFound"]
         }
    ],
    "transfers": ["console","logtail-file"]
}'

2.3 delete router

delete router by given name:

curl --request POST 'http://localhost:54321/manage/router/delete' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "error-router"
}'

3. Server API

3.1 list server types

curl --request GET 'http://localhost:54321/manage/server/types'

# ["command","commands","command_gen","file"]

3.2 list servers

curl --request GET 'http://localhost:54321/manage/server/list'

3.3 add server

# add server to get data stream from a command
curl --request POST 'http://localhost:54321/manage/server/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "my-service-log-server",
    "routers": ["error-router"],
    "command": "tail -f /logs/my-service/my-service.log"
}'

# add server to get data stream from multiple commands, which are split by the new line char `\n`, defined by key `commands`. 
curl --request POST 'http://localhost:54321/manage/server/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "my-service-log-server",
    "routers": ["error-router"],
    "commands": "tail -f /logs/app/app1.log\ntail -f /logs/app/app2.log\ntail -f /logs/app/app3.log"
}'

# add server to get data stream from multiple commands, which are generated by other command defined by key `command_gen`. 
curl --request POST 'http://localhost:54321/manage/server/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "my-service-log-server",
    "routers": ["error-router"],
    "command_gen": "/app/tail-logs-commands.sh"
}'

# add server to get data stream from files under given directory defined by `file`. 
curl --request POST 'http://localhost:54321/manage/server/add' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "my-service-log-server",
    "routers": ["error-router"],
    "file": { "path": "/logs/k8s_logs/service-app1/", "recursive": true, "suffix": ".log","method":"timer"}
}'
# The value of method could be `os` or `timer`:
# - os: using os file system api to monitor file changes
# - timer: interval check file stat to check file changes

3.4 delete server

delete server by given name:

curl --request POST 'http://localhost:54321/manage/server/delete' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "my-service-log-server"
}'

# Functions

Serve web api routers: - `/index/<server-id>`: server index page - `/tail/<server-id>`: server tailing api - `/manage/<op>`: manage page - else route to default server list page.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
URIRouterIndex uri index router.
URIRouterManage uri manage router.
URIRouterTail uri tail router.
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author