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

Make aggregationFile an optional setting #485

Merged
merged 12 commits into from Feb 25, 2022
Merged

Conversation

fionaliao
Copy link
Contributor

@fionaliao fionaliao commented Feb 16, 2022

aggregationFile is currently a mandatory setting for configuring a GrafanaNet route. This PR updates it to be optional. Making this optional simplifies the process of migrating to Grafana Cloud Graphite V5.

If aggregationFile is not set, the most recent aggregation file uploaded to Grafana Cloud will be used instead. If no aggregation files have been uploaded, the default Grafana Cloud aggregations will be applied.

This is a breaking change for the addRoute grafanaNet ... command, as aggregationFile= needs to be prepended to the aggregation file value since it's now an optional parameter.

Testing

Built a local Docker image for my branch and configured it to push to Grafana Cloud. Checked that ignoring aggregationFile doesn't error, and also checked that setting aggregationFile causes the config to be pushed to Grafana Cloud.

Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
@fionaliao fionaliao marked this pull request as ready for review February 16, 2022 15:21
for ; t.Token != toki.EOF; t = s.Next() {
switch t.Token {
case optAggregationFile:
t = s.Next()
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need to do this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The value of t.Token when we enter the for loop will be the name of the optional setting (in this case aggregationFile=). We need to move to the next token to get the value of the setting.

Copy link
Member

@jesusvazquez jesusvazquez left a comment

Choose a reason for hiding this comment

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

Overall looks good to me 💪

Copy link
Contributor

@Dieterbe Dieterbe left a comment

Choose a reason for hiding this comment

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

There's still a couple places that need updating.

e.g. docs/grafana-net.md (make it clear it's optional now), jsonnet (remove the default)
i recommend you grep for aggregations throughout the repo to find what needs updating.

route/grafananet_test.go Outdated Show resolved Hide resolved
cfg/table.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
@fionaliao
Copy link
Contributor Author

i recommend you grep for aggregations throughout the repo to find what needs updating.

This has been done, mainly in these two commits: https://github.com/grafana/carbon-relay-ng/pull/485/files/0379100cd31a361bbf0fcb3b7da04e9f7219d88a..414da429ba9bd73f696938cf7c843d8b0faa0db3

jsonnet (remove the default)

I decided to keep the aggregation file config in the jsonnet, but only add the file to the config map if $._config.storage_aggregation was not null:

storage_schemas: importstr 'files/storage-schemas.conf',
// You can set storage_aggregation to null if you don't have an
// aggregation file and want to use Grafana Cloud's default aggregations
// instead. (And in that case, don't forget to remove the aggregationFile
// setting in carbon-relay-ng.ini.)
storage_aggregation: importstr 'files/storage-aggregation.conf',
},
local configMap = k.core.v1.configMap,
carbon_relay_ng_config_map:
configMap.new('carbon-relay-ng-config') +
configMap.mixin.metadata.withNamespace($._config.namespace) +
configMap.withData(
{
'carbon-relay-ng.ini': $._config.crng_config,
'storage-schemas.conf': $._config.storage_schemas,
[if $._config.storage_aggregation != null then 'storage-aggregation.conf']: $._config.storage_aggregation,
}
),

The reasoning was that having the aggregation file and configmap set up is a useful reference if you want to configure your aggregations, but there are also simple and clear steps you can take if you don't want to send an aggregation file.

@Dieterbe
Copy link
Contributor

I decided to keep the aggregation file config in the jsonnet

ok. does the default match what we have in cloud v5?

@@ -163,7 +171,7 @@ func NewGrafanaNet(key string, matcher matcher.Matcher, cfg GrafanaNetConfig) (R
if cfg.AggregationFile != "" {
aggregation, err = conf.ReadAggregations(cfg.AggregationFile)
if err != nil {
return nil, fmt.Errorf("NewGrafanaNet: could not read aggregationFile %q: %s", cfg.AggregationFile, err.Error())
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

why? and why do we do it differently here than in NewGrafanaNetConfig() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just wraps the original (pre-PR) ReadAggregations(...) call in an if-else because it's possible that no file will be supplied.

I see you're commenting against a diff within two commits of the PR though:
image
In an earlier commit, I added the "NewGrafanaNet:..." error since I'd removed the aggregation file parameter from NewGrafanaNetConfig(). After the suggestion to keep the aggregation file parameter, I reverted that change and then reverted the error in this method back to what it was originally - just returning the error from reading the aggregations.

Signed-off-by: Fiona Liao <fiona.y.liao@gmail.com>
@fionaliao
Copy link
Contributor Author

ok. does the default match what we have in cloud v5?

It didn't, but I updated the examples to match in e4294f0

Copy link
Contributor

@Dieterbe Dieterbe left a comment

Choose a reason for hiding this comment

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

nice work, fiona. thanks!

@Dieterbe Dieterbe merged commit 6970b8c into master Feb 25, 2022
@Dieterbe Dieterbe deleted the fl/optional-aggregation-file branch February 25, 2022 19:01
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