-
Notifications
You must be signed in to change notification settings - Fork 32
feat: dynamic matcher+template checks #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alex5517
wants to merge
28
commits into
grafana:main
Choose a base branch
from
neticdk:feat/custom-target-matcher-check
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
bd48754
:sparkles: required matchers can be provided via args + dynamic check…
alex5517 ff625b5
Change var naming
alex5517 9527c05
update docs
alex5517 5d25007
update docs add new
alex5517 73f5a85
Revert deletion of job/instance rules + remove matchers arg in favor …
alex5517 a3f79d8
:rewind: :hankey: - Fix chmod...
alex5517 dcfc870
:lipstick: - Add way of indicating a rules stability + Change printin…
alex5517 09de038
Light cleanup work + improved testing
alex5517 4ed59dc
Add/Update docs
alex5517 b08d388
:construction: Add test for Grafana variables :construction:
alex5517 721da14
merge conflict
alex5517 845df8a
Add legacy config example
alex5517 99ff76a
Go mod tidy
alex5517 7076e64
Use const for stability
alex5517 f71ba50
revert usage of const in test
alex5517 287dffd
:construction: initial rework of variable expansion to support revers…
alex5517 15d2e81
remove misleading comment
alex5517 d2cc9d8
:adhesive_bandage: - support different uses of variables
alex5517 c4bb4fc
fix failing test
alex5517 98ee145
Reverse variable expansion for: target-required-matchers-rule
alex5517 54aeb32
Do not omitempty dashboard editable
alex5517 ae10cf2
Support templating variables having a variable as value (expand recur…
alex5517 99d1d7c
:adhesive_bandage: Modfiy regexp matching to only match string that p…
alex5517 17956a8
:adhesive_bandage: Use a combination of slices and maps to ensure out…
alex5517 2594e21
:white_check_mark: Update tests to match new variable expansion metho…
alex5517 09e53e8
Support cases where variable is matchers
alex5517 c2e6171
Add hacky check and override configured match type if needed
alex5517 89661c5
mType should also be used when autofix
alex5517 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # target-required-matchers-rule | ||
| Checks that each PromQL query has a the matchers specified in rule settings. This rule is experimental and is designed to work with Prometheus datasources. | ||
|
|
||
| ## Rule Settings | ||
|
|
||
| ```yaml | ||
| settings: | ||
| target-required-matchers-rule: | ||
| matchers: | ||
| - cluster=~"$cluster" | ||
| - someLabel="someValue" | ||
| ``` | ||
| Legacy config example for job and instance | ||
| ```yaml | ||
| settings: | ||
| target-required-matchers-rule: | ||
| matchers: | ||
| - job | ||
| - instance | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # template-required-variables-rule | ||
| Checks that each dashboard has a templated variable based on provided rule settings and detected variable usage for the target-required-matchers-rule. | ||
|
|
||
| # Best Practice | ||
| The rule ensures all of the following conditions. | ||
|
|
||
| * The dashboard template exists. | ||
| * The dashboard template is named `xxx`. | ||
| * The dashboard template is labeled `xxx`. | ||
| * The dashboard template uses a templated datasource, specifically named `$datasource`. | ||
| * The dashboard template uses a Prometheus query to find available matching instances. | ||
| * The dashboard template is multi select | ||
| * The dashboard template has an allValue of `.+` | ||
|
|
||
| ## Rule Settings | ||
|
|
||
| ```yaml | ||
| settings: | ||
| template-required-variables-rule: | ||
| variables: | ||
| - cluster | ||
| - namespace | ||
| ``` | ||
| Legacy config example for job and instance | ||
| ```yaml | ||
| settings: | ||
| template-required-variables-rule: | ||
| variables: | ||
| - job | ||
| - instance | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.