-
Notifications
You must be signed in to change notification settings - Fork 55
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
refactor: config for job aggregation strings #319
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c9ec237
refactor: config for job aggregation strings
darrenjaneczek d613a91
lint
darrenjaneczek 36ac142
Update cortex-mixin/dashboards/writes.libsonnet
darrenjaneczek cf89397
fix: syntax
darrenjaneczek 31466e6
refactor: added a group_config
darrenjaneczek a8630f3
refactor: added a group_config
darrenjaneczek 6c3aa96
refactor: added a group_config
darrenjaneczek a03451c
fix: changelog
darrenjaneczek 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 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 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 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 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 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 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,45 @@ | ||
{ | ||
local makePrefix(groups) = std.join('_', groups), | ||
local makeGroupBy(groups) = std.join(', ', groups), | ||
|
||
local group_by_cluster = makeGroupBy($._config.cluster_labels), | ||
|
||
_group_config+:: { | ||
// Each group prefix is composed of `_`-separated labels | ||
group_prefix_jobs: makePrefix($._config.job_labels), | ||
group_prefix_clusters: makePrefix($._config.cluster_labels), | ||
|
||
// Each group-by label list is `, `-separated and unique identifies | ||
group_by_job: makeGroupBy($._config.job_labels), | ||
group_by_cluster: group_by_cluster, | ||
}, | ||
|
||
// The following works around the deprecation of `$._config.alert_aggregation_labels` | ||
// - If an override of that value is detected, a warning will be printed | ||
// - If no override was detected, it will be set to the `group_by_cluster` value, | ||
// which will replace it altogether in the future. | ||
local alert_aggregation_labels_override = ( | ||
{ | ||
alert_aggregation_labels: null, | ||
} + super._config | ||
).alert_aggregation_labels, | ||
|
||
_config+:: { | ||
alert_aggregation_labels: | ||
if alert_aggregation_labels_override != null | ||
then std.trace( | ||
||| | ||
Deprecated: _config.alert_aggregation_labels | ||
This field has been explicitly overridden to "%s". | ||
Instead, express the override in terms of _config.cluster_labels. | ||
E.g., cluster_labels: %s will automatically convert to "%s". | ||
||| % [ | ||
alert_aggregation_labels_override, | ||
$._config.cluster_labels, | ||
group_by_cluster, | ||
], | ||
alert_aggregation_labels_override | ||
) | ||
else group_by_cluster, | ||
}, | ||
} |
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
(import 'config.libsonnet') + | ||
(import 'groups.libsonnet') + | ||
(import 'dashboards.libsonnet') + | ||
(import 'alerts.libsonnet') + | ||
(import 'recording_rules.libsonnet') |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job here! I'm just wondering if we actually need this complexity. What we typically do is to introduce a breaking change (eg. stop using
alert_aggregation_labels
) and document it in the CHANGELOG. This mixin policy doesn't guarantee backward compatibility.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was concerned that my change could cause a phantom failure for someone, where their custom override would just stop working without any warning/error.
A plain old "
error
ifalert_aggregation_labels
is defined" would be less complex and solve my concern.Let me know if/how you want this addressed in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not block on this. What you did looks correct, I'm just a bit worried about its maintenance, but not a blocker.