mirror of
https://github.com/TwiN/gatus.git
synced 2026-02-04 15:14:43 +00:00
fix(key): Support (, ), + and & as name/group (#1340)
fix(key): Support (, ), + and & as name/group Relevant: #1339
This commit is contained in:
16
README.md
16
README.md
@@ -366,7 +366,7 @@ or send an HTTP request:
|
|||||||
POST /api/v1/endpoints/{key}/external?success={success}&error={error}&duration={duration}
|
POST /api/v1/endpoints/{key}/external?success={success}&error={error}&duration={duration}
|
||||||
```
|
```
|
||||||
Where:
|
Where:
|
||||||
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.` and `#` replaced by `-`.
|
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.`, `#`, `(`, `)`, `+` and `&` replaced by `-`.
|
||||||
- Using the example configuration above, the key would be `core_ext-ep-test`.
|
- Using the example configuration above, the key would be `core_ext-ep-test`.
|
||||||
- `{success}` is a boolean (`true` or `false`) value indicating whether the health check was successful or not.
|
- `{success}` is a boolean (`true` or `false`) value indicating whether the health check was successful or not.
|
||||||
- `{error}` (optional): a string describing the reason for a failed health check. If {success} is false, this should contain the error message; if the check is successful.
|
- `{error}` (optional): a string describing the reason for a failed health check. If {success} is false, this should contain the error message; if the check is successful.
|
||||||
@@ -3294,7 +3294,7 @@ The path to generate a badge is the following:
|
|||||||
```
|
```
|
||||||
Where:
|
Where:
|
||||||
- `{duration}` is `30d`, `7d`, `24h` or `1h`
|
- `{duration}` is `30d`, `7d`, `24h` or `1h`
|
||||||
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.` and `#` replaced by `-`.
|
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.`, `#`, `(`, `)`, `+` and `&` replaced by `-`.
|
||||||
|
|
||||||
For instance, if you want the uptime during the last 24 hours from the endpoint `frontend` in the group `core`,
|
For instance, if you want the uptime during the last 24 hours from the endpoint `frontend` in the group `core`,
|
||||||
the URL would look like this:
|
the URL would look like this:
|
||||||
@@ -3320,7 +3320,7 @@ The path to generate a badge is the following:
|
|||||||
/api/v1/endpoints/{key}/health/badge.svg
|
/api/v1/endpoints/{key}/health/badge.svg
|
||||||
```
|
```
|
||||||
Where:
|
Where:
|
||||||
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.` and `#` replaced by `-`.
|
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.`, `#`, `(`, `)`, `+` and `&` replaced by `-`.
|
||||||
|
|
||||||
For instance, if you want the current status of the endpoint `frontend` in the group `core`,
|
For instance, if you want the current status of the endpoint `frontend` in the group `core`,
|
||||||
the URL would look like this:
|
the URL would look like this:
|
||||||
@@ -3337,7 +3337,7 @@ The path to generate a badge is the following:
|
|||||||
/api/v1/endpoints/{key}/health/badge.shields
|
/api/v1/endpoints/{key}/health/badge.shields
|
||||||
```
|
```
|
||||||
Where:
|
Where:
|
||||||
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.` and `#` replaced by `-`.
|
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.`, `#`, `(`, `)`, `+` and `&` replaced by `-`.
|
||||||
|
|
||||||
For instance, if you want the current status of the endpoint `frontend` in the group `core`,
|
For instance, if you want the current status of the endpoint `frontend` in the group `core`,
|
||||||
the URL would look like this:
|
the URL would look like this:
|
||||||
@@ -3360,7 +3360,7 @@ The endpoint to generate a badge is the following:
|
|||||||
```
|
```
|
||||||
Where:
|
Where:
|
||||||
- `{duration}` is `30d`, `7d`, `24h` or `1h`
|
- `{duration}` is `30d`, `7d`, `24h` or `1h`
|
||||||
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.` and `#` replaced by `-`.
|
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.`, `#`, `(`, `)`, `+` and `&` replaced by `-`.
|
||||||
|
|
||||||
#### Response time (chart)
|
#### Response time (chart)
|
||||||

|

|
||||||
@@ -3373,7 +3373,7 @@ The endpoint to generate a response time chart is the following:
|
|||||||
```
|
```
|
||||||
Where:
|
Where:
|
||||||
- `{duration}` is `30d`, `7d`, or `24h`
|
- `{duration}` is `30d`, `7d`, or `24h`
|
||||||
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.` and `#` replaced by `-`.
|
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.`, `#`, `(`, `)`, `+` and `&` replaced by `-`.
|
||||||
|
|
||||||
##### How to change the color thresholds of the response time badge
|
##### How to change the color thresholds of the response time badge
|
||||||
To change the response time badges' threshold, a corresponding configuration can be added to an endpoint.
|
To change the response time badges' threshold, a corresponding configuration can be added to an endpoint.
|
||||||
@@ -3431,7 +3431,7 @@ The path to get raw uptime data for an endpoint is:
|
|||||||
```
|
```
|
||||||
Where:
|
Where:
|
||||||
- `{duration}` is `30d`, `7d`, `24h` or `1h`
|
- `{duration}` is `30d`, `7d`, `24h` or `1h`
|
||||||
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.` and `#` replaced by `-`.
|
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.`, `#`, `(`, `)`, `+` and `&` replaced by `-`.
|
||||||
|
|
||||||
For instance, if you want the raw uptime data for the last 24 hours from the endpoint `frontend` in the group `core`, the URL would look like this:
|
For instance, if you want the raw uptime data for the last 24 hours from the endpoint `frontend` in the group `core`, the URL would look like this:
|
||||||
```
|
```
|
||||||
@@ -3445,7 +3445,7 @@ The path to get raw response time data for an endpoint is:
|
|||||||
```
|
```
|
||||||
Where:
|
Where:
|
||||||
- `{duration}` is `30d`, `7d`, `24h` or `1h`
|
- `{duration}` is `30d`, `7d`, `24h` or `1h`
|
||||||
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.` and `#` replaced by `-`.
|
- `{key}` has the pattern `<GROUP_NAME>_<ENDPOINT_NAME>` in which both variables have ` `, `/`, `_`, `,`, `.`, `#`, `(`, `)`, `+` and `&` replaced by `-`.
|
||||||
|
|
||||||
For instance, if you want the raw response time data for the last 24 hours from the endpoint `frontend` in the group `core`, the URL would look like this:
|
For instance, if you want the raw response time data for the last 24 hours from the endpoint `frontend` in the group `core`, the URL would look like this:
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -15,5 +15,9 @@ func sanitize(s string) string {
|
|||||||
s = strings.ReplaceAll(s, ",", "-")
|
s = strings.ReplaceAll(s, ",", "-")
|
||||||
s = strings.ReplaceAll(s, " ", "-")
|
s = strings.ReplaceAll(s, " ", "-")
|
||||||
s = strings.ReplaceAll(s, "#", "-")
|
s = strings.ReplaceAll(s, "#", "-")
|
||||||
|
s = strings.ReplaceAll(s, "(", "-")
|
||||||
|
s = strings.ReplaceAll(s, ")", "-")
|
||||||
|
s = strings.ReplaceAll(s, "+", "-")
|
||||||
|
s = strings.ReplaceAll(s, "&", "-")
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,21 @@ func TestConvertGroupAndNameToKey(t *testing.T) {
|
|||||||
Name: "name",
|
Name: "name",
|
||||||
ExpectedOutput: "_name",
|
ExpectedOutput: "_name",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
GroupName: "API (v1)",
|
||||||
|
Name: "endpoint",
|
||||||
|
ExpectedOutput: "api--v1-_endpoint",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
GroupName: "website (admin)",
|
||||||
|
Name: "test",
|
||||||
|
ExpectedOutput: "website--admin-_test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
GroupName: "search",
|
||||||
|
Name: "query&filter",
|
||||||
|
ExpectedOutput: "search_query-filter",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, scenario := range scenarios {
|
for _, scenario := range scenarios {
|
||||||
t.Run(scenario.ExpectedOutput, func(t *testing.T) {
|
t.Run(scenario.ExpectedOutput, func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user