Compare commits

...

5 Commits

Author SHA1 Message Date
Ian Fijolek
60cfac948b Breaking: Rename minitor_check_milliseconds and minitor_monitor_up_count
To conform with Prometheus metric name best practices, these have been
renamed as follows:

  * `minitor_check_milliseconds` to `minitor_check_seconds`
  * `minitor_monitor_up_count` to `minitor_monitor_up`
2022-12-19 15:45:23 -08:00
Ian Fijolek
958446050f Update linters 2022-12-19 15:34:47 -08:00
Ian Fijolek
88e94642d9 Remove some hooks included in golangci-lint and upgrade existing 2022-06-07 21:39:18 -07:00
Ian Fijolek
bc83a51907 Switch pre-commit url for golang 2022-04-04 20:12:01 -07:00
Ian Fijolek
08b8932331 Update curl version 2022-01-24 16:08:18 -08:00
7 changed files with 28 additions and 44 deletions
+14 -25
View File
@@ -1,32 +1,23 @@
---
linters:
enable:
- asciicheck
- bodyclose
- dogsled
- dupl
- errname
- errorlint
- exhaustive
- gochecknoinits
- gocognit
- gocritic
- gocyclo
- goerr113
- gofumpt
- goimports
- gomnd
- goprintffuncname
# - gosec
# - ifshort
- interfacer
- maligned
- misspell
- nakedret
- nestif
- nlreturn
- noctx
- unparam
- promlinter
- tagliatelle
- tenv
- testpackage
- thelper
- tparallel
- unconvert
- wrapcheck
- wsl
# - errorlint
disable:
- gochecknoglobals
@@ -34,15 +25,13 @@ linters-settings:
gosec:
excludes:
- G204
# gomnd:
# settings:
# mnd:
# ignored-functions: math.*
tagliatelle:
case:
rules:
yaml: snake
issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosec
- maligned
+3 -8
View File
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-yaml
@@ -11,15 +11,10 @@ repos:
- id: end-of-file-fixer
- id: check-merge-conflict
- repo: https://github.com/golangci/golangci-lint
rev: v1.42.1
rev: v1.50.1
hooks:
- id: golangci-lint
- repo: git://github.com/dnephin/pre-commit-golang
rev: v0.4.0
hooks:
- id: go-fmt
- id: go-imports
- repo: https://github.com/hadolint/hadolint
rev: v2.4.0
rev: v2.12.1-beta
hooks:
- id: hadolint
+1 -1
View File
@@ -5,7 +5,7 @@ RUN mkdir /app
WORKDIR /app/
# Add common checking tools
RUN apk --no-cache add bash=~5.0 curl=~7.76 jq=~1.6
RUN apk --no-cache add bash=~5.0 curl=~7.79 jq=~1.6
# Add minitor user for running as non-root
RUN addgroup -S minitor && adduser -S minitor -G minitor
+2 -2
View File
@@ -14,7 +14,7 @@ ARG VERSION=dev
ENV CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH}
RUN go build -ldflags "-X main.version=${VERSION}" -a -installsuffix nocgo -o minitor .
FROM ${REPO}/alpine:3.10
FROM ${REPO}/alpine:3.12
RUN mkdir /app
WORKDIR /app/
@@ -22,7 +22,7 @@ WORKDIR /app/
COPY --from=builder /app/minitor .
# Add common checking tools
RUN apk --no-cache add bash=~5.0 curl=~7.66 jq=~1.6
RUN apk --no-cache add bash=~5.0 curl=~7.79 jq=~1.6
# Add minitor user for running as non-root
RUN addgroup -S minitor && adduser -S minitor -G minitor
+1 -1
View File
@@ -76,7 +76,7 @@ func checkMonitors(config *Config) error {
// Track status metrics
Metrics.SetMonitorStatus(monitor.Name, monitor.IsUp())
Metrics.CountCheck(monitor.Name, success, monitor.LastCheckMilliseconds(), hasAlert)
Metrics.CountCheck(monitor.Name, success, monitor.LastCheckSeconds(), hasAlert)
if alertNotice != nil {
err := sendAlerts(config, monitor, alertNotice)
+4 -4
View File
@@ -43,14 +43,14 @@ func NewMetrics() *MinitorMetrics {
),
checkTime: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "minitor_check_milliseconds",
Name: "minitor_check_seconds",
Help: "Time in miliseconds that a check ran for",
},
[]string{"monitor", "status"},
),
monitorStatus: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "minitor_monitor_up_count",
Name: "minitor_monitor_up",
Help: "Status of currently responsive monitors",
},
[]string{"monitor"},
@@ -77,7 +77,7 @@ func (metrics *MinitorMetrics) SetMonitorStatus(monitor string, isUp bool) {
}
// CountCheck counts the result of a particular Monitor check
func (metrics *MinitorMetrics) CountCheck(monitor string, isSuccess bool, ms int64, isAlert bool) {
func (metrics *MinitorMetrics) CountCheck(monitor string, isSuccess bool, secs float64, isAlert bool) {
status := "failure"
if isSuccess {
status = "success"
@@ -94,7 +94,7 @@ func (metrics *MinitorMetrics) CountCheck(monitor string, isSuccess bool, ms int
metrics.checkTime.With(
prometheus.Labels{"monitor": monitor, "status": status},
).Set(float64(ms))
).Set(secs)
}
// CountAlert counts an alert
+3 -3
View File
@@ -91,9 +91,9 @@ func (monitor Monitor) IsUp() bool {
return monitor.alertCount == 0
}
// LastCheckMilliseconds gives number of miliseconds the last check ran for
func (monitor Monitor) LastCheckMilliseconds() int64 {
return monitor.lastCheckDuration.Milliseconds()
// LastCheckSeconds gives number of seconds the last check ran for
func (monitor Monitor) LastCheckSeconds() float64 {
return monitor.lastCheckDuration.Seconds()
}
func (monitor *Monitor) success() (notice *AlertNotice) {