├── .gitignore ├── Makefile ├── README.md ├── assets ├── .prettierrc ├── events.html ├── htmx.min.js ├── layout.html ├── monitors.html ├── output.css ├── package-lock.json ├── package.json ├── row.html ├── styles.css └── tailwind.config.js ├── cmd └── tevents │ └── main.go ├── db ├── db.go └── schema.sql ├── event.go ├── go.mod ├── go.sum ├── http.go ├── http_test.go ├── notifier.go └── screenshots └── events-monitors.png /.gitignore: -------------------------------------------------------------------------------- 1 | db.sqlite 2 | node_modules 3 | ./tevents 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | 3 | all: tailwind 4 | go build ./cmd/tevents 5 | 6 | run: 7 | go run ./cmd/tevents 8 | 9 | watch: 10 | nodemon --watch '*' -e html,go --exec go run ./cmd/tevents --signal SIGTERM 11 | 12 | tailwind: 13 | cd assets && npx tailwindcss -i ./styles.css -o ./output.css 14 | 15 | tailwind-watch: 16 | cd assets && npx tailwindcss -i ./styles.css -o ./output.css --watch 17 | 18 | test: 19 | go test ./... 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tevents 2 | 3 | tevents is a small tool to be deployed in your [tailnet](https://tailscale.com/kb/1136/tailnet/) to collect events/hooks from other services. 4 | By using [tsnet](https://tailscale.com/blog/tsnet-virtual-private-services/), it can be deployed as a virtual private service. This allows to centrally collect 5 | events in your network and display them on a web interface. 6 | 7 |  8 | 9 | ## Usage 10 | 11 | All required resources are embedded in the executable. 12 | 13 | ``` 14 | git clone github.com/rverton/tevents 15 | cd tevents && make 16 | export TS_AUTHKEY=tskey-auth-xyu # can be retrieved via admin panel 17 | go build -o tevents ./cmd/tevents 18 | ./tevents # all assets are embedded in this binary 19 | ``` 20 | 21 | ## Events 22 | An event holds the following fields: 23 | 24 | ``` 25 | origin: (unique) identifier of the sender 26 | type: type of the event (event or monitor-event) 27 | body: content 28 | owner: tailnet owner who send the event 29 | ``` 30 | 31 | There are two different types of events: 32 | 33 | - Log events are simple one-time HTTP requests to to notify of a specific event. 34 | - Monitor events are events that are sent periodically and allow you to graph execution. This allows for example to watch cron jobs for execution. 35 | 36 | ## Submission 37 | 38 | Events can be submitted via HTTP POST. 39 | 40 | ``` 41 | # example for log event 42 | curl http://tevents/.log?origin=networkwatcher -d "new device found connected to network" 43 | 44 | # example for monitoring a cron job executed every morning 45 | 0 1 * * * /usr/local/bin/backup.sh && curl -X POST http://tevents/.monitor?origin=cron:backup 46 | ``` 47 | 48 | ## Development 49 | 50 | All relevant tasks can be done via `make`: 51 | 52 | ``` 53 | make watch # restart web server on code changes 54 | make tailwind-watch # watch tailwind css changes 55 | make tailwind # only build tailwind resources 56 | make run # run web server 57 | make test # run all tests 58 | make # build executable with all assets embedded 59 | ``` 60 | 61 | ### ToDo 62 | 63 | - [ ] Add tests for event/monitor hook handler 64 | - [ ] Make hour interval configurable 65 | - [ ] Filter, search and pagination 66 | - [ ] Allow to remove monitors (and all corresponding events) 67 | - [x] Clear functionality 68 | -------------------------------------------------------------------------------- /assets/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "overrides": [ 3 | { 4 | "files": ["*.html"], 5 | "options": { 6 | "parser": "go-template" 7 | } 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /assets/events.html: -------------------------------------------------------------------------------- 1 | {{ define "main" }} 2 |