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

[ENHANCEMENT] Add grouped variable helper in Go SDK #1752

Merged
merged 2 commits into from
Feb 12, 2024

Conversation

Gladorme
Copy link
Member

@Gladorme Gladorme commented Feb 9, 2024

Description

Align Go SDK with Cue feature, you can create grouped variables. Grouped variables will be filtered by their parent variables. For now, it only applied automatically to label values and label names variables matchers.

Prev:

	dashboard.AddVariable("stack",
		listVar.List(
			labelValuesVar.PrometheusLabelValues("stack",
				labelValuesVar.Matchers("thanos_build_info{}"),
				labelValuesVar.Datasource("promDemo"),
			),
			listVar.DisplayName("PaaS"),
		),
	),
	dashboard.AddVariable("namespace", listVar.List(
		labelValuesVar.PrometheusLabelValues("namespace",
			labelValuesVar.Matchers("kube_namespace_labels{\"stack\"=\"$stack\"}"),
			labelValuesVar.Datasource("promDemo"),
		),
	)),
	dashboard.AddVariable("namespaceLabels", listVar.List(
		labelNamesVar.PrometheusLabelNames(
			labelNamesVar.Matchers("kube_namespace_labels{\"stack\"=\"$stack\", \"namespace\"=\"$namespace\"}"),
			labelNamesVar.Datasource("promDemo"),
		),
	)),
	dashboard.AddVariable("pod", listVar.List(
		labelValuesVar.PrometheusLabelValues("pod",
			labelValuesVar.Matchers("kube_namespace_labels{\"stack\"=\"$stack\", \"namespace\"=\"$namespace\"}"),
			labelValuesVar.Datasource("promDemo"),
		),
	)),

New:

dashboard.AddVariableGroup(
	group.AddVariable("stack",
		listVar.List(
			labelValuesVar.PrometheusLabelValues("stack",
				labelValuesVar.Matchers("thanos_build_info"),
				labelValuesVar.Datasource("promDemo"),
			),
			listVar.DisplayName("PaaS"),
		),
	),
	group.AddVariable("namespace", listVar.List(
		labelValuesVar.PrometheusLabelValues("namespace",
			labelValuesVar.Matchers("kube_namespace_labels"),
			labelValuesVar.Datasource("promDemo"),
		),
	)),
	group.AddIgnoredVariable("namespaceLabels", listVar.List(
		labelNamesVar.PrometheusLabelNames(
			labelNamesVar.Matchers("kube_namespace_labels"),
			labelNamesVar.Datasource("promDemo"),
		),
	)),
	group.AddVariable("pod", listVar.List(
		labelValuesVar.PrometheusLabelValues("pod",
			labelValuesVar.Matchers("kube_namespace_labels"),
			labelValuesVar.Datasource("promDemo"),
		),
	)),
),

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

@Gladorme Gladorme changed the base branch from main to feat/dashboard-as-code February 9, 2024 15:43
@Gladorme Gladorme force-pushed the gladorme/grouped-var branch 2 times, most recently from 39c4c5d to 9b5d8ed Compare February 9, 2024 16:23
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
@Gladorme Gladorme marked this pull request as ready for review February 9, 2024 17:01
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
@Gladorme Gladorme merged commit 0490a24 into feat/dashboard-as-code Feb 12, 2024
19 checks passed
@Gladorme Gladorme deleted the gladorme/grouped-var branch February 12, 2024 09:33
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

2 participants