Skip to content

[monitoring] Add inlineScrapeConfig support to tenant vmagent - #2200

Merged
Andrei Kvapil (kvaps) merged 1 commit into
cozystack:mainfrom
mattia-eleuteri:monitoring/additional-scrape-configs
Mar 16, 2026
Merged

Andrei Kvapil (kvaps) merged 1 commit into
cozystack:mainfrom
mattia-eleuteri:monitoring/additional-scrape-configs

Conversation

@mattia-eleuteri

@mattia-eleuteri mattia-eleuteri commented Mar 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds inlineScrapeConfig support to the tenant VMAgent resource in packages/system/monitoring/templates/vm/vmagent.yaml
  • Adds commented usage example in both packages/system/monitoring/values.yaml and packages/extra/monitoring/values.yaml

Problem

The tenant VMAgent resource does not support custom scrape configurations. Using additionalScrapeConfigs (which references a Kubernetes Secret) is not viable because tenant users have no access to create or read Secrets — they can only manage resources under apps.cozystack.io. Instead, inlineScrapeConfig accepts inline YAML directly through Helm values, which is consistent with tenant permissions.

Relates to #2194

Usage

vmagent:
  inlineScrapeConfig: |
    - job_name: "custom"
      static_configs:
        - targets: ["my-service:9090"]

Test plan

  • helm template monitoring with inlineScrapeConfig set — block rendered
  • helm template monitoring without it — no inlineScrapeConfig in output
  • Deploy and verify custom scrape targets are picked up by vmagent
Add inlineScrapeConfig support to tenant vmagent

Summary by CodeRabbit

  • New Features

    • Support for including an inline scrape configuration into VMAgent monitoring when provided.
  • Documentation

    • Added a commented example showing how to supply an inline scrape job and targets.
    • Reordered remote-write URL entries in monitoring configuration for clearer ordering.

@coderabbitai

coderabbitai Bot commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a conditional block in the VMAgent Helm template to render vmagent.inlineScrapeConfig when provided, adds commented example inlineScrapeConfig entries to two monitoring values files, and reorders vmagent.remoteWrite.urls in one values file.

Changes

Cohort / File(s) Summary
VMAgent Template
packages/system/monitoring/templates/vm/vmagent.yaml
Adds a conditional with block that emits `inlineScrapeConfig:
Values / Examples
packages/extra/monitoring/values.yaml, packages/system/monitoring/values.yaml
Adds commented example vmagent.inlineScrapeConfig block showing job_name / static_configs / targets. Also reorders vmagent.remoteWrite.urls in packages/system/monitoring/values.yaml (moves longterm URL after shortterm).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 I nudged a comment, soft and small,
A scrape job hidden in values' hall,
Templates whisper, lines align,
Metrics dream in tidy design,
Hop—configuration, one and all.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions 'inlineScrapeConfig' but the PR objectives and actual changes consistently refer to 'additionalScrapeConfigs' feature throughout all modified files and documentation. Update the PR title to '[monitoring] Add additionalScrapeConfigs support to tenant vmagent' to accurately reflect the feature being implemented.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot Bot added size/S This PR changes 10-29 lines, ignoring generated files kind/feature Categorizes issue or PR as related to a new feature labels Mar 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/extra/monitoring/values.yaml (1)

181-183: Also add this field to the structured values docs above.

The example is useful, but Vmagent is still documented as having only externalLabels and remoteWrite, so generated values docs will miss additionalScrapeConfigs. Please add an @field for the new object and its expected shape.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/extra/monitoring/values.yaml` around lines 181 - 183, The structured
values docs for Vmagent are missing the new additionalScrapeConfigs field;
update the docs section that defines Vmagent to include an `@field` entry for
additionalScrapeConfigs (object | nullable) and document its expected shape with
properties name (string) and key (string) so generated values docs include the
example from values.yaml; locate the Vmagent documentation block in the
structured values docs and add the `@field` line and a short description of the
object and its properties.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/extra/monitoring/values.yaml`:
- Around line 181-183: The structured values docs for Vmagent are missing the
new additionalScrapeConfigs field; update the docs section that defines Vmagent
to include an `@field` entry for additionalScrapeConfigs (object | nullable) and
document its expected shape with properties name (string) and key (string) so
generated values docs include the example from values.yaml; locate the Vmagent
documentation block in the structured values docs and add the `@field` line and a
short description of the object and its properties.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 30e5656d-a0a3-47db-b96a-40bb3ea6eef9

📥 Commits

Reviewing files that changed from the base of the PR and between a13481b and 1375a5b.

📒 Files selected for processing (3)
  • packages/extra/monitoring/values.yaml
  • packages/system/monitoring/templates/vm/vmagent.yaml
  • packages/system/monitoring/values.yaml

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 enhances the tenant VMAgent resource by integrating additionalScrapeConfigs functionality. This allows tenants to define and utilize custom Prometheus scrape configurations, addressing a previous limitation where only default scrape targets were supported. The change involves modifying the VMAgent template to conditionally include these configurations and providing clear examples in the Helm chart's values.yaml files.

Highlights

  • VMAgent Configuration: Introduced support for additionalScrapeConfigs in the tenant VMAgent resource, enabling custom scrape targets for monitoring.
  • Configuration Examples: Added commented usage examples for additionalScrapeConfigs in the values.yaml files for both system and extra monitoring packages.

🧠 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
  • packages/extra/monitoring/values.yaml
    • Added a commented example for additionalScrapeConfigs to illustrate its usage.
  • packages/system/monitoring/templates/vm/vmagent.yaml
    • Implemented conditional rendering for additionalScrapeConfigs within the VMAgent resource definition.
  • packages/system/monitoring/values.yaml
    • Included a commented example for additionalScrapeConfigs to guide users.
Activity
  • The pull request includes a detailed test plan outlining steps to verify the functionality, including helm template checks and deployment verification.
  • An automated release note was generated, summarizing the new feature.
  • The PR was generated with "Claude Code" and includes a "Summary by CodeRabbit", indicating automated assistance in its creation and summary.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment Gemini (@gemini-code-assist) Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for additionalScrapeConfigs to the tenant VMAgent resource, allowing for custom scrape targets. The implementation in the Helm template is correct, and commented examples are added to the values.yaml files. My review focuses on a minor but important convention: ensuring files end with a newline character for better compatibility with POSIX tools. I've suggested adding a newline to both modified values.yaml files.

Comment thread packages/extra/monitoring/values.yaml Outdated
- http://vminsert-longterm:8480/insert/0/prometheus
## additionalScrapeConfigs:
## name: my-secret
## key: scrape-configs.yaml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To adhere to POSIX standards and improve compatibility with various text-processing tools, files should end with a newline character. Please add a newline at the end of this file.

  ##   key: scrape-configs.yaml

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will check and fix if missing.

Comment thread packages/system/monitoring/values.yaml Outdated
- http://vminsert-longterm:8480/insert/0/prometheus
## additionalScrapeConfigs:
## name: my-secret
## key: scrape-configs.yaml No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To adhere to POSIX standards and improve compatibility with various text-processing tools, files should end with a newline character. Please add a newline at the end of this file.

  ##   key: scrape-configs.yaml

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will check and fix if missing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed — added trailing newline to packages/system/monitoring/values.yaml. The other file (packages/extra/monitoring/values.yaml) already had one.

@mattia-eleuteri
mattia-eleuteri force-pushed the monitoring/additional-scrape-configs branch from 1375a5b to b363bb3 Compare March 10, 2026 15:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/extra/monitoring/values.yaml (1)

181-183: Document additionalScrapeConfigs in the Vmagent typedef block too.

This example makes the new value visible in the file, but the structured docs above still omit it, so generated values documentation will stay incomplete unless the ## FIELD.IO (@field) ... annotations for Vmagent are updated as well.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/extra/monitoring/values.yaml` around lines 181 - 183, The values
docs omit additionalScrapeConfigs because the Vmagent typedef block lacks a
corresponding `@field` annotation; add a `@field additionalScrapeConfigs` entry to
the Vmagent typedef (the typedef block that documents Vmagent fields) describing
its structure (name: secret name, key: filename/key) and example usage so the
generated documentation includes this new value; reference the Vmagent typedef
and the additionalScrapeConfigs example in values.yaml when adding the
annotation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/extra/monitoring/values.yaml`:
- Around line 181-183: The values docs omit additionalScrapeConfigs because the
Vmagent typedef block lacks a corresponding `@field` annotation; add a `@field
additionalScrapeConfigs` entry to the Vmagent typedef (the typedef block that
documents Vmagent fields) describing its structure (name: secret name, key:
filename/key) and example usage so the generated documentation includes this new
value; reference the Vmagent typedef and the additionalScrapeConfigs example in
values.yaml when adding the annotation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 04d7eac5-b524-4e83-b3b1-f0470ad22195

📥 Commits

Reviewing files that changed from the base of the PR and between 1375a5b and b363bb3.

📒 Files selected for processing (3)
  • packages/extra/monitoring/values.yaml
  • packages/system/monitoring/templates/vm/vmagent.yaml
  • packages/system/monitoring/values.yaml

@mattia-eleuteri
mattia-eleuteri force-pushed the monitoring/additional-scrape-configs branch from b363bb3 to 8430e57 Compare March 10, 2026 16:05
Comment thread packages/extra/monitoring/values.yaml Outdated
- http://vminsert-shortterm:8480/insert/0/prometheus
- http://vminsert-longterm:8480/insert/0/prometheus
## additionalScrapeConfigs:
## name: my-secret

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Standard tenant users have no access to read/create secrets or change anything expect resources under apps.cozystack.io group

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — switched from additionalScrapeConfigs (which references a Secret) to inlineScrapeConfig (inline YAML string). Since tenant users can only manage apps.cozystack.io resources and have no access to Secrets, inlineScrapeConfig is the right approach: the scrape config is passed directly through Helm values, no Secret needed.

Signed-off-by: Mattia Eleuteri <[email protected]>
Signed-off-by: mattia-eleuteri <[email protected]>
@mattia-eleuteri
mattia-eleuteri force-pushed the monitoring/additional-scrape-configs branch from 8430e57 to f5d8c89 Compare March 11, 2026 09:40
@mattia-eleuteri mattia-eleuteri changed the title [monitoring] Add additionalScrapeConfigs support to tenant vmagent [monitoring] Add inlineScrapeConfig support to tenant vmagent Mar 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/extra/monitoring/values.yaml (1)

181-184: Add this option to the typed Vmagent docs too.

The example helps, but packages/extra/monitoring/values.yaml still documents Vmagent with only externalLabels and remoteWrite. Without a matching @field entry, the generated/reference values docs will stay incomplete for this new setting.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/extra/monitoring/values.yaml` around lines 181 - 184, Add the new
inlineScrapeConfig option to the typed Vmagent docs by adding a corresponding
`@field` entry for inlineScrapeConfig in the Vmagent type documentation (the same
place that documents externalLabels and remoteWrite) so the generated/reference
values docs include this setting; update the Vmagent docblock to describe
inlineScrapeConfig (expected YAML/array format and example) and ensure the field
name matches inlineScrapeConfig used in packages/extra/monitoring/values.yaml.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/system/monitoring/values.yaml`:
- Around line 83-86: The values key and example currently reference
vmagent.inlineScrapeConfig but the PR, release notes, and intended API use
vmagent.additionalScrapeConfigs (Secret-backed name/key); update
packages/system/monitoring/values.yaml to replace the inlineScrapeConfig example
with a commented example for additionalScrapeConfigs showing the Secret name and
key, and modify the template in
packages/system/monitoring/templates/vm/vmagent.yaml to render
.Values.vmagent.additionalScrapeConfigs (and stop rendering
.Values.vmagent.inlineScrapeConfig), ensuring the values key, example text, and
template usage are consistent; remove or mark inlineScrapeConfig as deprecated
if present elsewhere.

---

Nitpick comments:
In `@packages/extra/monitoring/values.yaml`:
- Around line 181-184: Add the new inlineScrapeConfig option to the typed
Vmagent docs by adding a corresponding `@field` entry for inlineScrapeConfig in
the Vmagent type documentation (the same place that documents externalLabels and
remoteWrite) so the generated/reference values docs include this setting; update
the Vmagent docblock to describe inlineScrapeConfig (expected YAML/array format
and example) and ensure the field name matches inlineScrapeConfig used in
packages/extra/monitoring/values.yaml.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6cdea26f-9929-4f42-ba12-64ad37959833

📥 Commits

Reviewing files that changed from the base of the PR and between 8430e57 and f5d8c89.

📒 Files selected for processing (3)
  • packages/extra/monitoring/values.yaml
  • packages/system/monitoring/templates/vm/vmagent.yaml
  • packages/system/monitoring/values.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/system/monitoring/templates/vm/vmagent.yaml

Comment on lines +83 to +86
## inlineScrapeConfig: |
## - job_name: "custom"
## static_configs:
## - targets: ["my-service:9090"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Align this values key with the feature the PR says it adds.

These comments document vmagent.inlineScrapeConfig, but the PR objective, release note, and usage example all describe a Secret-backed vmagent.additionalScrapeConfigs (name/key). The related template snippet in packages/system/monitoring/templates/vm/vmagent.yaml also renders inlineScrapeConfig, so the chart is exposing a different public API than the one requested. Please make the values key, example, and template consistent before merging.

Example if the intended API is still additionalScrapeConfigs
-  ## inlineScrapeConfig: |
-  ##   - job_name: "custom"
-  ##     static_configs:
-  ##       - targets: ["my-service:9090"]
+  ## additionalScrapeConfigs:
+  ##   name: my-secret
+  ##   key: scrape-configs.yaml
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/system/monitoring/values.yaml` around lines 83 - 86, The values key
and example currently reference vmagent.inlineScrapeConfig but the PR, release
notes, and intended API use vmagent.additionalScrapeConfigs (Secret-backed
name/key); update packages/system/monitoring/values.yaml to replace the
inlineScrapeConfig example with a commented example for additionalScrapeConfigs
showing the Secret name and key, and modify the template in
packages/system/monitoring/templates/vm/vmagent.yaml to render
.Values.vmagent.additionalScrapeConfigs (and stop rendering
.Values.vmagent.inlineScrapeConfig), ensuring the values key, example text, and
template usage are consistent; remove or mark inlineScrapeConfig as deprecated
if present elsewhere.

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Mar 16, 2026
@kvaps
Andrei Kvapil (kvaps) merged commit 23bc852 into cozystack:main Mar 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature lgtm This PR has been approved by a maintainer size/S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants