Skip to content

Conversation

@vivekgsharma
Copy link
Collaborator

@vivekgsharma vivekgsharma commented Aug 6, 2025

Description:

Issue being fixed or feature implemented

The prometheus.yml.j2 template was outdated compared to the manual changes that had been applied directly on the metrics server. This meant future deployments would overwrite the working production configuration and potentially break Grafana dashboards and monitoring.

What was done?

  • Synced template with live metrics server configuration that contains manual optimizations
  • Made template fully configurable with Ansible variables to prevent future manual modifications
  • Preserved working scrape intervals from production:
  • Tenderdash: 15s (critical blockchain metrics)
  • Gateway/Drive: 30s (medium priority)
  • Rate limiter: 60s (low priority monitoring)
  • Added external labels
  • Enhanced service labeling
  • Made alertmanager targets configurable to avoid hardcoded values like we did manually.

How Has This Been Tested?

  • Tested on testnet
  • Template generates identical configuration to current working prometheus.yml on metrics server
  • grafana dashboard functional as expected.

Breaking Changes
None.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • Template changes tested on testnet infrastructure
  • Synced with existing production metrics server configuration
  • Ensures Grafana dashboards continue working with future deployments

Summary by CodeRabbit

  • New Features

    • Prometheus configuration now supports customizable global scrape and evaluation intervals, scrape timeouts, and external labels for cluster and environment.
    • Ability to define additional custom scrape jobs with configurable parameters and labels.
  • Improvements

    • Scrape jobs for specific services are now dynamically generated based on available groups, reducing manual configuration.
    • Targets and labels for jobs are now more flexible and easier to manage.

@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The Prometheus configuration template was updated to replace hardcoded intervals and timeouts with configurable variables, introduce external labels, and enable dynamic generation of scrape jobs and targets. Conditional logic now defines jobs based on inventory groups and supports additional custom jobs via variables, enhancing flexibility and parameterization.

Changes

Cohort / File(s) Change Summary
Prometheus Configuration Template
ansible/roles/metrics/templates/prometheus.yml.j2
Replaced hardcoded global scrape/evaluation intervals and timeouts with variables and defaults; added external cluster/environment labels; made Alertmanager targets configurable; added conditional blocks for group-based and additional scrape jobs with dynamic target/label generation; updated job definitions to use variables and grouping logic.

Sequence Diagram(s)

sequenceDiagram
    participant Ansible
    participant Prometheus Template (Jinja2)
    participant Inventory/Vars

    Ansible->>Prometheus Template (Jinja2): Render with variables and inventory
    Prometheus Template (Jinja2)->>Inventory/Vars: Fetch intervals, timeouts, labels, job configs
    Prometheus Template (Jinja2)->>Prometheus Template (Jinja2): Conditionally define jobs (self, group-based, additional)
    Prometheus Template (Jinja2)-->>Ansible: Rendered prometheus.yml with dynamic jobs and targets
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

The configs once rigid, now flex and expand,
With variables guiding Prometheus’ hand.
Clusters and labels, all neatly in place,
New jobs appear swiftly, with targets to chase.
A hop and a skip through dynamic delight—
The metrics now sparkle, all through the night!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56b725e and b30831c.

📒 Files selected for processing (1)
  • ansible/roles/metrics/templates/prometheus.yml.j2 (2 hunks)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vivek/fix-metrics-role

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vivekgsharma vivekgsharma merged commit 21a21bb into v1.0-dev Aug 6, 2025
1 of 2 checks passed
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.

2 participants