A minimal monitoring tool
Go to file
Ian Fijolek b2d9882c91
All checks were successful
continuous-integration/drone/push Build is passing
Update readme with accurate To do status
2019-11-15 17:17:46 -08:00
test Add more config validation 2019-10-07 10:48:19 -07:00
.drone.yml Add a build step to drone pipeline 2019-10-07 15:02:13 -07:00
.gitignore Add mod and Makefile to speed development 2019-10-03 12:56:03 -07:00
alert_test.go Add alert tests 2019-10-03 16:30:49 -07:00
alert.go Add debug flag to adjust log verbosity a bit 2019-10-04 16:05:25 -07:00
config_test.go Add more config validation 2019-10-07 10:48:19 -07:00
config.go Add prometheus metrics exporter 2019-11-15 17:14:20 -08:00
Dockerfile First go at Docker builds 2019-10-10 17:20:42 -07:00
Dockerfile.multi-stage First go at Docker builds 2019-10-10 17:20:42 -07:00
go.mod Add prometheus metrics exporter 2019-11-15 17:14:20 -08:00
go.sum Add prometheus metrics exporter 2019-11-15 17:14:20 -08:00
LICENSE Initial commit 2019-09-21 22:01:12 +00:00
main_test.go Move panics up to main function 2019-10-04 16:17:36 -07:00
main.go Add prometheus metrics exporter 2019-11-15 17:14:20 -08:00
Makefile Add prometheus metrics exporter 2019-11-15 17:14:20 -08:00
metrics.go Add prometheus metrics exporter 2019-11-15 17:14:20 -08:00
monitor_test.go Update test to be less environment dependent 2019-10-07 15:53:41 -07:00
monitor.go Make AlertDown required for a Monitor 2019-10-04 16:23:48 -07:00
README.md Update readme with accurate To do status 2019-11-15 17:17:46 -08:00
sample-config.yml WIP 2019-09-21 15:03:26 -07:00
util_test.go Refactor a bit more for testing, update tests 2019-10-04 14:47:38 -07:00
util.go Refactor a bit more for testing, update tests 2019-10-04 14:47:38 -07:00

minitor-go

A reimplementation of Minitor in Go

Minitor is already a minimal monitoring tool. Python 3 was a quick way to get something live, but Python itself comes with a large footprint. Thus Go feels like a better fit for the project, longer term.

Initial target is meant to be roughly compatible requiring only minor changes to configuration. Future iterations may diverge to take advantage of Go specific features.

Differences from Python version

There are a few key differences between the Python version and the v0.x Go version.

First, configuration keys cannot have multiple types in Go, so a different key must be used when specifying a Shell command as a string rather than a list of args. Instead of command, you must use command_shell. Eg:

minitor-py:

monitors:
  - name: Exec command
    command: ['echo', 'test']
  - name: Shell command
    command: echo 'test'

minitor-go:

monitors:
  - name: Exec command
    command: ['echo', 'test']
  - name: Shell command
    command_shell: echo 'test'

Second, templating for Alert messages has been updated. In the Python version, str.format(...) was used with certain keys passed in that could be used to format messages. In the Go version, we use a struct containing Alert info and the built in Go templating format. Eg.

minitor-py:

alerts:
  log_command:
    command: ['echo', '{monitor_name}']
  log_shell:
    command_shell: 'echo {monitor_name}'

minitor-go:

alerts:
  log_command:
    command: ['echo', '{{.MonitorName}}']
  log_shell:
    command_shell: 'echo {{.MonitorName}}'

Finally, newlines in a shell command don't terminate a particular command. Semicolons must be used and continuations should not.

minitor-py:

alerts:
  log_shell:
    command_shell: >
      echo "line 1"
      echo "line 2"
      echo "continued" \
        "line"      

minitor-go:

alerts:
  log_shell:
    command_shell: >
      echo "line 1";
      echo "line 2";
      echo "continued"
        "line"      

To do

There are two sets of task lists. The first is to get rough parity on key features with the Python version. The second is to make some improvements to the framework.

Pairity:

  • Run monitor commands
  • Run monitor commands in a shell
  • Run alert commands
  • Run alert commands in a shell
  • Allow templating of alert commands
  • Implement Prometheus client to export metrics
  • Test coverage

Improvement (potentially breaking):

  • Implement leveled logging (maybe glog or logrus)
  • Consider switching from YAML to TOML
  • Consider value of templating vs injecting values into Env variables
  • Consider dropping alert_up and alert_down in favor of using Go templates that offer more control of messaging
  • Async checking
  • Use durations rather than seconds checked in event loop
  • Revisit metrics and see if they all make sense