-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
✨📖 [plugins]: Create monitoring plugin #3106
Conversation
|
Hi @avlitman. 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 Once the patch is verified, the new status will be reflected by the 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: avlitman The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @machadovilaca @sradco @varshaprasad96 @everettraven @assafad. Notes: @machadovilaca: |
a36bb60
to
dba9c2b
Compare
dba9c2b
to
e5df7f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to discuss this one. So, just putting in hold for we are able to properly get the review and discuss the initiative.
@@ -132,16 +135,17 @@ scaffold_test_project project-v2 --project-version=2 | |||
# [Currently, default CLI plugin] - Project version 3 (default) uses plugin go/v3 (default). | |||
scaffold_test_project project-v3 | |||
scaffold_test_project project-v3-multigroup | |||
scaffold_test_project project-v3-declarative-v1 --plugins="go/v3,declarative,grafana/v1-alpha" | |||
scaffold_test_project project-v3-declarative-v1 --plugins="go/v3,declarative,grafana/v1-alpha,monitoring/v1-alpha" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we you please do not add this plugin here? we should have in the declarative one juts the declarative.
Therefore, we need to remove the grafana/v1-alpha from master branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@camilamacedo86
We need to test both the init
and edit
commands with the new monitoring plugin.
at first I used scaffold_test_project project-v4-monitoring --plugins="go/v4-alpha,monitoring.kubebuilder.io/v1-alpha"
to test the init commend.
but it created a confusing naming under testdata folder
project-v*-monitoring
project-v*-with-monitoring
Later I followed @varshaprasad96 suggestion:
"
I would suggest to test both the init and edit commands. We should have scaffold_test_project project-v4-with-monitoring and the other scaffolding which calls this command chained with other plugins (whichever seems fit), probably `scaffold_test_project project-v4-declarative-v1 --plugins="go/v4-alpha,declarative,grafana/v1-alpha,monitoring/v1-alpha". This will make sure that a user with pre-scaffolded project is able to add the monitoring plugin with the edit command, as well as someone who is scaffolding their project for the first time can chain this plugin with existing ones during init.
"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@varshaprasad96 and @everettraven suggested this to test all the plugins together, in oreder to see there are no conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So thinking about this again (I now think I understand the original problem better than I did before), I understand @camilamacedo86's reasoning for wanting them separate (definitely better for testing/maintenance IMO).
I don't feel particularly strongly one way or another but if I had to choose I would probably vote for separate project scaffolds. I understand that it could be confusing names under the testdata folder but in the end I think we need to do what is better for testing and maintenance. I think maybe naming the projects project-v*-init-monitoring
and project-v*-edit-monitoring
might make it a bit more clear which project was created with which subcommand.
scaffold_test_project project-v3-config --component-config | ||
scaffold_test_project project-v3-with-deploy-image | ||
scaffold_test_project project-v3-with-metrics | ||
scaffold_test_project project-v3-with-monitoring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add this new plugin to the metrics sample with seems the category releated and allow us to check only the diff scaffolds that will be done by it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@camilamacedo86 This is the plan, and it will be done in later PR.
// constant parts of the file | ||
const ( | ||
title = "# sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1 Operator Metrics\n" | ||
background = "This document aims to help users that are not familiar with metrics exposed by the sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1 operator.\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cannot scaffold it by default.
The final result of the plugin should not point out users for the master samples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, same of : https://github.com/kubernetes-sigs/kubebuilder/pull/3106/files#r1037114035
It does not fit to an end-project scaffold. It should be a lib, tool and etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan is to give an example scaffold for adding new metrics, the files can be commented also.
but it's not by default, the user will need to init/edit with monitoring plugin in order to get these files.
footer = footerHeading + footerContent | ||
) | ||
|
||
func main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is really required to implement a util to do that?
If that is a common good practice so have not tools and etc that does it already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@camilamacedo86 Yes, This is a very useful addition for creating an automated metrics documentation.
It we be automatically updated after every new metric is added.
We plan to also add to it the recording rules, since they are used the same as metrics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @camilamacedo86 is trying to point out here is that if every operator project that wants to create/use metrics needs to use this tooling, it might be better to instead have a library/binary with this functionality that can import/download/build and be used instead of scaffolding it in every operator project.
I agree with @camilamacedo86 here that we should probably consider finding a way to make this code reusable by many operator projects without actually scaffolding this code in every operator project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,145 @@ | |||
package util |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not this kind of implementation fit better in a lib such as controller-runtime or operator-lib or a new one since prometheus-lib?
If all projects would need to use this func so that does not seems reasonable to be scaffolded in a plugin for the final projects. That really seems to be more appropriated in a lib (ihmo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@camilamacedo86 Not sure I understand right your comment, but this implementation (util) is only for adding Prometheus metrics to the operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @camilamacedo86 is trying to point out here is that if every operator that wants to use metrics will have to use these utility functions, it may be better to make them a Go library that can be imported rather than scaffolded in every project.
I guess this ends up posing the question - Will every operator that wants to use metrics need to implement these utility functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ihmo) what is proposed by this plugin do the scaffold fit better in libs/tools and not to the final "Operator" project itself. The project itself could take benefit and use the lib to generate the metrics and/or the binary to build the docs. Therefore, explain the good practices and how to use the libs / tools that could fit in docs.
However, if you would like to have a plugin to scaffold that and does not go along within the above thought then I think that is good case for external plugins. @varshaprasad96 @everettraven @Kavinjsir @erikgb wdyt? What are your thoughts about this one?
Hi @camilamacedo86 , thank you so much for reviewing this PR! |
testdata/project-v3-with-monitoring/monitoring/metrics/example_metrics.go
Outdated
Show resolved
Hide resolved
cff5220
to
85cdb6e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round. Overall everything looks good, but I share a few of the concerns @camilamacedo86 has regarding scaffolding code in every operator project that may be better suited to being a library.
|
||
- `monitoring/` | ||
- `main.go` | ||
- `MakeFile` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
- `MakeFile` | |
- `Makefile` |
|
||
var OperatorMetrics = []util.Metric{ | ||
// When adding new metrics, Please follow the naming conventions best practices | ||
// TODO: Add the link to the Observability Best Practices - Metrics Naming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend moving this TODO comment out of this template. Having it in the template makes it seem like it is something the user of the monitoring plugin will have to do, but should instead be something that is included in the template (once it is available).
} | ||
} | ||
|
||
// TODO: add here a comment about the functions to explain what they do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO comment seems more related to the maintainers of the monitoring plugin and not the user. I would recommend moving it out of the scaffold template.
_out/metricsdocs > docs/monitoring/metrics.md | ||
|
||
.PHONY: build-metricsdocs | ||
build-metricsdocs: | ||
go build -ldflags="${LDFLAGS}" -o _out/metricsdocs ./monitoring/tools/metricsdocs.go | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is specifically a tool for development purposes (i.e not running in production as part of the operator) I think it might be a bit overkill to actually build a binary for generating the metrics docs.
I would personally prefer something like:
_out/metricsdocs > docs/monitoring/metrics.md | |
.PHONY: build-metricsdocs | |
build-metricsdocs: | |
go build -ldflags="${LDFLAGS}" -o _out/metricsdocs ./monitoring/tools/metricsdocs.go | |
` | |
go run ./monitoring/tools/metricsdocs.go > docs/monitoring/metrics.md | |
` |
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would fit well as a third-party project with the lib.
Therefore it shows too much Prometheus specific why not add those in the Prometheus project (https://github.com/prometheus/) and allow anyone that is using kubebuilder or not to take advantage of it?
@@ -132,16 +135,17 @@ scaffold_test_project project-v2 --project-version=2 | |||
# [Currently, default CLI plugin] - Project version 3 (default) uses plugin go/v3 (default). | |||
scaffold_test_project project-v3 | |||
scaffold_test_project project-v3-multigroup | |||
scaffold_test_project project-v3-declarative-v1 --plugins="go/v3,declarative,grafana/v1-alpha" | |||
scaffold_test_project project-v3-declarative-v1 --plugins="go/v3,declarative,grafana/v1-alpha,monitoring/v1-alpha" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So thinking about this again (I now think I understand the original problem better than I did before), I understand @camilamacedo86's reasoning for wanting them separate (definitely better for testing/maintenance IMO).
I don't feel particularly strongly one way or another but if I had to choose I would probably vote for separate project scaffolds. I understand that it could be confusing names under the testdata folder but in the end I think we need to do what is better for testing and maintenance. I think maybe naming the projects project-v*-init-monitoring
and project-v*-edit-monitoring
might make it a bit more clear which project was created with which subcommand.
@@ -0,0 +1,145 @@ | |||
package util |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @camilamacedo86 is trying to point out here is that if every operator that wants to use metrics will have to use these utility functions, it may be better to make them a Go library that can be imported rather than scaffolded in every project.
I guess this ends up posing the question - Will every operator that wants to use metrics need to implement these utility functions?
footer = footerHeading + footerContent | ||
) | ||
|
||
func main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @camilamacedo86 is trying to point out here is that if every operator project that wants to create/use metrics needs to use this tooling, it might be better to instead have a library/binary with this functionality that can import/download/build and be used instead of scaffolding it in every operator project.
I agree with @camilamacedo86 here that we should probably consider finding a way to make this code reusable by many operator projects without actually scaffolding this code in every operator project.
85cdb6e
to
eb95c9b
Compare
GitHub-issue: kubernetes-sigs#3078 Signed-off-by: Aviv Litman <[email protected]> Uncomment monitoring go files Signed-off-by: João Vilaça <[email protected]> Generate working monitoring scaffolding Signed-off-by: João Vilaça <[email protected]> Allow kubebuilder init with monitoring bundle Signed-off-by: João Vilaça <[email protected]> Add metrics register to main file Signed-off-by: João Vilaça <[email protected]> Update testdata Signed-off-by: João Vilaça <[email protected]> Improve comments Signed-off-by: Aviv Litman <[email protected]>
eb95c9b
to
28fe31e
Compare
@avlitman I have a similar idea to what @camilamacedo86 brought: |
@camilamacedo86 @Kavinjsir I have added the questions based on our discussions and some of my thoughts here: #3078 (comment). |
@avlitman: PR needs rebase. 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. |
Hi @camilamacedo86 @everettraven @varshaprasad96 @Kavinjsir @sradco Since we still discussing the implementation method, and the capacity to maintain this by our team. |
Closing this one as not accepted, for further information see: #3078. |
We would like to add a new monitoring plugin that will help operators developer with setting up Prometheus based monitoring for their operator, will provide them with best practices and tooling to shorten their time to get up to speed with monitoring requirements and help with standardizing the way monitoring is implemented in operators.
Fixes Add Monitoring Plugin #3078
Signed-off-by: Aviv Litman [email protected]