kubebuilder icon indicating copy to clipboard operation
kubebuilder copied to clipboard

:sparkles: Experimental practice to scaffold dashboard manifest for custom metrics

Open Kavinjsir opened this issue 3 years ago • 5 comments
trafficstars

(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

  1. Specify custom metrics in config.yaml
---
customMetrics:
  - metric: memcached_operator_reconcile_total
    type: counter
  - metric: memcached_operator_reconcile_time_seconds_bucket
    type: histogram
  1. Run kubebuilder edit --plugins=grafana.kubebuilder.io/v1-alpha1 to generate the manifest
  2. Import the manifest into Grafana Web UI:

Kavinjsir avatar Aug 04 '22 09:08 Kavinjsir

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 avatar Aug 04 '22 09:08 k8s-ci-robot

@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.

k8s-ci-robot avatar Aug 16 '22 06:08 k8s-ci-robot

@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.

k8s-ci-robot avatar Aug 16 '22 06:08 k8s-ci-robot

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

Kavinjsir avatar Aug 16 '22 16:08 Kavinjsir

/ok-to-test

camilamacedo86 avatar Sep 02 '22 17:09 camilamacedo86

/approved

camilamacedo86 avatar Sep 02 '22 17:09 camilamacedo86

[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

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 avatar Sep 02 '22 17:09 k8s-ci-robot

/test pull-kubebuilder-test

camilamacedo86 avatar Sep 02 '22 18:09 camilamacedo86

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

camilamacedo86 avatar Sep 02 '22 18:09 camilamacedo86

/test pull-kubebuilder-e2e-k8s-1-19-16

camilamacedo86 avatar Sep 02 '22 18:09 camilamacedo86

/test pull-kubebuilder-test

Kavinjsir avatar Sep 02 '22 18:09 Kavinjsir

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

Kavinjsir avatar Sep 03 '22 18:09 Kavinjsir

/test pull-kubebuilder-e2e-k8s-1-19-16

Kavinjsir avatar Sep 03 '22 18:09 Kavinjsir

/test pull-kubebuilder-test

Kavinjsir avatar Sep 03 '22 18:09 Kavinjsir

/test pull-kubebuilder-e2e-k8s-1-19-16 /test pull-kubebuilder-test

camilamacedo86 avatar Sep 03 '22 21:09 camilamacedo86

/test pull-kubebuilder-test

camilamacedo86 avatar Sep 05 '22 07:09 camilamacedo86

/test pull-kubebuilder-test

camilamacedo86 avatar Sep 05 '22 08:09 camilamacedo86

See that the two test cases remain erroring. Would you like me to fix it by additional coding? @varshaprasad96 @camilamacedo86

Kavinjsir avatar Sep 05 '22 16:09 Kavinjsir

/lgtm

camilamacedo86 avatar Sep 06 '22 05:09 camilamacedo86