-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
✨ Experimental practice to scaffold dashboard manifest for custom metrics #2858
✨ Experimental practice to scaffold dashboard manifest for custom metrics #2858
Conversation
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 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. |
b5194c9
to
15df8cd
Compare
pkg/plugins/optional/grafana/v1alpha/scaffolds/internal/templates/custom.go
Show resolved
Hide resolved
22a4e5a
to
81e8ddc
Compare
81e8ddc
to
3fb8a89
Compare
@Kavinjsir: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
@Kavinjsir: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
Since Right now the integration test will generate test data from 0 to 1. I'm wondering how we may insert a config template such as: ---
customMetrics:
- metric: memcached_operator_reconcile_total
type: counter
- metric: memcached_operator_reconcile_time_seconds_bucket
type: histogram And run |
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.
Good work @Kavinjsir ! Just a few nits.
return false | ||
} | ||
|
||
func fillMissingExpr(item templates.CustomMetricItem) templates.CustomMetricItem { |
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 this func adds a default expression when user does not provide it?
If so, is it compatible with all the three kinds of prometheus metrics like gauge, counter 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.
so this func adds a default expression when user does not provide it?
Yes, the current design is the plugin will check if the user provides expr
, if missed, then filled a basic one.
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 it compatible with all the three kinds of prometheus metrics like gauge, counter etc.
Yes, very basic though:
- counter:
sum(rate(custom_metric{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, pod)
- histogram:
histogram_quantile(0.90, sum by(instance, le) (rate(custom_metric{job=\"$job\", namespace=\"$namespace\"}[5m])))
- gauge: the custom_metric itself (show the value directly)
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 be glad if we have better choices of expr
, especially for gauge
.
(Not quite confident to bring further prom_ql for gauge
since it seems such fluctuating values might be observed in various perspectives..)
3d40a17
to
9180448
Compare
/test pull-kubebuilder-test |
/test pull-kubebuilder-e2e-k8s-1-18-20 |
/test pull-kubebuilder-e2e-k8s-1-19-16 |
/test pull-kubebuilder-test |
ca98b1a
to
c1fcb7e
Compare
/test pull-kubebuilder-e2e-k8s-1-18-20 |
/test pull-kubebuilder-e2e-k8s-1-19-16 |
/test pull-kubebuilder-test |
/test pull-kubebuilder-e2e-k8s-1-19-16 |
/test pull-kubebuilder-test |
1 similar comment
/test pull-kubebuilder-test |
See that the two test cases remain erroring. Would you like me to fix it by additional coding? |
} | ||
] | ||
}, | ||
"unit": "s" |
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.
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.
configurable units would be much appreciated!
return false | ||
} | ||
|
||
func fillMissingExpr(item templates.CustomMetricItem) templates.CustomMetricItem { |
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 this func adds a default expression when user does not provide it?
Yes, the current design is the plugin will check if the user provides expr
, if missed, then filled a basic one.
return false | ||
} | ||
|
||
func fillMissingExpr(item templates.CustomMetricItem) templates.CustomMetricItem { |
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 it compatible with all the three kinds of prometheus metrics like gauge, counter etc.
Yes, very basic though:
- counter:
sum(rate(custom_metric{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, pod)
- histogram:
histogram_quantile(0.90, sum by(instance, le) (rate(custom_metric{job=\"$job\", namespace=\"$namespace\"}[5m])))
- gauge: the custom_metric itself (show the value directly)
customMetrics: | ||
# - metric: # Raw custom metric (required) | ||
# type: # Metric type: counter/gauge/histogram (required) | ||
# expr: # Prom_ql for the metric (optional) |
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.
Yeah, that makes sense. I'm not sure how could it be better. Right now, I just append an example following the template. Would this be good?
) | ||
|
||
var _ plugins.Scaffolder = &editScaffolder{} | ||
|
||
const ConfigFilePath = "grafana/custom-metrics/config.yaml" |
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.
Sounds good!
|
||
BeforeEach(func() { | ||
var err error | ||
kbc, err = utils.NewTestContext(pluginutil.KubebuilderBinName, "GO111MODULE=on") |
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.
Test error may come from here. Since such NewTestContext
would call kubectl
that assumes an existing kind
cluster.
test/e2e/plugin.sh
Outdated
@@ -0,0 +1,33 @@ | |||
#!/usr/bin/env bash |
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.
@Kavinjsir we should not add a new file here.
In this case, we need only in the Kubebuilder Makefile to call the test.
We would only need to execute this test once. However, to make simple let's call it with the others and a TODO here to sort it out after.
That means:
a) Remove this file plugin.sh
b) Add the new test in : https://github.com/kubernetes-sigs/kubebuilder/blob/master/test/e2e/setup.sh#L65
c) Revert the changes made in the Kubebuilder Makefile
d) Add a comment in the setup.sh and in the new e2e test like TODO: in this case, we do not need the cluster and we would not need to test against many k8s versions. So that it can be improved in the future.
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.
c/c @varshaprasad96
/hold
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.
Sounds good to me. I've updated the code based on the steps and it looks work well.
Co-authored-by: Varsha <varshaprasad96@gmail.com> Camila Macedo <camilamacedo86@gmail.com> - Scaffold `config.yaml` template - Load configured `config.yaml` to create manifest - Add test cases for custom metrics manifests - Documentation Go template syntax ref: https://stackoverflow.com/a/22375000
c1fcb7e
to
001daab
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.
/hold cancel
/lgtm |
(This PR is experimental and welcome discussion)
Description
This is the experimental practice to see how possible if we can bring dashboards for custom metrics through the Grafana Plugin.
The user can add the desired metrics in
grafana/custom-metrics/config.yaml
:(If you execute the plugin for the first time(either by
init
oredit
), the above config template will be automatically generated.)The plugin triggered by
edit
subcommand will read theconfig.yaml
and generategrafana/custom-metrics/custom-metrics-dashboard.json
, which can be directly import in the Grafana Web UI.Story 1
Users get the config entry when initialize the project or introduce the
grafana-plugin
for the first time:A nested
custom-metrics/config.yaml
will be generated undergrafana/
.Story 2
Users configure
grafana/custom-metrics/config.yaml
and runedit
subcommand to get Grafana manifest:The
grafana/custom-metrics/config.yaml
will be validated and then the manifest will be generated:grafana/custom-metrics/custom-metrics-dashboard.json
.Sample
kubebuilder edit --plugins=grafana.kubebuilder.io/v1-alpha1
to generate the manifest