kubebuilder
kubebuilder copied to clipboard
:sparkles: Experimental practice to scaffold dashboard manifest for custom metrics
(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:
---
customMetrics: []
# - metric: Raw custom metric (required)
# type: Metric type: counter/gauge/histogram (required)
# expr: Prom_ql for the metric (optional)
(If you execute the plugin for the first time(either by init or edit), the above config template will be automatically generated.)
The plugin triggered by edit subcommand will read the config.yaml and generate grafana/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:
# Initialize a project with the plugin enabled
kubebuilder init --plugins=grafana.kubebuilder.io/v1-alpha
# Introduce the Grafana Plugin to an existing project
kubebuilder edit --plugins=grafana.kubebuilder.io/v1-alpha
A nested custom-metrics/config.yaml will be generated under grafana/.
Story 2
Users configure grafana/custom-metrics/config.yaml and run edit subcommand to get Grafana manifest:
kubebuilder edit --plugins=grafana.kubebuilder.io/v1-alpha
The grafana/custom-metrics/config.yaml will be validated and then the manifest will be generated: grafana/custom-metrics/custom-metrics-dashboard.json.
Sample
- Specify custom metrics in config.yaml
---
customMetrics:
- metric: memcached_operator_reconcile_total
type: counter
- metric: memcached_operator_reconcile_time_seconds_bucket
type: histogram
- Run
kubebuilder edit --plugins=grafana.kubebuilder.io/v1-alpha1to generate the manifest - Import the manifest into Grafana Web UI:
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.
@Kavinjsir: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.
In response to this:
/test lint
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 /ok-to-test message.
In response to this:
/test Lint
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 grafana/custom-metrics/config.yaml is exposed to customize the panels, I'm also looking for methods to test the plugin upon a sample config.
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 kubebuilder edit ... follow by that in the integration test?
cc: @varshaprasad96 @camilamacedo86 @rashmigottipati
/ok-to-test
/approved
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: camilamacedo86, Kavinjsir
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [camilamacedo86]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/test pull-kubebuilder-test
/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-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
/test pull-kubebuilder-test
/test pull-kubebuilder-test
See that the two test cases remain erroring. Would you like me to fix it by additional coding? @varshaprasad96 @camilamacedo86
/lgtm