docs(monitoring): add custom metrics collection guide#444
Conversation
Explain how tenants can connect their own Prometheus exporters to the monitoring stack using VMServiceScrape and VMPodScrape CRDs, covering namespace labeling, example manifests, and verification steps. Signed-off-by: ohotnikov.ivan <[email protected]>
✅ Deploy Preview for cozystack ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds two new documentation pages (v0 and v1) describing how to collect custom metrics for tenant monitoring using VictoriaMetrics VMServiceScrape and VMPodScrape. Covers prerequisites, namespace labeling behavior, example manifests, key fields, verification steps, and troubleshooting. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces comprehensive documentation for integrating custom metrics into the Cozystack tenant monitoring stack. It provides clear instructions and examples for tenants to leverage Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds excellent documentation for collecting custom metrics. I've provided a few suggestions to improve the user experience by making the kubectl commands more self-contained and to clarify the usage of port selection in VMPodScrape. Overall, the documentation is clear and well-structured.
Note: Security Review has been skipped due to the limited scope of the PR.
| Suppose you have a Service named `my-app` in namespace `my-app-ns` that exposes metrics on port `metrics` at path `/metrics`: | ||
|
|
||
| ```yaml | ||
| apiVersion: operator.victoriametrics.com/v1beta1 | ||
| kind: VMServiceScrape | ||
| metadata: | ||
| name: my-app-metrics | ||
| namespace: my-app-ns | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: my-app | ||
| endpoints: | ||
| - port: metrics | ||
| path: /metrics | ||
| interval: 30s | ||
| ``` | ||
|
|
||
| Apply the resource: | ||
|
|
||
| ```bash | ||
| kubectl apply --filename vmservicescrape.yaml --namespace my-app-ns | ||
| ``` |
There was a problem hiding this comment.
To make the instructions easier to follow, consider combining the YAML definition and the kubectl apply command into a single, copy-pastable block using a heredoc. This prevents users from needing to manually create a file and reduces the potential for error.
| Suppose you have a Service named `my-app` in namespace `my-app-ns` that exposes metrics on port `metrics` at path `/metrics`: | |
| ```yaml | |
| apiVersion: operator.victoriametrics.com/v1beta1 | |
| kind: VMServiceScrape | |
| metadata: | |
| name: my-app-metrics | |
| namespace: my-app-ns | |
| spec: | |
| selector: | |
| matchLabels: | |
| app: my-app | |
| endpoints: | |
| - port: metrics | |
| path: /metrics | |
| interval: 30s | |
| ``` | |
| Apply the resource: | |
| ```bash | |
| kubectl apply --filename vmservicescrape.yaml --namespace my-app-ns | |
| ``` | |
| Suppose you have a Service named `my-app` in namespace `my-app-ns` that exposes metrics on port `metrics` at path `/metrics`. You can create and apply a `VMServiceScrape` resource with the following command: | |
| ```bash | |
| cat <<EOF | kubectl apply -n my-app-ns -f - | |
| apiVersion: operator.victoriametrics.com/v1beta1 | |
| kind: VMServiceScrape | |
| metadata: | |
| name: my-app-metrics | |
| namespace: my-app-ns | |
| spec: | |
| selector: | |
| matchLabels: | |
| app: my-app | |
| endpoints: | |
| - port: metrics | |
| path: /metrics | |
| interval: 30s | |
| EOF |
| Suppose you have Pods labeled `app: my-worker` that expose metrics on port `9090` at path `/metrics`: | ||
|
|
||
| ```yaml | ||
| apiVersion: operator.victoriametrics.com/v1beta1 | ||
| kind: VMPodScrape | ||
| metadata: | ||
| name: my-worker-metrics | ||
| namespace: my-app-ns | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: my-worker | ||
| podMetricsEndpoints: | ||
| - port: "9090" | ||
| path: /metrics | ||
| ``` | ||
|
|
||
| Apply the resource: | ||
|
|
||
| ```bash | ||
| kubectl apply --filename vmpodscrape.yaml --namespace my-app-ns | ||
| ``` | ||
|
|
||
| ### Key Fields | ||
|
|
||
| | Field | Description | | ||
| | --- | --- | | ||
| | `spec.selector.matchLabels` | Label selector to find the target Pods | | ||
| | `spec.podMetricsEndpoints[].port` | Port name or number on the Pod to scrape | | ||
| | `spec.podMetricsEndpoints[].path` | HTTP path for metrics (default: `/metrics`) | |
There was a problem hiding this comment.
To improve clarity and user experience, this section can be improved in two ways:
- The
kubectl applycommand can be combined with the YAML definition using a heredoc. This creates a single copy-pastable command. - The
VMPodScrapeexample usesport: "9090", which implies the port is named9090. It's more common and clearer to specify a port number usingtargetPort. The key fields table should also be updated to reflect this.
Suppose you have Pods labeled `app: my-worker` that expose metrics on port `9090` at path `/metrics`. You can create and apply a `VMPodScrape` resource with the following command:
```bash
cat <<EOF | kubectl apply -n my-app-ns -f -
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMPodScrape
metadata:
name: my-worker-metrics
namespace: my-app-ns
spec:
selector:
matchLabels:
app: my-worker
podMetricsEndpoints:
- targetPort: 9090
path: /metrics
EOFKey Fields
| Field | Description |
|---|---|
spec.selector.matchLabels |
Label selector to find the target Pods |
spec.podMetricsEndpoints[].targetPort |
Port number or name on the Pod to scrape |
spec.podMetricsEndpoints[].path |
HTTP path for metrics (default: /metrics) |
| Suppose you have a Service named `my-app` in namespace `my-app-ns` that exposes metrics on port `metrics` at path `/metrics`: | ||
|
|
||
| ```yaml | ||
| apiVersion: operator.victoriametrics.com/v1beta1 | ||
| kind: VMServiceScrape | ||
| metadata: | ||
| name: my-app-metrics | ||
| namespace: my-app-ns | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: my-app | ||
| endpoints: | ||
| - port: metrics | ||
| path: /metrics | ||
| interval: 30s | ||
| ``` | ||
|
|
||
| Apply the resource: | ||
|
|
||
| ```bash | ||
| kubectl apply --filename vmservicescrape.yaml --namespace my-app-ns | ||
| ``` |
There was a problem hiding this comment.
To make the instructions easier to follow, consider combining the YAML definition and the kubectl apply command into a single, copy-pastable block using a heredoc. This prevents users from needing to manually create a file and reduces the potential for error.
| Suppose you have a Service named `my-app` in namespace `my-app-ns` that exposes metrics on port `metrics` at path `/metrics`: | |
| ```yaml | |
| apiVersion: operator.victoriametrics.com/v1beta1 | |
| kind: VMServiceScrape | |
| metadata: | |
| name: my-app-metrics | |
| namespace: my-app-ns | |
| spec: | |
| selector: | |
| matchLabels: | |
| app: my-app | |
| endpoints: | |
| - port: metrics | |
| path: /metrics | |
| interval: 30s | |
| ``` | |
| Apply the resource: | |
| ```bash | |
| kubectl apply --filename vmservicescrape.yaml --namespace my-app-ns | |
| ``` | |
| Suppose you have a Service named `my-app` in namespace `my-app-ns` that exposes metrics on port `metrics` at path `/metrics`. You can create and apply a `VMServiceScrape` resource with the following command: | |
| ```bash | |
| cat <<EOF | kubectl apply -n my-app-ns -f - | |
| apiVersion: operator.victoriametrics.com/v1beta1 | |
| kind: VMServiceScrape | |
| metadata: | |
| name: my-app-metrics | |
| namespace: my-app-ns | |
| spec: | |
| selector: | |
| matchLabels: | |
| app: my-app | |
| endpoints: | |
| - port: metrics | |
| path: /metrics | |
| interval: 30s | |
| EOF |
| Suppose you have Pods labeled `app: my-worker` that expose metrics on port `9090` at path `/metrics`: | ||
|
|
||
| ```yaml | ||
| apiVersion: operator.victoriametrics.com/v1beta1 | ||
| kind: VMPodScrape | ||
| metadata: | ||
| name: my-worker-metrics | ||
| namespace: my-app-ns | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: my-worker | ||
| podMetricsEndpoints: | ||
| - port: "9090" | ||
| path: /metrics | ||
| ``` | ||
|
|
||
| Apply the resource: | ||
|
|
||
| ```bash | ||
| kubectl apply --filename vmpodscrape.yaml --namespace my-app-ns | ||
| ``` | ||
|
|
||
| ### Key Fields | ||
|
|
||
| | Field | Description | | ||
| | --- | --- | | ||
| | `spec.selector.matchLabels` | Label selector to find the target Pods | | ||
| | `spec.podMetricsEndpoints[].port` | Port name or number on the Pod to scrape | | ||
| | `spec.podMetricsEndpoints[].path` | HTTP path for metrics (default: `/metrics`) | |
There was a problem hiding this comment.
To improve clarity and user experience, this section can be improved in two ways:
- The
kubectl applycommand can be combined with the YAML definition using a heredoc. This creates a single copy-pastable command. - The
VMPodScrapeexample usesport: "9090", which implies the port is named9090. It's more common and clearer to specify a port number usingtargetPort. The key fields table should also be updated to reflect this.
Suppose you have Pods labeled `app: my-worker` that expose metrics on port `9090` at path `/metrics`. You can create and apply a `VMPodScrape` resource with the following command:
```bash
cat <<EOF | kubectl apply -n my-app-ns -f -
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMPodScrape
metadata:
name: my-worker-metrics
namespace: my-app-ns
spec:
selector:
matchLabels:
app: my-worker
podMetricsEndpoints:
- targetPort: 9090
path: /metrics
EOFKey Fields
| Field | Description |
|---|---|
spec.selector.matchLabels |
Label selector to find the target Pods |
spec.podMetricsEndpoints[].targetPort |
Port number or name on the Pod to scrape |
spec.podMetricsEndpoints[].path |
HTTP path for metrics (default: /metrics) |
The namespace labeling mechanism and VMAgent selector configuration are internal details that should not be exposed in user-facing docs. Signed-off-by: ohotnikov.ivan <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
content/en/docs/v0/operations/services/monitoring/custom-metrics.md (1)
110-112: Consider demonstrating named port usage for consistency.The VMPodScrape example uses a numeric port
"9090", while the VMServiceScrape example uses a named port"metrics". Consider adding a comment or second example showing named port usage (e.g.,port: "metrics") to demonstrate both options and maintain consistency with the VMServiceScrape section.📝 Optional: Add example with named port
podMetricsEndpoints: - - port: "9090" + - port: "9090" # Can also use named port: port: "metrics" path: /metrics🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@content/en/docs/v0/operations/services/monitoring/custom-metrics.md` around lines 110 - 112, Add a second example or inline comment in the VMPodScrape section showing named-port usage to match VMServiceScrape: modify the podMetricsEndpoints block (symbol: podMetricsEndpoints) to include an alternative like port: "metrics" and a short note that named ports are equivalent to numeric ports, so readers see both options; ensure the example mirrors VMServiceScrape's use of the named port and clearly labels it as an alternative to port: "9090".content/en/docs/v1/operations/services/monitoring/custom-metrics.md (1)
110-112: Consider demonstrating named port usage for consistency.The VMPodScrape example uses a numeric port
"9090", while the VMServiceScrape example uses a named port"metrics". Consider adding a comment or second example showing named port usage (e.g.,port: "metrics") to demonstrate both options and maintain consistency with the VMServiceScrape section.📝 Optional: Add example with named port
podMetricsEndpoints: - - port: "9090" + - port: "9090" # Can also use named port: port: "metrics" path: /metrics🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@content/en/docs/v1/operations/services/monitoring/custom-metrics.md` around lines 110 - 112, Update the VMPodScrape example around podMetricsEndpoints to show named-port usage for consistency with VMServiceScrape: add either a comment explaining you can use a named port (e.g., "metrics") or include a second podMetricsEndpoints example entry using port: "metrics" and the same path: /metrics; ensure you reference the existing podMetricsEndpoints block so readers see both numeric ("9090") and named ("metrics") port options.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@content/en/docs/v0/operations/services/monitoring/custom-metrics.md`:
- Around line 110-112: Add a second example or inline comment in the VMPodScrape
section showing named-port usage to match VMServiceScrape: modify the
podMetricsEndpoints block (symbol: podMetricsEndpoints) to include an
alternative like port: "metrics" and a short note that named ports are
equivalent to numeric ports, so readers see both options; ensure the example
mirrors VMServiceScrape's use of the named port and clearly labels it as an
alternative to port: "9090".
In `@content/en/docs/v1/operations/services/monitoring/custom-metrics.md`:
- Around line 110-112: Update the VMPodScrape example around podMetricsEndpoints
to show named-port usage for consistency with VMServiceScrape: add either a
comment explaining you can use a named port (e.g., "metrics") or include a
second podMetricsEndpoints example entry using port: "metrics" and the same
path: /metrics; ensure you reference the existing podMetricsEndpoints block so
readers see both numeric ("9090") and named ("metrics") port options.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fce1b07a-8b7a-4ece-9df9-8759e32dd420
📒 Files selected for processing (2)
content/en/docs/v0/operations/services/monitoring/custom-metrics.mdcontent/en/docs/v1/operations/services/monitoring/custom-metrics.md
Summary
namespace.cozystack.io/monitoring) required for tenant VMAgent target discoveryTest plan
make serveSummary by CodeRabbit