Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement(prometheus): support prometheus2 .yml rule file format #333

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

dpavle
Copy link
Contributor

@dpavle dpavle commented Apr 15, 2024

No description provided.

@github-actions github-actions bot added enhancement New feature or request roles/prometheus labels Apr 15, 2024
Copy link
Contributor

github-actions bot commented Apr 15, 2024

Docs Build 📝

Thank you for contribution!✨

The docs for this PR have been published here:
https://prometheus-community.github.io/ansible/pr/333

You can compare to the docs for the main branch here:
https://prometheus-community.github.io/ansible/branch/main

The docsite for this PR is also available for download as an artifact from this run:
https://github.com/prometheus-community/ansible/actions/runs/8736595095

File changes:

Click to see the diff comparison.

NOTE: only file modifications are shown here. New and deleted files are excluded.
See the file list and check the published docs to see those files.

diff --git a/home/runner/work/ansible/ansible/docsbuild/base/prometheus_role.html b/home/runner/work/ansible/ansible/docsbuild/head/prometheus_role.html
index db53335..d2d72e9 100644
--- a/home/runner/work/ansible/ansible/docsbuild/base/prometheus_role.html
+++ b/home/runner/work/ansible/ansible/docsbuild/head/prometheus_role.html
@@ -199,8 +199,8 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <div class="ansibleOptionAnchor" id="parameter-main--prometheus_alert_rules"></div><p class="ansible-option-title" id="ansible-collections-prometheus-prometheus-prometheus-role-parameter-main-prometheus-alert-rules"><strong>prometheus_alert_rules</strong></p>
 <a class="ansibleOptionLink" href="#parameter-main--prometheus_alert_rules" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=dictionary</span></p>
 </div></td>
-<td><div class="ansible-option-cell"><p>Full list of alerting rules which will be copied to <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">prometheus_config_dir</span> <span class="pre">}}/rules/ansible_managed.rules</span></code>.</p>
-<p>Alerting rules can be also provided by other files located in <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">prometheus_config_dir</span> <span class="pre">}}/rules/</span></code> which have <code class="docutils literal notranslate"><span class="pre">*.rules</span></code> extension</p>
+<td><div class="ansible-option-cell"><p>Full list of alerting rules which will be copied to <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">prometheus_config_dir</span> <span class="pre">}}/rules/ansible_managed.yml</span></code>.</p>
+<p>Alerting rules can be also provided by other files located in <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">prometheus_config_dir</span> <span class="pre">}}/rules/</span></code> which have a <code class="docutils literal notranslate"><span class="pre">*.yml</span></code> or <code class="docutils literal notranslate"><span class="pre">*.yaml</span></code> extension</p>
 <p>Please see default values in role defaults/main.yml</p>
 </div></td>
 </tr>
@@ -209,8 +209,8 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <a class="ansibleOptionLink" href="#parameter-main--prometheus_alert_rules_files" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
 </div></td>
 <td><div class="ansible-option-cell"><p>List of folders where ansible will look for files containing alerting rules which will be copied to <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">prometheus_config_dir</span> <span class="pre">}}/rules/</span></code>.</p>
-<p>Files must have <code class="docutils literal notranslate"><span class="pre">*.rules</span></code> extension</p>
-<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">[&quot;prometheus/rules/*.rules&quot;]</span></code></p>
+<p>Files must have a <code class="docutils literal notranslate"><span class="pre">*.yml</span></code> or <code class="docutils literal notranslate"><span class="pre">*.yaml</span></code> extension</p>
+<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">[&quot;prometheus/rules/*.yml&quot;,</span> <span class="pre">&quot;prometheus/rules/*.yaml&quot;]</span></code></p>
 </div></td>
 </tr>
 <tr class="row-even"><td><div class="ansible-option-cell">

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 15, 2024
Signed-off-by: dpavle <dencic.pavle@gmail.com>
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 15, 2024
Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Pavle <17710777+dpavle@users.noreply.github.com>
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 15, 2024
@SuperQ
Copy link
Contributor

SuperQ commented Apr 15, 2024

Please also update the updated docs.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 15, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 15, 2024
Signed-off-by: dpavle <17710777+dpavle@users.noreply.github.com>
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 15, 2024
@dpavle dpavle requested a review from SuperQ April 16, 2024 13:22
@SuperQ SuperQ requested a review from gardar April 16, 2024 19:59
@SuperQ
Copy link
Contributor

SuperQ commented Apr 16, 2024

There are some other references to .rules files in the role. Maybe worth cleaning up more.

Copy link
Member

@gardar gardar left a comment

Choose a reason for hiding this comment

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

If we want to support both .rules and .yml as proposed by this PR then both should be listed in the docs and argument specs.

But if we want to drop .rules then that should be done clearly with a warning in the preflight.

Also .yaml should be supported since both.yml and .yaml are valid yaml file extensions.

@dpavle
Copy link
Contributor Author

dpavle commented Apr 17, 2024

If we want to support both .rules and .yml as proposed by this PR then both should be listed in the docs and argument specs.

But if we want to drop .rules then that should be done clearly with a warning in the preflight.

Also .yaml should be supported since both.yml and .yaml are valid yaml file extensions.

I'm for removing the old .rules format. It's essentially been deprecated since 2017 and it doesn't work in any recent version of Prometheus as far as I'm aware.

As for the warning in the preflight, sure, that could be done. I'm just not sure how exactly, do we fail if any .rules files are found in /rules?

And yes, .yaml should also be supported.

@SuperQ
Copy link
Contributor

SuperQ commented Apr 17, 2024

We probably want to keep the *.rules handling, at least from a configuration loading perspective, around in order to maintain backwards compatibility. Otherwise existing deployments that are pushing yaml to files named .rules will break.

@gardar
Copy link
Member

gardar commented Apr 17, 2024

We probably want to keep the *.rules handling, at least from a configuration loading perspective, around in order to maintain backwards compatibility. Otherwise existing deployments that are pushing yaml to files named .rules will break.

That's why I suggested a error in the preflight, but we could also make that a warning for now and then drop *.rules support in the future.
Or we could handle it automatically by adding a task that renames .rules to .yml

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 17, 2024
Signed-off-by: dpavle <17710777+dpavle@users.noreply.github.com>
…les extension

Signed-off-by: dpavle <17710777+dpavle@users.noreply.github.com>
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 18, 2024
Signed-off-by: dpavle <17710777+dpavle@users.noreply.github.com>
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Apr 18, 2024
@dpavle
Copy link
Contributor Author

dpavle commented Apr 18, 2024

We probably want to keep the *.rules handling, at least from a configuration loading perspective, around in order to maintain backwards compatibility. Otherwise existing deployments that are pushing yaml to files named .rules will break.

That's why I suggested a error in the preflight, but we could also make that a warning for now and then drop *.rules support in the future. Or we could handle it automatically by adding a task that renames .rules to .yml

A warning works. If there are any YAML formatted files with the .rules extension there will be a warning message in the preflight and the rule validation will pass normally. On the other hand, if there are any rules in the old .rules format, the warning message will show in the preflight and promtool check validation will catch them and fail in a later step.

@dpavle dpavle requested a review from gardar April 18, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request roles/prometheus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants