Compare commits

..

14 Commits

Author SHA1 Message Date
Ian Fijolek
e262afdb1f Merge branch 'master' into next-major 2026-01-13 21:45:27 -08:00
Renovate Bot
a5268ae1f6 Update actions/setup-python action to v6 2026-01-14 05:45:09 +00:00
Renovate Bot
16ad16d873 Update actions/setup-go action to v6 2026-01-14 05:44:37 +00:00
Ian Fijolek
f4fb75610a Update variable interpolation for hcl 2026-01-13 21:43:57 -08:00
Ian Fijolek
0ae7c6dbdf Update default config file to config.hcl 2026-01-13 21:43:03 -08:00
Ian Fijolek
a06ed3540c Remove extra spaces in Makefile 2026-01-13 21:13:19 -08:00
Renovate Bot
200cfd1a2d Update actions/checkout action to v6 2026-01-07 00:02:31 +00:00
Ian Fijolek
bcbac39cad Add migration instructions 2026-01-05 16:32:59 -08:00
Ian Fijolek
afacf40ec8 Update build to better detect tags and versions 2026-01-05 16:20:51 -08:00
Ian Fijolek
c18e9c8771 Update readme with better default descriptions 2025-12-11 16:41:17 -08:00
Ian Fijolek
eb2987d3bc Tidy again and update readme 2025-12-11 16:37:02 -08:00
Ian Fijolek
945c1b1ce0 Update module path to v2 2025-12-11 16:34:18 -08:00
Ian Fijolek
b0ea3dc6d4 Bump go version 2025-12-11 16:26:05 -08:00
Renovate Bot
0a7aab7030 Update actions/checkout action to v6 2025-12-12 00:02:32 +00:00
11 changed files with 69 additions and 34 deletions
+7 -9
View File
@@ -3,19 +3,17 @@ on:
push: push:
branches: branches:
- main - main
- master
tags: tags:
- "v*" - "v*"
pull_request: pull_request:
branches: branches:
- main - main
- master
jobs: jobs:
tests: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6
@@ -28,7 +26,7 @@ jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6
@@ -46,7 +44,7 @@ jobs:
needs: test needs: test
if: "${{ github.event_name != 'pull_request' }}" if: "${{ github.event_name != 'pull_request' }}"
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6
@@ -55,17 +53,17 @@ jobs:
- name: Build binaries - name: Build binaries
env: env:
VERSION: "${{ vars.REF_NAME }}" VERSION: "${{ github.REF_NAME }}"
run: make all run: make all
# Package binaries and create release if this is a tagged build # Package binaries and create release if this is a tagged build
- name: Compress binaries - name: Compress binaries
if: "${{ github.event_name == 'tag' }}" if: "${{ github.ref_type == 'tag' }}"
run: find ./dist -type f -executable -execdir tar -czvf {}.tar.gz {} \; run: find ./dist -type f -executable -execdir tar -czvf {}.tar.gz {} \;
- name: Upload release - name: Upload release
uses: https://gitea.com/actions/gitea-release-action@v1 uses: https://gitea.com/actions/gitea-release-action@v1
if: "${{ github.event_name == 'tag' }}" if: "${{ github.ref_type == 'tag' }}"
with: with:
files: |- files: |-
dist/*.tar.gz dist/*.tar.gz
@@ -89,6 +87,7 @@ jobs:
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
if: "${{ github.event_name != 'pull_request' }}"
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
@@ -108,6 +107,5 @@ jobs:
platforms: | platforms: |
linux/amd64 linux/amd64
linux/arm64 linux/arm64
linux/arm
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
Vendored
+1
View File
@@ -14,6 +14,7 @@
# User configuration # User configuration
config.yml config.yml
config.hcl
# Output binary # Output binary
minitor minitor
+48 -12
View File
@@ -17,7 +17,7 @@ I'm running a few small services and found Sensu, Consul, Nagios, etc. to all be
Install and execute with: Install and execute with:
```bash ```bash
go install github.com/iamthefij/minitor-go@latest go install github.com/iamthefij/minitor-go/v2@latest
minitor minitor
``` ```
@@ -50,15 +50,17 @@ You can configure the timezone for the container by passing a `TZ` env variable.
## Configuring ## Configuring
In this repo, you can explore the `sample-config.hcl` file for an example, but the general structure is as follows. It should be noted that environment variable interpolation happens on load of the HCL file. In this repo, you can explore the `sample-config.hcl` file for an example, but the general structure is as follows. If you are passing environment variables to your commands or alerts, you should be aware that `${VAR}` syntax is reserved for HCL variable interpolation. To avoid issues, you can use `$${VAR}` syntax to escape the `$` character, simply use `$VAR`.
```hcl
The global configurations are: The global configurations are:
|key|value| |key|value|
|---|---| |---|---|
|`check_interval`|Maximum frequency to run checks for each monitor as duration, eg. 1m2s.| |`check_interval`|Maximum frequency to run checks for each monitor as duration, eg. 1m2s.|
|`default_alert_after`|A default value used as an `alert_after` value for a monitor if not specified or 0.| |`default_alert_after`|A default value used as an `alert_after` value for a monitor if not specified. Defaults 1, which will alert immediately.|
|`default_alert_every`|A default value used as an `alert_every` value for a monitor if not specified.| |`default_alert_every`|A default value used as an `alert_every` value for a monitor if not specified. Defaults to -1, which will re-alert exponentially.|
|`default_alert_down`|Default down alerts to used by a monitor in case none are provided.| |`default_alert_down`|Default down alerts to used by a monitor in case none are provided.|
|`default_alert_up`|Default up alerts to used by a monitor in case none are provided.| |`default_alert_up`|Default up alerts to used by a monitor in case none are provided.|
|`monitor`|block listing monitors. Detailed description below| |`monitor`|block listing monitors. Detailed description below|
@@ -167,6 +169,48 @@ minitor -metrics
minitor -metrics -metrics-port 3000 minitor -metrics -metrics-port 3000
``` ```
## Migrating from v1 to v2
Minitor v2 introduces some breaking changes from v1. The most notable changes are:
- The configuration file is now in HCL format instead of YAML.
- The the Python formatting backwards compatability is removed.
- The Command and ShellCommand fields are now mutually exclusive.
- The check_interval is now strictly a duration string value. Eg. "30s" rather than `30`.
- Default alert_every is now -1 (exponential backoff) rather than 0 (no re-alerting).
For the configuration, a confic that looked like this in v1:
```yaml
check_interval: 60
monitors:
- name: example
command: "false"
alert_down: ["log"]
alerts:
log:
command: ["echo", "Minitor up={{.IsUp}} for {{.MonitorName}}"]
```
Would now look like this in v2:
```hcl
check_interval = "1m"
monitor "example" {
# example showing string to shell command migration
shell_command = "false"
alert_down = ["log"]
check_interval = "1m"
}
alert "log" {
# example showing list to exec command migration
command = ["echo", "Minitor up={{.IsUp}} for {{.MonitorName}}"]
}
```
## Contributing ## Contributing
Whether you're looking to submit a patch or tell me I broke something, you can contribute through the Github mirror and I can merge PRs back to the source repository. Whether you're looking to submit a patch or tell me I broke something, you can contribute through the Github mirror and I can merge PRs back to the source repository.
@@ -174,11 +218,3 @@ Whether you're looking to submit a patch or tell me I broke something, you can c
Primary Repo: https://git.iamthefij.com/iamthefij/minitor.git Primary Repo: https://git.iamthefij.com/iamthefij/minitor.git
Github Mirror: https://github.com/IamTheFij/minitor.git Github Mirror: https://github.com/IamTheFij/minitor.git
## Original Minitor
This is a reimplementation of [Minitor](https://git.iamthefij.com/iamthefij/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.
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"errors" "errors"
"testing" "testing"
m "git.iamthefij.com/iamthefij/minitor-go" m "git.iamthefij.com/iamthefij/minitor-go/v2"
) )
func TestAlertValidate(t *testing.T) { func TestAlertValidate(t *testing.T) {
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"testing" "testing"
"time" "time"
m "git.iamthefij.com/iamthefij/minitor-go" m "git.iamthefij.com/iamthefij/minitor-go/v2"
) )
func TestLoadConfig(t *testing.T) { func TestLoadConfig(t *testing.T) {
+2 -2
View File
@@ -1,6 +1,6 @@
module git.iamthefij.com/iamthefij/minitor-go module git.iamthefij.com/iamthefij/minitor-go/v2
go 1.23.0 go 1.25.0
require ( require (
git.iamthefij.com/iamthefij/slog v1.3.0 git.iamthefij.com/iamthefij/slog v1.3.0
+1 -1
View File
@@ -119,7 +119,7 @@ func SendStartupAlerts(config *Config, alertNames []string) error {
func main() { func main() {
showVersion := flag.Bool("version", false, "Display the version of minitor and exit") showVersion := flag.Bool("version", false, "Display the version of minitor and exit")
configPath := flag.String("config", "config.yml", "Alternate configuration path (default: config.yml)") configPath := flag.String("config", "config.hcl", "Alternate configuration path (default: config.hcl)")
startupAlerts := flag.String("startup-alerts", "", "List of alerts to run on startup. This can help determine unhealthy alerts early on. (default \"\")") startupAlerts := flag.String("startup-alerts", "", "List of alerts to run on startup. This can help determine unhealthy alerts early on. (default \"\")")
flag.BoolVar(&slog.DebugLevel, "debug", false, "Enables debug logs (default: false)") flag.BoolVar(&slog.DebugLevel, "debug", false, "Enables debug logs (default: false)")
+1 -1
View File
@@ -3,7 +3,7 @@ package main_test
import ( import (
"testing" "testing"
m "git.iamthefij.com/iamthefij/minitor-go" m "git.iamthefij.com/iamthefij/minitor-go/v2"
) )
func Ptr[T any](v T) *T { func Ptr[T any](v T) *T {
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"testing" "testing"
"time" "time"
m "git.iamthefij.com/iamthefij/minitor-go" m "git.iamthefij.com/iamthefij/minitor-go/v2"
) )
func TestMonitorValidate(t *testing.T) { func TestMonitorValidate(t *testing.T) {
+4 -4
View File
@@ -38,15 +38,15 @@ alert "mailgun_down" {
-F to=me@minitor.mon \ -F to=me@minitor.mon \
-F text="Our monitor failed" \ -F text="Our monitor failed" \
https://api.mailgun.net/v3/minitor.mon/messages \ https://api.mailgun.net/v3/minitor.mon/messages \
-u "api:${MAILGUN_API_KEY}" -u "api:$${MAILGUN_API_KEY}"
EOF EOF
} }
alert "sms_down" { alert "sms_down" {
shell_command = <<-EOF shell_command = <<-EOF
curl -s -X POST -F "Body=Failure! {{.MonitorName}} has failed" \ curl -s -X POST -F "Body=Failure! {{.MonitorName}} has failed" \
-F "From=${AVAILABLE_NUMBER}" -F "To=${MY_PHONE}" \ -F "From=$${AVAILABLE_NUMBER}" -F "To=$${MY_PHONE}" \
"https://api.twilio.com/2010-04-01/Accounts/${ACCOUNT_SID}/Messages" \ "https://api.twilio.com/2010-04-01/Accounts/$${ACCOUNT_SID}/Messages" \
-u "${ACCOUNT_SID}:${AUTH_TOKEN}" -u "$${ACCOUNT_SID}:$${AUTH_TOKEN}"
EOF EOF
} }