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

✨ Initialize the Grafana plugin #2718

Merged

Conversation

Kavinjsir
Copy link
Contributor

@Kavinjsir Kavinjsir commented Jun 10, 2022

Description of the Change

Initialize the Grafana plugin with the basic function to scaffold raw json manifest that can be copied to Grafana Web UI to visualize the controller/operator status.

Plugin Basic Function

  • Scaffold a new grafana folder with dashboard manifests (raw json to be imported to Grafana UI)

Sample Usage

output2

Motivation

This is the starting entry for developing the Grafana plugin.
Relative EP is in PR: #2708

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 10, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @Kavinjsir. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 10, 2022
@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch from cbafd02 to 02cd2ed Compare June 11, 2022 06:26
@Kavinjsir Kavinjsir changed the title Draft: ✨ Initialize the Grafana plugin WIP: ✨ Initialize the Grafana plugin Jun 11, 2022
@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch from 02cd2ed to cc599f8 Compare June 13, 2022 19:25
@Kavinjsir Kavinjsir marked this pull request as ready for review June 13, 2022 21:09
@k8s-ci-robot k8s-ci-robot requested a review from joelanford June 13, 2022 21:10
cmd/main.go Outdated Show resolved Hide resolved
@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch from cc599f8 to aefb041 Compare June 13, 2022 23:08
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 13, 2022
@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch 2 times, most recently from 75f103b to 071265a Compare June 13, 2022 23:43
@Kavinjsir Kavinjsir changed the title WIP: ✨ Initialize the Grafana plugin ✨ Initialize the Grafana plugin Jun 13, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 13, 2022
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
Copy link
Member

Choose a reason for hiding this comment

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

should we have a dashaboard with all or could we divide per category?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we have a dashaboard with all or could we divide per category?

Are we talking about displaying all default metrics in dashboards? (If so, I feel like having multiple dashboards for different groups of metrics makes more sense, since there are so many..)

Talking about one single dashboard, it is available to divide panels into different folders, so that some folders can be folded up in case of the limited web page size.

Copy link
Member

Choose a reason for hiding this comment

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

Why we need many folders?
Could not be dashboards and we have <metric_category>.json

@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch from 071265a to 4343371 Compare June 14, 2022 16:43
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 14, 2022
@Kavinjsir
Copy link
Contributor Author

Just added test cases bymake generate.

Some error happens when running make test-e2e-local:
Screen Shot 2022-06-14 at 1 37 15 PM

Will see if it works for CI tests.

@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch from dacff4f to 3a57b94 Compare June 23, 2022 19:44
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 27, 2022
@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch from 3a57b94 to f3a6ba4 Compare June 28, 2022 07:15
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 28, 2022
@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch from f3a6ba4 to de641bd Compare June 28, 2022 07:59
@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-18-20

cmd/main.go Outdated
@@ -33,6 +33,7 @@ import (
deployimagev1alpha1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/deploy-image/v1alpha1"
golangv2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2"
golangv3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
grafana "sigs.k8s.io/kubebuilder/v3/pkg/plugins/optional/grafana/alphav1"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
grafana "sigs.k8s.io/kubebuilder/v3/pkg/plugins/optional/grafana/alphav1"
grafanaalphav1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/optional/grafana/alphav1"

Could we change the alias to have alphav1 so that we follow its standards?

Copy link
Member

Choose a reason for hiding this comment

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

@camilamacedo86 @Kavinjsir Wdyt about renaming the directory to v1alpha instead of alphav1, to make it in sync with other plugin naming.
The path would be sigs.k8s.io/kubebuilder/v3/pkg/plugins/optional/grafana/v1alpha, the alias would be grafanav1alpha

*/

package alphav1

Copy link
Member

Choose a reason for hiding this comment

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

See that code for init and edit are the same. Therefore we can centralize the content by:
a) creating a new file constants.go and adding all contacts there for the examples and descriptions
b) creating a new file commons.go and centralize the code that is used in both by encapsulating them with cohesion to be called in the subcommand implementations.

@@ -1,6 +1,8 @@
domain: testproject.org
layout:
- go.kubebuilder.io/v3
plugins:
grafana.kubebuilder.io/v1-alpha: {}
Copy link
Member

Choose a reason for hiding this comment

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

Terrific 🥇

@@ -112,6 +112,7 @@
- [go/v2 plugin (Deprecated)](./plugins/go-v2-plugin.md)
- [go/v3 plugin](./plugins/go-v3-plugin.md)
- [Declarative V1](./plugins/declarative-v1.md)
- [Grafana V1](./plugins/grafana-v1-alpha.md)
Copy link
Member

Choose a reason for hiding this comment

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

we ne

Suggested change
- [Grafana V1](./plugins/grafana-v1-alpha.md)
- [grafana/v1-alpha](./plugins/grafana-v1-alpha.md)


The plugin will create a new directory and scaffold the JSON files under it (i.e. `grafana/controller-runtime-metrics.json`).

#### Grafana Manifest Usage
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#### Grafana Manifest Usage
#### Now, let's check how to use the Grafana Dashboards

cmd/main.go Outdated
@@ -33,6 +33,7 @@ import (
deployimagev1alpha1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/deploy-image/v1alpha1"
golangv2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2"
golangv3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
grafana "sigs.k8s.io/kubebuilder/v3/pkg/plugins/optional/grafana/alphav1"
Copy link
Member

Choose a reason for hiding this comment

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

@camilamacedo86 @Kavinjsir Wdyt about renaming the directory to v1alpha instead of alphav1, to make it in sync with other plugin naming.
The path would be sigs.k8s.io/kubebuilder/v3/pkg/plugins/optional/grafana/v1alpha, the alias would be grafanav1alpha

<img width="644" alt="Screen Shot 2022-06-28 at 3 40 22 AM" src="https://user-images.githubusercontent.com/18136486/176121955-1c4aec9c-0ba4-4271-9767-e8d1726d9d9a.png">
4. Select the data source for Prometheus metrics
<img width="633" alt="Screen Shot 2022-06-28 at 3 41 26 AM" src="https://user-images.githubusercontent.com/18136486/176122261-e3eab5b0-9fc4-45fc-a68c-d9ce1cfe96ee.png">
5. Once `import` the json, the dashboard is ready.
Copy link
Member

Choose a reason for hiding this comment

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

Nit

Suggested change
5. Once `import` the json, the dashboard is ready.
5. Once the json is imported in grafana, the dashboard is ready.

@Kavinjsir Kavinjsir force-pushed the feat/grafana-plugin-base branch from de641bd to fae8f05 Compare June 28, 2022 21:13
@Kavinjsir
Copy link
Contributor Author

/test pull-kubebuilder-e2e-k8s-1-18-20

1 similar comment
@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-18-20

Copy link
Member

@varshaprasad96 varshaprasad96 left a comment

Choose a reason for hiding this comment

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

Looks good, nice work @Kavinjsir!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 29, 2022
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/approved

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 30, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, Kavinjsir, varshaprasad96

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 30, 2022
@k8s-ci-robot k8s-ci-robot merged commit 68b0809 into kubernetes-sigs:master Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants