<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by FUSAKLA on Medium]]></title>
        <description><![CDATA[Stories by FUSAKLA on Medium]]></description>
        <link>https://medium.com/@fusakla?source=rss-481ce24bf81d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*02K5s7Qh41FovuXy07JWYw.jpeg</url>
            <title>Stories by FUSAKLA on Medium</title>
            <link>https://medium.com/@fusakla?source=rss-481ce24bf81d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 20:08:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fusakla/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Promruval v3: Validation of Loki rules and more]]></title>
            <link>https://fusakla.medium.com/promruval-v3-validation-of-loki-rules-and-more-299d675f6f5a?source=rss-481ce24bf81d------2</link>
            <guid isPermaLink="false">https://medium.com/p/299d675f6f5a</guid>
            <category><![CDATA[grafana-loki]]></category>
            <category><![CDATA[prometheus-monitoring]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[testing-tools]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[FUSAKLA]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 16:10:00 GMT</pubDate>
            <atom:updated>2024-07-23T16:10:00.697Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*To3g2Adx_CoVOHLPgetmng.png" /></figure><p>Since the <a href="https://medium.com/@fusakla/promruval-validating-prometheus-rules-9a29f5dc24d2">first blog post about the Promruval</a> tool, a lot of new features have been added to it, so I thought I’ll write a short summary of the most interesting ones.</p><p><em>Loads of new validations were added that I’m not going to go through here, so if you want to check out what you can validate using promruval, see the </em><a href="https://github.com/FUSAKLA/promruval/blob/master/docs/validations.md"><em>complete list here</em></a><em>. <br>If you are not familiar with the tool, please refer to the</em><a href="https://medium.com/@fusakla/promruval-validating-prometheus-rules-9a29f5dc24d2"><em> first blog post</em></a><em> or see the projects&#39; </em><a href="https://github.com/FUSAKLA/promruval/blob/master/README.md"><em>README</em></a><em>.</em></p><p>So here are the most interesting new features</p><h3>Other monitoring systems support</h3><p>Since other monitoring systems like <a href="https://thanos.io/">Thanos</a>, <a href="https://grafana.com/oss/mimir/">Mimir</a> or even <a href="https://grafana.com/oss/loki/">Loki</a> have almost identical syntax of the alerting rules as Prometheus, it was quite easy to support them and even add special validations for them.<br>See <a href="http://support-loki/">the documentation on how to enable support for it and what can be validated</a>.</p><h4>Validating Loki rules and alerts</h4><p>The <a href="https://grafana.com/oss/loki/">Grafana Loki</a> logging solution is getting more and more traction, and it also <a href="https://grafana.com/docs/loki/latest/alert/">supports writing Prometheus like alerts based on your logs</a>. The syntax is exactly the same for the rules file, BUT the expression is <a href="https://grafana.com/docs/loki/latest/query/">LogQL</a>. Promruval now since v3 supports validation of Loki rules if you specify the —support-loki, and it even has special validations for the LogQL queries, see <a href="https://github.com/FUSAKLA/promruval/blob/master/docs/validations.md#logql-expression-validators">here</a>.</p><h3>Rule validation using live Prometheus</h3><p>Since the v2 of promruval you can also use live Prometheus instance to validate the queries in your rules. A <a href="https://github.com/FUSAKLA/promruval?tab=readme-ov-file#configuration">new section in the config named </a><a href="https://github.com/FUSAKLA/promruval?tab=readme-ov-file#configuration">prometheuswas added</a>, it describes what Prometheus instance should be used. The complete list of validations using the live Prometheus, see <a href="https://github.com/FUSAKLA/promruval/blob/master/docs/validations.md#promql-expression-validators-using-live-prometheus-instance">here</a>.</p><p>For example, the following config will check if the expressions in your rules can be really evaluated without an error <em>(this could catch for example many to many join errors, which are otherwise hard to test)</em>. It can even check if the evaluation does not take too much of a time <em>(30s in this case)</em>. Then it extracts all the selectors from the expression and checks if they match any series at all (it uses the /api/v1/series endpoint to check) and allows you to also set a limit on how many series the single selector can match. Finally, it will check if the labels used in the expression selectors, joins or aggregations does actually exist in the Prometheus instance <em>(it uses the </em><em>/api/v1/labels endpoint to list them).</em></p><pre>prometheus:<br>  url: http://demo.robustperception.io:9090<br>validationRules:<br>  - name: live-prometheus-checks<br>    validations:<br>      - type: expressionCanBeEvaluated<br>        params:<br>          evaluationDurationLimit: 30s<br>      - type: expressionSelectorsMatchesAnything<br>        params:<br>          maximumMatchingSeries: 1000<br>      - type: expressionUsesExistingLabels</pre><p><em>The query results are cached in a local file to avoid overloading the Prometheus.</em></p><h3>Keeping up with Prometheus new features</h3><p>Prometheus lately added quite a few new options to configure the rules evaluations such as group.limit, group.query_offset and rule.keep_firing_for. Also, a lot of new functions were added to the PromQL. All those should be supported by promruval and I try to keep the dependencies up to date as possible.</p><h3>Jsonnet support</h3><p>Often <a href="https://jsonnet.org/">Jsonnet</a> is used to write Prometheus rules in the form of mixins such as <a href="https://monitoring.mixins.dev/">these</a>. Till now, you had to render those first and then validate them. Since the v3 promruval now also supports .jsonnet files in addition to the standard .yamland .ymlfiles.</p><h3>Disabling validations</h3><p>If you have a rule that you know and expect not to pass the validation, you can now disable particular rules or validations using a YAML comments or even comments in the PromQL expression itself <em>(this is useful if you use for example jsonnet to define your rules so you cannot use the YAML comments).<br></em><a href="https://github.com/FUSAKLA/promruval/tree/master?tab=readme-ov-file#disabling-validations">See the documentation for more details</a>.</p><p><em>Example of disabling validations using YAML and PromQL comments</em></p><pre># Disable for the whole file<br># ignore_validations: expressionDoesNotUseIrate<br>groups:<br>  # Disable only for the following rule group<br>  # ignore_validations: expressionDoesNotUseIrate<br>  - name: group1<br>    partial_response_strategy: abort<br>    interval: 1m<br>    limit: 10<br>    rules:<br>      # Disable only for the following rule<br>      # ignore_validations: expressionDoesNotUseIrate<br>      - record: recorded_metrics<br>        expr: |<br>          # ignore_validations: expressionDoesNotUseIrate<br>          1<br>        labels:<br>          foo: bar</pre><h3>Multiple configuration files and params from file</h3><p>If you have for example multiple teams where their validation differs just in a few rules, but the core is the same, you can now have one common validation config and then just the per-team specific. Promruval allows you to set multiple configs and it will merge them. Again, <a href="https://github.com/FUSAKLA/promruval?tab=readme-ov-file#configuration-composition">see the docs for more info</a>.</p><p>Also, if you want to load any of the parameters for validation dynamically, you can now use the paramsFromFile instead of the params field in the validation config to load the YAML content from the referenced file.</p><p><em>So if you use or would like to use promruval and see any ideas or things to improve, please feel free to</em><a href="https://github.com/FUSAKLA/promruval/issues"><em> file an issue</em></a><em> or even PR, and I’d be really happy to discuss it and hopefully help you out.</em></p><figure><img alt="That’s all folks" src="https://cdn-images-1.medium.com/max/1024/0*IkIl1H2x7Fwnjcuy" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=299d675f6f5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Promruval: Validation of Prometheus rules]]></title>
            <link>https://fusakla.medium.com/promruval-validating-prometheus-rules-9a29f5dc24d2?source=rss-481ce24bf81d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a29f5dc24d2</guid>
            <category><![CDATA[alerts]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[FUSAKLA]]></dc:creator>
            <pubDate>Mon, 23 Nov 2020 07:13:38 GMT</pubDate>
            <atom:updated>2020-11-23T07:13:38.049Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Validating Prometheus rules</h3><p>There are a lot of tools in the Prometheus ecosystem for you to check or test your configuration. The <em>promtool </em>currently allows you to <a href="https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#syntax-checking-rules">check syntax</a> of your alerts and also <a href="https://prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules/">unit test the expressions</a> they use. As a side effect, it also tests rendering of the Go templates used in annotations which is also handy. Once verified, those alerts will be sent to the Alertmanager eventually. It has its own <em>amtool</em> allowing you to <a href="https://github.com/prometheus/alertmanager#routes">test the routing</a> if the alert, with a given set of labels, will notify the expected receivers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*cficPK1nf4B8w1i0u6kfHQ.jpeg" /></figure><h3><strong>So what’s still missing?</strong></h3><p>Imagine you have routing in Alertmanager based on the <em>severity</em> label values <em>critical</em>, <em>warning</em> and <em>info. </em>But what happens if a new developer, not aware of the well known severities, creates an alert with severity <em>high</em>? Well that depends on the rest of the configuration, but most probably the alert will end up thrown away or in some generic receiver no one watches, oops! 😱 We should probably check that no one uses some weird severities or even check for typos to avoid such cases.</p><p>Another Alertmanager related issue can be rendering the templates. The Go templates used in Alertmanager most probably expect some specific annotations present in the alert, so it would be handy to verify if the alert has those, before receiving weird messed up notifications with missing text for example 🚧</p><p>Also best practice is to link a playbook right from the alert, so the on-call person does not have to think of how to resolve the situation from zero. You would put such a link as a URL in the alert annotation, but you should probably check if the annotation is even there, and if so, is it really a valid URL? You could possibly go even further and try to check if the URL does not return 404? 🤔</p><p>And what about writing an alert analyzing the difference in incoming traffic between now and a week ago, but forget your Prometheus having only retention of 5 days? Been there, done that 😐 How cool it would be if your CI would tell, you are trying to use more data than available?</p><p>Or in more complex cluster setup (for example when using Thanos) you have multiple places where you can evaluate your rules. But those can differ in labels you can use there. If some labels are propagated as external labels or added/dropped by relabeling of some kind, the user can get easily confused, what labels he can or cannot use in the queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*NKJ6kyXHmrMoIpx1Iff_Tw.png" /></figure><h3><strong>So let&#39;s validate those cases! 💪</strong></h3><p>To address these situations and more, the <a href="https://github.com/FUSAKLA/promruval"><em>promruval</em></a><em> </em>tool was created. An open-source, free to use, single binary tool allowing you to write simple validation rules and check if files with Prometheus rules conform to it.</p><p>Let’s try it out and write a validation configuration for all the situations mentioned above.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/513ab887e5d2f575abbb6897260ccaad/href">https://medium.com/media/513ab887e5d2f575abbb6897260ccaad/href</a></iframe><p>Now we can write an alert violating all these rules.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d168cce5ac46d235316981f623003f7c/href">https://medium.com/media/d168cce5ac46d235316981f623003f7c/href</a></iframe><p>And let&#39;s validate it</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8932018a6b66314ddb062286db3d6c8/href">https://medium.com/media/a8932018a6b66314ddb062286db3d6c8/href</a></iframe><p>So in the output beginning we can see a brief summary of the used validations. Next there is a tree of validated files, groups and alerts. Each having a list of failed validation checks. The <em>promruval</em> exits with an exit code 1 if failed and prints out also statistics about the validation run.</p><p>So the validation result is…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*ioq_xYoQFkzaYnyg2EGujQ.png" /></figure><p>The tool supports even more validation checks not covered in this example. The full list can be found <a href="https://github.com/FUSAKLA/promruval/blob/master/docs/validations.md">here</a>.</p><p>Also, there are few other minor but useful features such as <a href="https://github.com/FUSAKLA/promruval#disabling-rules">disabling rules</a> and printing <a href="https://github.com/FUSAKLA/promruval#readable-validation-description">more human-readable form of the validation</a> configuration to be rendered in git pages for example.</p><p>So that’s it, The <em>promruval</em> tool can be found here <br><a href="https://github.com/FUSAKLA/promruval">https://github.com/FUSAKLA/promruval</a> with hopefully all the documentation needed. You’ll find there prebuilt binaries and Docker images or just simply <em>go get</em> it.</p><p>So feel free to use it and hopefully it will help you make your monitoring stack even more reliable and error proof! 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a29f5dc24d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>