All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Fixed: FIxed the
expressionUsesOnlyAllowedLabelsForMetricRegexp
validator that might return false positives when used on more complex expressions with vector matching and functions using labels.
- Added: Configuration file can now be in Jsonnet format if the config file name ends with
.jsonnet
and it will get automatically evaluated.
- Added: New validation
expressionDoesNotUseClassicHistogramBucketOperations
to avoid queries fragile because of the classic histogram bucket operations. See the docs for more info expressionDoesNotUseClassicHistogramBucketOperations - Changed:
⚠️ revert the ENV expansion in config file since it was breaking and caused issues (it was a stupid idea) - Fix: Avoid panic when validating unsupported file type and revert to previous behavior when any file was treated as a rule file regardless of the extension.
The only exception are
.jsonnet
files that are evaluated first.
- Fixed:
⚠️ Ignore white spaces around rule names in thedisabled_validation_rules
annotation CSV format (Thanks @jmichalek13 !) - Added:
⚠️ Support ENV expansion in the config file in format$ENV_VAR
or${ENV_VAR}
- Changed:
⚠️ The cache format is now scoped by source tenants (internal change, no action required) - Changed: Uses structured logging
- Added: new
httpHeaders
field in theprometheus
section of the config to set custom headers in the Prometheus requests - Added: new option
negativeRegexp
to thehasSourceTenantsForMetrics
validation, see the docs - Added: new validator
recordedMetricNameDoesNotMatchRegexp
to check if the recorded metric name does not match the regexp
- Changed: Upgrade to go 1.23
- Changed: Upgrade prometheus dependencies
- Changed: Upgrade other dependencies
- Changed: Enable experimental functions in PromQL parser by default, to forbid them use a new validator
expressionDoesNotUseExperimentalFunctions
- Added: New validator
expressionDoesNotUseExperimentalFunctions
to check if the expression does not use experimental functions - Added: New validator
expressionUsesUnderscoresInLargeNumbers
that requires using underscores as separators in large numbers in expressions
- Added: Build of windows and darwin and support for arm architectures in CI
- Added: New validator
expressionUsesOnlyAllowedLabelsForMetricRegexp
to check if the expression uses only allowed labels for the metric.
- Changed: Updated README.md installation instructions, to install latest version use
go install github.com/fusakla/promruval/v3
. - Fixed:
⚠️ Unmarshalling of the rule files is strict again, this behavior was unintentionally brought when adding support for yaml comments. - Changed:
⚠️ RenamedhasValidPartialStrategy
tohasValidPartialResponseStrategy
as it was documented so it is actually a fix - Changed:
⚠️ Disallow special rule file fields of Thanos, Mimir or Loki by default To enable them, you need to set some of the new flags described below - Changed: The Prometheus results cache format has changed to reduce it's size and improve performance. Delete the old cache file before upgrade. Also now if the cache contains time of creation and URL of the Prometheus it has data for. From now on, if the URL does not match, the case is pruned.
- Added: 🚀 Support for validation of rule files in the Jsonnet format.
- Added: New flags
--support-thanos
,--support-mimir
,--support-loki
to enable special rule file fields of Thanos, Mimir or Loki - Added: 🎉 Support for validation of Loki rules! Now you can validate Loki rules as well. First two validators are:
expressionIsValidLogQL
to check if the expression is a valid LogQL querylogQlExpressionUsesRangeAggregation
to check if the LogQL expression uses range aggregationlogQlExpressionUsesFiltersFirst
to check if the LogQL expression uses filters first in the query since it is more efficient
- Added: Support for alert field
keep_firing_for
- Added: Support for the
query_offset
field in the rule group - Added: New validator
expressionIsValidPromQL
to check if the expression is a valid PromQL query - Added: Support for bearer token authentication in the
prometheus
section of the config using thebearerTokenFile
field or by specifying thePROMETHEUS_BEARER_TOKEN
env variable. - Added:
maximumMatchingSeries
option to theexpressionSelectorsMatchesAnything
validator to check maximum number of series any selector can match. - Added: new config options to the prometheus section of config:
queryOffset
: Specify offset(delay) of the query (useful for consistency if using remote write for example).queryLookback
: How long into the past to look in queries supporting time range (just metadata queries for now).
- Added: New validator
alertNameMatchesRegexp
to check if the alert name matches the regexp. - Added: New validator
groupNameMatchesRegexp
to check if the rule group name matches the regexp. - Added: New validator
recordedMetricNameMatchesRegexp
to check if the recorded metric name matches the regexp. - Added: Set the
User-Agent
header in the Prometheus requests topromruva
to identify the client. - Added: Automatically configure the
X-ScopeOrgID
header in the Prometheus requests if thesource_tenants
field is set in the rule group. - Fixed: Rules count in the result stats is now correct.
- Fixed: Better error message when validation rule is missing
scope
. - Fixed: Loading glob patterns in the file paths to rules
- Fixed: Params of the
expressionCanBeEvaluated
validator were ignored, this is now fixed. - Updated: Prometheus and other dependencies
- CI: Updated Github actions for golangcilint and goreleaser
- Fixed: error message in the
hasSourceTenantsForMetrics
validator - Updated: indirect Go dependency google.golang.org/protobuf bumped to v1.33.0
- Added: new param
defaultTenant
to thehasSourceTenantsForMetrics
validator to set the default tenant for the rule group.
- Added: support for disabling validation using comments in yaml rules per rule group and for the whole file.
- Docs: Updated/improved documentation on how to disable validations and validation rules.
- Fixed resolving of the path in
paramsFromFile
. Formerly it was resolved from the current working directory, now it must be a relative path, that will be resolved from the config file location. - Fixed: tenants in the
hasSourceTenantsForMetrics
validator are now sorted in the human readable output.
⚠️ CHANGED: Params of thehasSourceTenantsForMetrics
validator (again FACEPALM). Now the tenant can have multiple regexp matchers. See its docs.
-
Fixed error messages for the
hasSourceTenantsForMetrics
andexpressionDoesNotUseIrate
validators. -
Added new option
paramsFromFile
to the validators, so the params can be loaded from a YAML file. Example promruval config:- type: labelHasAllowedValue paramsFromFile: ./examples/allowed_values_params.yaml
Content of
./examples/allowed_values_params.yaml
:label: "severity" allowedValues: ["info", "warning", "critical"]
-
Added new config option
additionalDetails
to all validators providing possibility to add custom details about the error and how to solve it. Those will be appended to the validator error message in a parenthesis if provided. Example configuration:- name: expressionDoesNotUseIrate additionalDetails: "Just do as I say!"
Example output:
expressionDoesNotUseIrate: you should not use the `irate` function in rules, for more info see https://www.robustperception.io/avoid-irate-in-alerts/ (Just do as I say!)
-
⚠️ CHANGED: Params of thehasSourceTenantsForMetrics
validator. See its docs.
- Added new
All rules
validatorexpressionIsWellFormatted
to check if rules are well formatted aspromtool promql format
would do. - Added new
Group
validatormaxRulesPerGroup
to check if the number of rules in the group is not exceeding the limit. - Added new
Group
validatorhasAllowedLimit
to check if the rule group has thelimit
lower than the limit and possibility to enforce it to be configured. - Added new
Alert
validatorvalidateLabelTemplates
to check if the alert labels are valid Go templates. - Added new
Alert
validatorkeepFiringForIsNotLongerThan
to check if the alert does not havekeep_firing_for
longer then limit. - Updated all deps to the latest versions.
- Upgraded go to 1.22
- Update all Github actions in CI
- Made lint more strict and fixed all the issues
From now on each validator has restricted scopes it can be used with since they may not make sense in some contexts. The documentation in docs/validations.md was updated and is structured based on the scopes.
If you were using the
All rules
scope, you may need to update your configuration and split the rules by the scopes.
- Fixed param validation of the
hasAllowedEvaluationInterval
validator, if themaximum
was not set.
- Added new param
ignoreTemplatedValues
to thelabelHasAllowedValue
validator to ignore templated values in the label. - Added new validation rule scope
Group
to validate the rule group itself (not the rules in it). - Added new
Group
scope validatorhasAllowedEvaluationInterval
to check if the rule group has theinterval
in the configured range and possibility to enforce it to be configured. - Added new
Group
scope validatorhasValidPartialResponseStrategy
to check if the rule group has validpartial_response_strategy
and possibility to enforce it to be configured. - CHANGED: The validator
allowedSourceTenants
is now allowed only in theGroup
scope validation rules. - Fixed marking empty rule files (or those with all the content commented out) with an error saying EOF, from now on such files are ignored.
- Upgrade all dependencies
- Fix:
promruval version
now works without specifying--config-file
- Added new validator
expressionDoesNotUseMetrics
, see its docs. - Added new validator
hasSourceTenantsForMetrics
, see its docs. - Improved the HTML output of human readable validation description.
- Added examples of the human-readable validation descriptions to the examples dir.
- Refactored the validation so it can use also group to validate the context of the rule.
- Improve linting and fix all the linting issues.
- Added new validator
hasValidSourceTenants
, see its docs. - Improved wording in the human readable validation output.
- Added new validator
expressionWithNoMetricName
, see its docs. Thanks @tizki ! - Upgrade to go 1.21
- Upgrade all dependencies
- Upgrade all dependencies
- Upgrade to Go 1.19
- Support
keep_firing_for
in alert rule - Support
source_tenants
in rule group used by Cortex/Mimir - Add linting to CI
- Fixed installation instructions in README.
- Upgraded prometheus dependency and to avoid installation issues using
go install
.
- #30
- Upgrade Go to 1.19.
⚠️ CHANGE - go.mod version bumped to match the project major version, if you use promruval as a library, make sure to change the package togithub.com/fusakla/promruval/v3
.⚠️ CHANGE - Updated README.md installation instructions, to install latest version usego install github.com/fusakla/promruval/v2
.
- #27
- typos and wording in validator messages were corrected
-
- Delete forgotten debug print :ashamed:
- Redirect logging to stderr
- Log progress
- Fix e2e test
-
- Allow disabling validations in comments inside the
expr
of rules. This is useful when you generate the prometheus rule files from a system that doesn't support YAML comments, e.g. jsonnet.
- Allow disabling validations in comments inside the
- #23 Fix unmarshall of
expressionDoesNotUseOlderDataThan
params.
- #22 Upgrade Prometheus dependencies to support newest PromQL features
- #21 Fix
validFunctionsOnCounters
andrateBeforeAggregation
validators
No actual breaking changes, but a lot of new features and configuration options so why not a major release :)
- #16 Upgraded yaml.v3 library to mitigate CVE-2022-28948
- #15 Upgraded to Go 1.18
- #9 Upgraded to Go 1.17
- #10 New validator
validateAnnotationTemplates
for more info see the docs - #11 New validator
forIsNotLongerThan
for more info see the docs - #12 New validator
expressionDoesNotUseIrate
for more info see the docs - #13 New validator
validFunctionsOnCounters
for more info see the docs - #14 New validator
rateBeforeAggregation
for more info see the docs - #17 New
validators:
nonEmptyLabels
,exclusiveLabels
- #18 Added e2e tests
- #19
- Added support for validations using live Prometheus and added checks:
- Added
--debug
flag and more logging. - New
prometheus
section to the root configuration allowing to use validation against live prometheus instance. - Added caching of Prometheus data is used. Default cache file is
./.promruval_cache.json
. - Added new flag
--enabled-rule
to enable only named validation rules.
- #20
- Flag
--config-file
can be now passed multiple times allowing config composition. - Accept
partial_response_strategy
field in rule group to be able to validate thanos rules.
- Flag
- #12 Fixed the
annotationIsValidURL
to be more strict in parsing URL and to actually use theresolve_url
configuration.
- #8 Fixed severe bugs in loading some of validator configurations.
- #7 Fixed typos in label and annotations checks
hasAnyOfAnnotations
andhasAnyOfLabels
.
- New parameter
commaSeparatedValue
for theannotationHasAllowedValue
validator supporting annotations with a comma separated values.
- New parameter
commaSeparatedValue
for thelabelHasAllowedValue
validator supporting labels with a comma separated values. - Added new validation check
annotationIsValidPromQL
to verify if rule annotation contains valid PromQL expression.
- Switch back to official PromQL package to parse queries.
- Switched to
the Prometheus Duration format
allowing usage ot
d
,w
andy
.
- Breaking: The
scope
configuration values has changed:AllRules
->All rules
RecordingRules
->Recording rules
- Added support for special rule annotation containing names of validation rules
that should be skipped for the rule. Default annotation name is
disabled_validation_rules
. - Added new command
validation-docs
to print out human readable description of the validation config. - Added docs for all supported validations in docs/validations.md.
- Added new
version
command that prints out version and build metadata. - Added new validator
expressionDoesNotUseRangeShorterThan
. - Support searching in
expr
in label presence validators. - Added short flags.
- Fixed issue when unmarshalling errors of rule files were not printed.
- Fixed docker build using goreleaser in CI.
- Fixed docker release in CI.
First public release.
Initial release.