Skip to content
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 8 commits into from
Jun 10, 2021

Conversation

darrenjaneczek
Copy link
Contributor

@darrenjaneczek darrenjaneczek commented Jun 2, 2021

What this PR does:
(Updated based on suggestions below)

  • to make it easier to override, define "cluster_namespace_job" and "cluster, namespace, job" in terms of a new list in $._config: job_labels: ['cluster', 'namespace', 'job']
    • This replaces many hard-coded uses of these labels
  • for consistency, based on feedback, we now follow a similar pattern for clusters: cluster_labels: ['cluster', 'namespace']
  • the resulting string values are defined using a new groups.libsonnet file as $._group_config, which gets mixed in where it is needed.
  • a hard-coded group-by used namespace hard-coded in the query -- it has been updated to use the composition from $._cluster_labels.
  • deprecated _config.alert_aggregation_labels, since it is now a function of $._cluster_labels
    • there is a warning message if this old value is still being directly overridden; it still works (for now)
    • encouraged approach is to override the cluster_labels list instead, which is what will happen if alert_aggregation_labels is not overridden.

The resulting output does not change (unless any of the new lists in config are overridden), except in exactly one case where it was recommended to replace a hard-coded reference from namespace to cluster, namespace, composed from $._config.cluster_labels.

Checklist

  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

- to make it easier to override, define "cluster_namespace_job"
  in $._config as `job_aggregation_prefix`.
- added some `job_aggregation_labels_*` as well

The resulting output does not change (unless config is overridden).
@darrenjaneczek
Copy link
Contributor Author

I am hoping for some feedback on the variable names, to ensure that they are appropriate.

@darrenjaneczek darrenjaneczek marked this pull request as ready for review June 2, 2021 20:19
@darrenjaneczek darrenjaneczek requested a review from a team as a code owner June 2, 2021 20:19
Copy link
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'd wait for someone from the Cortex team

Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I left few comments 🙏

cortex-mixin/dashboards/writes.libsonnet Outdated Show resolved Hide resolved
cortex-mixin/dashboards/writes.libsonnet Outdated Show resolved Hide resolved
cortex-mixin/config.libsonnet Outdated Show resolved Hide resolved
darrenjaneczek and others added 5 commits June 3, 2021 10:24
simplify mapping by extending $._config

Co-authored-by: Marco Pracucci <marco@pracucci.com>
defines group-related strings based off of array-based
parameters in _config.

deprecated _config.alert_aggregation_labels with a std.trace warning,
while maintaining (temporary?) backward compatibility.
defines group-related strings based off of array-based
parameters in _config.

deprecated _config.alert_aggregation_labels with a std.trace warning,
while maintaining (temporary?) backward compatibility.
defines group-related strings based off of array-based
parameters in _config.

deprecated _config.alert_aggregation_labels with a std.trace warning,
while maintaining (temporary?) backward compatibility.
@darrenjaneczek
Copy link
Contributor Author

darrenjaneczek commented Jun 4, 2021

@pracucci , with the [cluster, namespace] list (cluster_labels) defining which labels identify a cluster, does it make sense to seek out references to cluster_namespace* string patterns and replace them with the corresponding prefix (group_prefix_clusters)?

Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (modulo a comment about alert_aggregation_labels_override). Please also add a CHANGELOG entry to explain the new config options.

// - 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 = (
Copy link
Collaborator

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.

Copy link
Contributor Author

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 if alert_aggregation_labels is defined" would be less complex and solve my concern.

Let me know if/how you want this addressed in this PR.

Copy link
Collaborator

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.

@pracucci
Copy link
Collaborator

pracucci commented Jun 8, 2021

@pracucci , with the [cluster, namespace] list (cluster_labels) defining which labels identify a cluster, does it make sense to seek out references to cluster_namespace* string patterns and replace them with the corresponding prefix (group_prefix_clusters)?

I would start as smallest as possible because the potential replacement is huge. If this PR solves your use case, I would start from here and work on it on incremental PRs.

@pracucci pracucci merged commit 8c82746 into main Jun 10, 2021
@pracucci pracucci deleted the darrenjaneczek/config-job-aggregation branch June 10, 2021 10:39
simonswine pushed a commit to grafana/mimir that referenced this pull request Oct 18, 2021
…czek/config-job-aggregation

refactor: config for job aggregation strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants