Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ab8899dc6 | ||
|
|
819abf4263 | ||
|
|
6950a080df | ||
|
|
7d6923730e | ||
|
|
542da61215 | ||
|
|
45fe7beb6d | ||
|
|
26611b7793 |
No files matched your search
@@ -1,5 +1,9 @@
|
|||||||
name: benchmark
|
name: benchmark
|
||||||
on:
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [publish-latest]
|
||||||
|
branches: [master]
|
||||||
|
types: [completed]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
repository:
|
repository:
|
||||||
@@ -19,8 +23,8 @@ jobs:
|
|||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.19
|
go-version: 1.19
|
||||||
repository: "${{ github.event.inputs.repository }}"
|
repository: "${{ github.event.inputs.repository || 'TwiN/gatus' }}"
|
||||||
ref: "${{ github.event.inputs.ref }}"
|
ref: "${{ github.event.inputs.ref || 'master' }}"
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Benchmark
|
- name: Benchmark
|
||||||
run: go test -bench=. ./storage/store
|
run: go test -bench=. ./storage/store
|
||||||
@@ -3,14 +3,14 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '*.md'
|
- '*.md'
|
||||||
- '.examples/*'
|
- '.examples/**'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '*.md'
|
- '*.md'
|
||||||
- '.github/*'
|
- '.github/**'
|
||||||
- '.examples/*'
|
- '.examples/**'
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
Gatus is a developer-oriented health dashboard that gives you the ability to monitor your services using HTTP, ICMP, TCP, and even DNS
|
Gatus is a developer-oriented health dashboard that gives you the ability to monitor your services using HTTP, ICMP, TCP, and even DNS
|
||||||
queries as well as evaluate the result of said queries by using a list of conditions on values like the status code,
|
queries as well as evaluate the result of said queries by using a list of conditions on values like the status code,
|
||||||
the response time, the certificate expiration, the body and many others. The icing on top is that each of these health
|
the response time, the certificate expiration, the body and many others. The icing on top is that each of these health
|
||||||
checks can be paired with alerting via Slack, PagerDuty, Pushover, Discord, Twilio and more.
|
checks can be paired with alerting via Slack, Teams, PagerDuty, Discord, Twilio and many more.
|
||||||
|
|
||||||
I personally deploy it in my Kubernetes cluster and let it monitor the status of my
|
I personally deploy it in my Kubernetes cluster and let it monitor the status of my
|
||||||
core applications: https://status.twin.sh/
|
core applications: https://status.twin.sh/
|
||||||
@@ -801,7 +801,7 @@ endpoints:
|
|||||||
| `alerting.pushover.user-key` | User or group key | `""` |
|
| `alerting.pushover.user-key` | User or group key | `""` |
|
||||||
| `alerting.pushover.title` | Fixed title for all messages sent via Pushover | Name of your App in Pushover |
|
| `alerting.pushover.title` | Fixed title for all messages sent via Pushover | Name of your App in Pushover |
|
||||||
| `alerting.pushover.priority` | Priority of all messages, ranging from -2 (very low) to 2 (emergency) | `0` |
|
| `alerting.pushover.priority` | Priority of all messages, ranging from -2 (very low) to 2 (emergency) | `0` |
|
||||||
| `alerting.pushover.sound` | Sound of all messages<br/ >See [sounds](https://pushover.net/api#sounds) for all valid choices. | `""` |
|
| `alerting.pushover.sound` | Sound of all messages<br />See [sounds](https://pushover.net/api#sounds) for all valid choices. | `""` |
|
||||||
| `alerting.pushover.default-alert` | Default alert configuration. <br />See [Setting a default alert](#setting-a-default-alert) | N/A |
|
| `alerting.pushover.default-alert` | Default alert configuration. <br />See [Setting a default alert](#setting-a-default-alert) | N/A |
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -1301,11 +1301,11 @@ Please refer to Helm's [documentation](https://helm.sh/docs/) to get started.
|
|||||||
Once Helm is set up properly, add the repository as follows:
|
Once Helm is set up properly, add the repository as follows:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
helm repo add gatus https://avakarev.github.io/gatus-chart
|
helm repo add minicloudlabs https://minicloudlabs.github.io/helm-charts
|
||||||
```
|
```
|
||||||
|
|
||||||
To get more details, please check chart's [configuration](https://github.com/avakarev/gatus-chart#configuration)
|
To get more details, please check [chart's configuration](https://github.com/minicloudlabs/helm-charts/tree/main/charts/gatus#configuration)
|
||||||
and [helmfile example](https://github.com/avakarev/gatus-chart#helmfileyaml-example)
|
and [helmfile example](https://github.com/minicloudlabs/helm-charts/tree/main/charts/gatus#helmfileyaml-example)
|
||||||
|
|
||||||
|
|
||||||
### Terraform
|
### Terraform
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/TwiN/deepmerge"
|
"github.com/TwiN/deepmerge"
|
||||||
@@ -214,8 +215,13 @@ func walkConfigDir(path string, fn fs.WalkDirFunc) error {
|
|||||||
|
|
||||||
// parseAndValidateConfigBytes parses a Gatus configuration file into a Config struct and validates its parameters
|
// parseAndValidateConfigBytes parses a Gatus configuration file into a Config struct and validates its parameters
|
||||||
func parseAndValidateConfigBytes(yamlBytes []byte) (config *Config, err error) {
|
func parseAndValidateConfigBytes(yamlBytes []byte) (config *Config, err error) {
|
||||||
|
// Replace $$ with __GATUS_LITERAL_DOLLAR_SIGN__ to prevent os.ExpandEnv from treating "$$" as if it was an
|
||||||
|
// environment variable. This allows Gatus to support literal "$" in the configuration file.
|
||||||
|
yamlBytes = []byte(strings.ReplaceAll(string(yamlBytes), "$$", "__GATUS_LITERAL_DOLLAR_SIGN__"))
|
||||||
// Expand environment variables
|
// Expand environment variables
|
||||||
yamlBytes = []byte(os.ExpandEnv(string(yamlBytes)))
|
yamlBytes = []byte(os.ExpandEnv(string(yamlBytes)))
|
||||||
|
// Replace __GATUS_LITERAL_DOLLAR_SIGN__ with "$" to restore the literal "$" in the configuration file
|
||||||
|
yamlBytes = []byte(strings.ReplaceAll(string(yamlBytes), "__GATUS_LITERAL_DOLLAR_SIGN__", "$"))
|
||||||
// Parse configuration file
|
// Parse configuration file
|
||||||
if err = yaml.Unmarshal(yamlBytes, &config); err != nil {
|
if err = yaml.Unmarshal(yamlBytes, &config); err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
+28
-1
@@ -1534,7 +1534,34 @@ endpoints:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseAndValidateConfigBytesWithNoEndpointsOrAutoDiscovery(t *testing.T) {
|
func TestParseAndValidateConfigBytesWithLiteralDollarSign(t *testing.T) {
|
||||||
|
os.Setenv("GATUS_TestParseAndValidateConfigBytesWithLiteralDollarSign", "whatever")
|
||||||
|
config, err := parseAndValidateConfigBytes([]byte(`
|
||||||
|
endpoints:
|
||||||
|
- name: website
|
||||||
|
url: https://twin.sh/health
|
||||||
|
conditions:
|
||||||
|
- "[BODY] == $$GATUS_TestParseAndValidateConfigBytesWithLiteralDollarSign"
|
||||||
|
- "[BODY] == $GATUS_TestParseAndValidateConfigBytesWithLiteralDollarSign"
|
||||||
|
`))
|
||||||
|
if err != nil {
|
||||||
|
t.Error("expected no error, got", err.Error())
|
||||||
|
}
|
||||||
|
if config == nil {
|
||||||
|
t.Fatal("Config shouldn't have been nil")
|
||||||
|
}
|
||||||
|
if config.Endpoints[0].URL != "https://twin.sh/health" {
|
||||||
|
t.Errorf("URL should have been %s", "https://twin.sh/health")
|
||||||
|
}
|
||||||
|
if config.Endpoints[0].Conditions[0] != "[BODY] == $GATUS_TestParseAndValidateConfigBytesWithLiteralDollarSign" {
|
||||||
|
t.Errorf("Condition should have been %s", "[BODY] == $GATUS_TestParseAndValidateConfigBytesWithLiteralDollarSign")
|
||||||
|
}
|
||||||
|
if config.Endpoints[0].Conditions[1] != "[BODY] == whatever" {
|
||||||
|
t.Errorf("Condition should have been %s", "[BODY] == whatever")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParseAndValidateConfigBytesWithNoEndpoints(t *testing.T) {
|
||||||
_, err := parseAndValidateConfigBytes([]byte(``))
|
_, err := parseAndValidateConfigBytes([]byte(``))
|
||||||
if err != ErrNoEndpointInConfig {
|
if err != ErrNoEndpointInConfig {
|
||||||
t.Error("The error returned should have been of type ErrNoEndpointInConfig")
|
t.Error("The error returned should have been of type ErrNoEndpointInConfig")
|
||||||
|
|||||||
+10
-2
@@ -302,10 +302,18 @@ func sanitizeAndResolveNumerical(list []string, result *Result) (parameters []st
|
|||||||
parameters, resolvedParameters := sanitizeAndResolve(list, result)
|
parameters, resolvedParameters := sanitizeAndResolve(list, result)
|
||||||
for _, element := range resolvedParameters {
|
for _, element := range resolvedParameters {
|
||||||
if duration, err := time.ParseDuration(element); duration != 0 && err == nil {
|
if duration, err := time.ParseDuration(element); duration != 0 && err == nil {
|
||||||
|
// If the string is a duration, convert it to milliseconds
|
||||||
resolvedNumericalParameters = append(resolvedNumericalParameters, duration.Milliseconds())
|
resolvedNumericalParameters = append(resolvedNumericalParameters, duration.Milliseconds())
|
||||||
} else if number, err := strconv.ParseInt(element, 10, 64); err != nil {
|
} else if number, err := strconv.ParseInt(element, 10, 64); err != nil {
|
||||||
// Default to 0 if the string couldn't be converted to an integer
|
// It's not an int, so we'll check if it's a float
|
||||||
resolvedNumericalParameters = append(resolvedNumericalParameters, 0)
|
if f, err := strconv.ParseFloat(element, 64); err == nil {
|
||||||
|
// It's a float, but we'll convert it to an int. We're losing precision here, but it's better than
|
||||||
|
// just returning 0.
|
||||||
|
resolvedNumericalParameters = append(resolvedNumericalParameters, int64(f))
|
||||||
|
} else {
|
||||||
|
// Default to 0 if the string couldn't be converted to an integer or a float
|
||||||
|
resolvedNumericalParameters = append(resolvedNumericalParameters, 0)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
resolvedNumericalParameters = append(resolvedNumericalParameters, number)
|
resolvedNumericalParameters = append(resolvedNumericalParameters, number)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,6 +294,13 @@ func TestCondition_evaluate(t *testing.T) {
|
|||||||
ExpectedSuccess: false,
|
ExpectedSuccess: false,
|
||||||
ExpectedOutput: "[BODY].data.id (1) > 5",
|
ExpectedOutput: "[BODY].data.id (1) > 5",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "body-jsonpath-float-using-greater-than-issue433", // As of v5.3.1, Gatus will convert a float to an int. We're losing precision, but it's better than just returning 0
|
||||||
|
Condition: Condition("[BODY].balance > 100"),
|
||||||
|
Result: &Result{body: []byte(`{"balance": "123.40000000000005"}`)},
|
||||||
|
ExpectedSuccess: true,
|
||||||
|
ExpectedOutput: "[BODY].balance > 100",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "body-jsonpath-complex-int-using-less-than",
|
Name: "body-jsonpath-complex-int-using-less-than",
|
||||||
Condition: Condition("[BODY].data.id < 5"),
|
Condition: Condition("[BODY].data.id < 5"),
|
||||||
|
|||||||
@@ -158,6 +158,22 @@ func TestEval(t *testing.T) {
|
|||||||
ExpectedOutputLength: 0,
|
ExpectedOutputLength: 0,
|
||||||
ExpectedError: true,
|
ExpectedError: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "float-as-string",
|
||||||
|
Path: "balance",
|
||||||
|
Data: `{"balance": "123.40000000000005"}`,
|
||||||
|
ExpectedOutput: "123.40000000000005",
|
||||||
|
ExpectedOutputLength: 18,
|
||||||
|
ExpectedError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "float-as-number",
|
||||||
|
Path: "balance",
|
||||||
|
Data: `{"balance": 123.40000000000005}`,
|
||||||
|
ExpectedOutput: "123.40000000000005",
|
||||||
|
ExpectedOutputLength: 18,
|
||||||
|
ExpectedError: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, scenario := range scenarios {
|
for _, scenario := range scenarios {
|
||||||
t.Run(scenario.Name, func(t *testing.T) {
|
t.Run(scenario.Name, func(t *testing.T) {
|
||||||
|
|||||||
Reference in new issue
Block a user