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

Loki mixin: make labelsSelector in loki chunks dashboards configurable #5536

Merged
merged 1 commit into from
Mar 4, 2022
Merged

Loki mixin: make labelsSelector in loki chunks dashboards configurable #5536

merged 1 commit into from
Mar 4, 2022

Conversation

jiachengxu
Copy link
Contributor

@jiachengxu jiachengxu commented Mar 4, 2022

What this PR does / why we need it:
This PR makes labelsSelector in loki chunks dashboards configurable so that it can be configured for different Loki installations.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Add an entry in the CHANGELOG.md about the changes.

@jiachengxu jiachengxu requested a review from a team as a code owner March 4, 2022 05:30
@jiachengxu jiachengxu changed the title Loki mixin: make labelsSelector in loki chunks dashboards configurable Loki mixins: make labelsSelector in loki chunks dashboards configurable Mar 4, 2022
@jiachengxu jiachengxu changed the title Loki mixins: make labelsSelector in loki chunks dashboards configurable Loki mixin: make labelsSelector in loki chunks dashboards configurable Mar 4, 2022
Copy link
Contributor

@dannykopping dannykopping 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 this @jiachengxu 👍
Can you try out my suggestion below please?

@@ -16,14 +16,14 @@ local utils = import 'mixin-utils/utils.libsonnet';
$.row('Active Series / Chunks')
.addPanel(
$.panel('Series') +
$.queryPanel('sum(loki_ingester_memory_chunks{%s})' % labelsSelector, 'series'),
$.queryPanel('sum(loki_ingester_memory_chunks{%s})' % dashboards['loki-chunks.json'].labelsSelector, 'series'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these can all reference self

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @dannykopping for the review.
I just tried:

$mixtool lint dashboards.libsonnet                                                                                                           
RUNTIME ERROR: Field does not exist: labelsSelector
	dashboards/loki-chunks.libsonnet:19:83-102
	<std>:237:21-22	thunk from <function <anonymous>>
	<std>:776:20-24	thunk from <function <anonymous>>
	<std>:32:25-26	thunk from <function <anonymous>>
	<std>:32:16-27	function <anonymous>
	<std>:776:8-25	function <anonymous>
	<std>:237:7-23	function <anonymous>
	dashboards/loki-chunks.libsonnet:19:42-102
	/Users/jiachengxu/projects/github.com/grafana/loki/production/loki-mixin/vendor/grafana-builder/grafana.libsonnet:234:19-26	thunk from <object <anonymous>>
	/Users/jiachengxu/projects/github.com/grafana/loki/production/loki-mixin/vendor/grafana-builder/grafana.libsonnet:234:10-27	object <anonymous>
	...
	/Users/jiachengxu/projects/github.com/grafana/loki/production/loki-mixin/vendor/grafana-builder/grafana.libsonnet:255:17-24	object <anonymous>
	/Users/jiachengxu/projects/github.com/grafana/loki/production/loki-mixin/vendor/grafana-builder/grafana.libsonnet:(246:15)-(256:6)
	/Users/jiachengxu/projects/github.com/grafana/loki/production/loki-mixin/vendor/grafana-builder/grafana.libsonnet:(246:15)-(256:6)	+:
	Field "targets"
	Array element 0
	Field "panels"
	Array element 0
	Field "rows"
	Field "loki-chunks.json"
	During manifestation

I think the reason is that the labelsSelector doesn't belong to the current object(https://github.com/grafana/loki/pull/5536/files#diff-d15d89e43869bd43b09a788d084921eff62a763bbb4c7df33c95cb919a7bd644R7-R10)

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I think it'd be best to make it a local then; I'm not sure what value there is in having this as a field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but this PR is trying to switch from local to a field, to make it configurable for different use cases. local basically cannot be overridden if you want to use a different labelsSelector.
I saw similar use cases in other dashboards: https://github.com/grafana/loki/blob/main/production/loki-mixin/dashboards/loki-operational.libsonnet#L35 for example, in this dashboard, user can override matchers for difference use cases

Copy link
Contributor

Choose a reason for hiding this comment

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

local basically cannot be overridden if you want to use a different labelsSelector

Ah, right. Got it.
I think we need to take a more deliberate approach with the labelsSelector, then. This implementation feels a little hacky.

For now, I think let's merge it and we should try split this file up and provide a cleaner way to override these labelsSelectors in the future.

Thanks 👍

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@dannykopping dannykopping enabled auto-merge (squash) March 4, 2022 06:51
Signed-off-by: Jiacheng Xu <jiachengxu@users.noreply.github.com>
auto-merge was automatically disabled March 4, 2022 06:52

Head branch was pushed to by a user without write access

@jiachengxu
Copy link
Contributor Author

jiachengxu commented Mar 4, 2022

@dannykopping Thanks for your help! Would you mind approve it again? I just squashed the commits but looks like it can not be auto-merged

@dannykopping
Copy link
Contributor

@dannykopping Thanks for your help! Would you mind approve it again? I just squashed the commits but looks like it can not be auto-merged

For future reference, there's no need to squash your commits because we squash-merge anyway 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants