Skip to content

Comments

(feat): Add Metrics Exporter Sidecar to ValkeyCluster Pods#49

Merged
sandeepkunusoth merged 5 commits intovalkey-io:mainfrom
sandeepkunusoth:redis_exporter
Jan 12, 2026
Merged

(feat): Add Metrics Exporter Sidecar to ValkeyCluster Pods#49
sandeepkunusoth merged 5 commits intovalkey-io:mainfrom
sandeepkunusoth:redis_exporter

Conversation

@sandeepkunusoth
Copy link
Member

@sandeepkunusoth sandeepkunusoth commented Jan 12, 2026

This PR implements #28 by adding redis_exporter sidecar to ValkeyCluster pods (configurable via spec.exporter) so each pod exposes Valkey metrics on port 9121. also includes e2e tests to validate redis exporter metrics and small refactors to the existing e2e test suite(moved some common code from e2e_test.go to e2e_suite_test.go).

Signed-off-by: Sandeep Kunusoth <sandeepkunsoth000@gmail.com>
Signed-off-by: Sandeep Kunusoth <sandeepkunsoth000@gmail.com>
Signed-off-by: Sandeep Kunusoth <sandeepkunsoth000@gmail.com>
Signed-off-by: Sandeep Kunusoth <sandeepkunsoth000@gmail.com>
Copy link
Collaborator

@jdheyburn jdheyburn left a comment

Choose a reason for hiding this comment

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

Overall looks great! Just had a few minor comments

Signed-off-by: Sandeep Kunusoth <sandeepkunsoth000@gmail.com>
Copy link
Collaborator

@jdheyburn jdheyburn left a comment

Choose a reason for hiding this comment

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

Thank you!

@sandeepkunusoth sandeepkunusoth merged commit 44d674b into valkey-io:main Jan 12, 2026
4 checks passed
@sandeepkunusoth sandeepkunusoth deleted the redis_exporter branch January 12, 2026 17:32
Copy link
Collaborator

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

Nice. Added some comments/questions.

Affinity *corev1.Affinity `json:"affinity,omitempty"`

// Metrics exporter options
// +kubebuilder:default:={enabled:true}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change needed? And if yes; can we remove // +kubebuilder:default=true on line 88 in the ExporterSpec type now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this change is needed otherwise by default its becoming false. I will remove other change in next PR.

`, valkeyName)

// Create temporary YAML file
manifestFile := filepath.Join(os.TempDir(), fmt.Sprintf("%s-%d.yaml", valkeyName, time.Now().UnixNano()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need a unique name here?
We don't do this in the degraded state test where we use valkeycluster-degraded.yaml directly.

out, err := utils.Run(cmd)
g.Expect(err).NotTo(HaveOccurred(), "Deployment not found")
g.Expect(out).To(ContainSubstring(valkeyName))
}, 2*time.Minute, 5*time.Second).Should(Succeed())
Copy link
Collaborator

Choose a reason for hiding this comment

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

The default is 2 minutes, so we could remove all these extra timeouts to get rid of clutter

Suggested change
}, 2*time.Minute, 5*time.Second).Should(Succeed())
}).Should(Succeed())

Copy link
Member Author

Choose a reason for hiding this comment

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

yes forgot about this suggestion from past PRs. will update this in next PR.

`, valkeyName)

// Create temporary YAML file
manifestFile := filepath.Join(os.TempDir(), fmt.Sprintf("%s-%d.yaml", valkeyName, time.Now().UnixNano()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment here regarding including time in the filename.
If the reason is to enable it to run in parallel, maybe https://pkg.go.dev/os#CreateTemp is a better option to get uniqueness.


By("verifying common Valkey metrics are exposed")
Eventually(func(g Gomega) {
cmd := exec.Command("curl", "-s", "http://localhost:9121/metrics")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test now requires curl to be installed on the system.
An option that is to use a curl pod, that how the kubebuilder scaffolding gets the metrics from the controller.

hieu2102 pushed a commit to hieu2102/valkey-operator that referenced this pull request Jan 15, 2026
)

This PR implements
valkey-io#28 by adding
redis_exporter sidecar to ValkeyCluster pods (configurable via
spec.exporter) so each pod exposes Valkey metrics on port 9121. also
includes e2e tests to validate redis exporter metrics and small
refactors to the existing e2e test suite(moved some common code from
e2e_test.go to e2e_suite_test.go).

---------

Signed-off-by: Sandeep Kunusoth <sandeepkunsoth000@gmail.com>
hieu2102 pushed a commit to hieu2102/valkey-operator that referenced this pull request Jan 15, 2026
)

This PR implements
valkey-io#28 by adding
redis_exporter sidecar to ValkeyCluster pods (configurable via
spec.exporter) so each pod exposes Valkey metrics on port 9121. also
includes e2e tests to validate redis exporter metrics and small
refactors to the existing e2e test suite(moved some common code from
e2e_test.go to e2e_suite_test.go).

---------

Signed-off-by: Sandeep Kunusoth <31273507+sandeepkunusoth@users.noreply.github.com>
sandeepkunusoth added a commit that referenced this pull request Jan 15, 2026
…#54)

This PR fixes e2e test failing due to
#43 temporarily by
deleting replica deployment in e2e tests instead of deleting random
deployment (either replica or shard previously). We need to add back e2e
test to delete shard and allow it to recover once above issue is fixed.

Also addressed review comments from metrics exporter PR @bjosv
#49

---------

Signed-off-by: Sandeep Kunusoth <sandeepkunsoth000@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants