Skip to content

Commit

Permalink
Add tags to prometheus config
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Dec 14, 2022
1 parent 2c19bd1 commit 40a8431
Show file tree
Hide file tree
Showing 17 changed files with 1,284 additions and 66 deletions.
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v0.38.0

### Added

- `prometheus` configuration blocks now accepts `tags` field with a list of tags.
Tags can be used to disable or snooze specific checks on all Prometheus instances
with that tag.
See [ignoring](ignoring.md) for details.

## v0.37.0

### Added
Expand Down
5 changes: 5 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ Syntax:
prometheus "$name" {
uri = "https://..."
failover = ["https://...", ...]
tags = ["...", ...]
headers = { "...": "..." }
timeout = "2m"
concurrency = 16
Expand All @@ -207,6 +208,9 @@ prometheus "$name" {
It's highly recommended that all URIs point to Prometheus servers with identical
configuration, otherwise pint checks might return unreliable results and potential
false positives.
- `tags` - a list of strings that can be used to group Prometheus servers together.
Tags cannot contain spaces.
Tags can be later used when disabling checks via comments, see [ignoring](ignoring.md).
- `headers` - a list of HTTP headers that will be set on all requests for this Prometheus
server.
- `timeout` - timeout to be used for API requests. Defaults to 2 minutes.
Expand Down Expand Up @@ -248,6 +252,7 @@ Example:
```js
prometheus "prod" {
uri = "https://prometheus-prod.example.com"
tags = ["prod"]
headers = {
"X-Auth": "secret"
}
Expand Down
35 changes: 35 additions & 0 deletions docs/ignoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,32 @@ to disable.

See each individual [check](checks/index.md) documentation for details.

Checks can also be disabled for specific Prometheus servers using
`# pint disable ...($prometheus)` comments. Replace `$prometheus` with the name
of the Prometheus configuration block in pint that you want to disable it for.
Examples:

If you have a `stating` Prometheus configuration block in pint config file:

```js
prometheus "staging" {
uri = "https://prometheus-staging.example.com"
tags = ["testing"]
}
```

and have a rule where you want to disable `promql/series` checks run against that
Prometheus server then add a comment:

`# pint disable promql/series(staging)`

You can also use tags set on Prometheus configuration blocks inside comments.
Tags must use `+` prefix, so if you want to disable `promql/series` check on all
Prometheus servers with `testing` tag then add this comment:

`# pint disable promql/series(+testing)`


## Snoozing individual checks for specific rules

If you want to disable invididual checks just for some time then you can snooze them
Expand All @@ -124,3 +150,12 @@ Examples:
- record: ...
expr: ...
```

Just like with `# pint disable ...` you can also use tags with snooze comments.

```yaml
# pint snooze 2023-01-12T10:00:00Z promql/series(+tag)
# pint snooze 2023-01-12 promql/rate(+tag)
- record: ...
expr: ...
```
1 change: 1 addition & 0 deletions internal/checks/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func simpleProm(name, uri string, timeout time.Duration, required bool) *promapi
"up",
nil,
nil,
nil,
)
}

Expand Down
1 change: 1 addition & 0 deletions internal/checks/rule_duplicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func TestRuleDuplicateCheck(t *testing.T) {
"up",
nil,
[]*regexp.Regexp{regexp.MustCompile(".*")},
nil,
)
},
problems: noProblems,
Expand Down
Loading

0 comments on commit 40a8431

Please sign in to comment.