### Repository Setup and Git Operations Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0072_bitbucket_move_bug_to_modified.txt This snippet demonstrates the setup of a local Git repository for testing, including initialization, configuration, and branching. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . ``` ```bash cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` ```bash exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' ``` -------------------------------- ### Valid Pint Control Comment Example Source: https://github.com/cloudflare/pint/blob/main/docs/index.md Examples of correctly formatted control comments for Pint, including file and owner information. Comments must start with '# pint '. ```yaml # pint file/owner bob # pint file/owner bob ``` -------------------------------- ### Example Rule File Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0126_lint_fail_on_invalid.txt An example of an empty rule file, used in conjunction with the lint command. ```yaml -- rules/0001.yml -- # empty ``` -------------------------------- ### Thanos Schema Example Source: https://github.com/cloudflare/pint/blob/main/docs/configuration.md Example of the expected structure when using schema: thanos, including the partial_response_strategy. ```yaml groups: - name: example partial_response_strategy: abort rules: - record: ... expr: ... - alert: ... expr: ... ``` -------------------------------- ### Example Rule in v1.yml Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0134_ci_base_branch_flag_path.txt This is an example rule definition in YAML format, likely used for static analysis or configuration. ```yaml - record: rule1 expr: sum(foo) by(job) ``` -------------------------------- ### Initial Git Repository Setup Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0160_ci_comment_edit.txt Sets up a new Git repository and copies necessary configuration and rule files. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . ``` ```bash cp ../src/v0.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Prometheus Schema Example Source: https://github.com/cloudflare/pint/blob/main/docs/configuration.md Example of the expected structure when using schema: prometheus. ```yaml groups: - name: example rules: - record: ... expr: ... - alert: ... expr: ... ``` -------------------------------- ### File Path Discovery Example Source: https://github.com/cloudflare/pint/blob/main/docs/configuration.md An example demonstrating file path discovery, mapping cluster names from directory paths to Prometheus server configurations. ```hcl filepath { directory = "/etc/prometheus/clusters" match = "(?P[a-z]+[0-9]{2})" ignore = [ "staging[0-9]+" ] template { name = "cluster-{{ $cluster }}" uri = "https://{{ $cluster }}.prometheus.example.com" uptime = "prometheus_ready" include = [ "/etc/prometheus/clusters/{{ $cluster }}/.*.ya?ml", ] } } ``` -------------------------------- ### Test Repository Setup and Execution Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0213_ci_removed_rule.txt Sets up a test repository, configures Git, and runs the pint CI command. ```shell http start gitlab 127.0.0.1:6213 mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' env GITLAB_AUTH_TOKEN=secret exec pint -l debug --offline --no-color ci ! stdout . cmp gitlab.got ../gitlab.expected ``` -------------------------------- ### Setup and Execution of Watch Test Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0275_watch_symlink_owner.txt This snippet demonstrates the setup for the test, including creating a directory, a symlink, and executing the Pint watch command. It also includes the test script that verifies the metrics. ```bash mkdir rules/real exec ln -s real/bob.yml rules/link.yml exec bash -x ./test.sh & exec pint watch --listen=127.0.0.1:6275 --pidfile=pint.pid glob rules cmp curl.txt metrics.txt ``` ```bash #!/bin/bash sleep 3 curl -s http://127.0.0.1:6275/metrics | grep -E 'pint_problem\b|pint_rule_file_owner' | perl -pe "s/^([a-zA-Z].+)[ ]([0-9\.\-\+eE]+)$/\1/g" > curl.txt cat pint.pid | xargs kill ``` -------------------------------- ### Test Repository Setup and Git Operations Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0269_ci_gitlab_long_expr.txt This section details the setup of a test repository, including initializing Git, copying configuration files, and committing changes across different branches. ```shell mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'modify rules' ``` -------------------------------- ### Setup Symlink and Execute Pint Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0099_symlink_outside_glob.txt This snippet demonstrates the setup of a symlink pointing to a rule file outside the expected glob path and then executes the Pint linter with debug logging. ```bash mkdir rules/strict exec ln -s ../relaxed/1.yml rules/strict/symlink.yml exec pint -l debug --no-color lint rules/relaxed ! stdout . cmp stderr stderr.txt ``` -------------------------------- ### Record Rule Example (v2) Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0219_ci_gitlab_delete_dependency.txt An example of recording rules for v2, which excludes the 'up:sum' metric. It only contains unused recording rules. ```yaml groups: - name: g1 rules: - record: unused:sum1 expr: sum(up) - record: unused:sum2 expr: sum(up) ``` -------------------------------- ### Enable Annotation Check with Rule Examples Source: https://github.com/cloudflare/pint/blob/main/docs/checks/alerts/annotation.md Demonstrates how to enable the annotation check by defining rules. Includes examples for requiring a 'summary' annotation and validating a 'dashboard' annotation's URL. ```js rule { match { kind = "alerting" } annotation "summary" { required = true } annotation "dashboard" { severity = "bug" comment = "You must add a link to a Grafana dashboard showing impact of this alert" value = "https://grafana\.example\.com/.+" } } ``` -------------------------------- ### YAML Rule File Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0140_ci_include_exclude.txt Example of a YAML file containing a rule definition. This file is used within the test repository to be processed by Pint. ```yaml -- src/a.yml -- - record: rule1 expr: sum(foo) bi() ``` ```yaml -- src/b.yml -- - record: rule1 expr: sum(foo) bi() ``` -------------------------------- ### Example Rule File 1 Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0001_match_path.txt This is an example of a Prometheus rule file that might be checked by Pint. It defines a recording rule with an expression that uses aggregation. ```yaml - record: "colo:test1" expr: sum(foo) without(job) ``` -------------------------------- ### Bitbucket CI No-Op Test Setup Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0188_ci_noop.txt This snippet demonstrates the setup for a CI no-op test using Pint with Bitbucket. It involves initializing a Git repository, copying configuration files, setting environment variables for Git author/committer, and executing the Pint CI command. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/rules.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 exec touch .keep exec git add .keep exec git commit -am 'v2' env BITBUCKET_AUTH_TOKEN="12345" exec pint -l debug --no-color ci ! stdout . cmp bitbucket.got ../bitbucket.expected ``` -------------------------------- ### Example: Set Different Min-Age for Specific Metrics Source: https://github.com/cloudflare/pint/blob/main/docs/checks/promql/series.md Example demonstrating how to set different minimum ages for missing metrics, with a default for 'foo' and a 4-hour minimum for 'bar{instance="xxx"}'. ```yaml - record: ... # Report problems if: # - metric "foo" is missing for at least 1 hour (defaults) # - metric "bar{instance=xxx}" is missing for at least 4 hours # pint rule/set promql/series(bar{instance="xxx"}) min-age 4h expr: sum(foo) / sum(bar{instance="xxx"}) ``` -------------------------------- ### Example Rule Name Configuration Source: https://github.com/cloudflare/pint/blob/main/docs/checks/rule/name.md An example of a Pint rule that uses the name check to enforce a 'rec:' prefix for recording rules, setting a custom comment and 'bug' severity. ```js name "rec:.+" { comment = "All recording rules must use the `rec:` prefix." severity = "bug" } ``` -------------------------------- ### Metrics Output Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0042_watch_metrics.txt A sample of metrics output, including Go runtime metrics and their types. ```text # HELP go_gc_duration_seconds A summary of the wall-time pause (stop-the-world) duration in garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} go_gc_duration_seconds{quantile="0.25"} go_gc_duration_seconds{quantile="0.5"} go_gc_duration_seconds{quantile="0.75"} go_gc_duration_seconds{quantile="1"} go_gc_duration_seconds_sum go_gc_duration_seconds_count # HELP go_gc_gogc_percent Heap size target percentage configured by the user, otherwise 100. This value is set by the GOGC environment variable, and the runtime/debug.SetGCPercent function. Sourced from /gc/gogc:percent. ``` -------------------------------- ### Pint Configuration Error Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0079_check_promql_series_invalid.txt This example demonstrates the error message generated by Pint when an unsupported argument is used in the configuration file. It highlights the specific line and column where the error occurs. ```shell ! exec pint --no-color config ! stdout . cmp stderr stderr.txt ``` ```text -- stderr.txt -- level=INFO msg="Loading configuration file" path=.pint.hcl level=ERROR msg="Execution completed with error(s)" err="failed to load config file ".pint.hcl": .pint.hcl:7,3-6: Unsupported argument; An argument named "bob" is not expected here. ``` -------------------------------- ### Stderr Output Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0069_bitbucket_unmodified.txt Example of stderr output from pint, showing warnings about always firing alerts and redundant regexps, as well as information about default values. ```text -- stderr.txt -- Warning: always firing alert (alerts/comparison) ---> rules.yml:2 -> `rule1b` [+1 duplicates] 2 | expr: sum(foo{job=~"xxx"}) by(job) ^^^^^^^^^^^^^^^ This query doesn't have any condition and so this alert will always fire if it matches anything. Warning: redundant regexp (promql/regexp) ---> rules.yml:2 -> `rule1b` [+1 duplicates] 2 | expr: sum(foo{job=~"xxx"}) by(job) ^^^^^^^^^^^ Unnecessary regexp match on static string `job=~"xxx"`, use `job="xxx"` instead. Information: redundant field with default value (alerts/for) ---> rules.yml:3 -> `rule1b` [+1 duplicates] 3 | for: 0s ^^ `0s` is the default value of `for`, this line is unnecessary. ``` -------------------------------- ### Setup and Execution of Bad Symlink Test Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0096_bad_symlink.txt This snippet demonstrates the setup for the bad symlink test, including creating a rules directory, creating a symlink to a non-existent file, and executing `pint` to check for errors. It also includes the comparison of the actual stderr output with the expected output. ```bash mkdir rules exec ln -s ../bad.yml rules/symlink.yml ! exec pint --no-color lint rules ! stdout . cmp stderr stderr.txt ``` -------------------------------- ### Start Pint Watch Mode Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0228_watch_pidfile_remove_error.txt Starts Pint in watch mode, monitoring a glob of rules, with a specified interval and listen address. It also configures a PID file. ```bash mkdir piddir exec pint --no-color watch --interval=5s --listen=127.0.0.1:6228 --pidfile=piddir/pint.pid glob rules ``` -------------------------------- ### Setup Git Repository and Rules Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0249_ci_github_shifted_line.txt Initializes a Git repository, copies Pint rules and configuration files, and makes an initial commit. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### GitHub API GET Request for Reviews Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0033_ci_github_multi.txt Example of a GET request to the GitHub API to retrieve pull request reviews. Includes necessary headers for authentication and content negotiation. ```http GET /api/v3/repos/cloudflare/pint/pulls/1/reviews Accept: application/vnd.github.v3+json Accept-Encoding: gzip Authorization: Bearer 12345 X-Github-Api-Version: 2022-11-28 ``` -------------------------------- ### Setup Test Repository and Initial Rules Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0097_rule_file_symlink_error.txt Initializes a Git repository, sets up initial rule files, and configures Pint. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml exec ln -s xxx.yml symlink.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Setup Git Repository and Initial Files Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0248_ci_github_deleted_line.txt Initializes a Git repository, copies configuration and rule files, and makes an initial commit. This sets up the environment for testing Pint's CI functionality. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1/alert.yml . cp ../src/v1/record.yml . cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Parse Aggregate Expression with Pint Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0046_parse_3.txt Use 'pint parse' to validate a Prometheus aggregate expression. This example parses a sum over http_requests_total for GET method at a specific timestamp. ```bash exec pint parse 'sum(http_requests_total{method="GET"} @ 1609746000)' cmp stdout stdout.txt ! stderr . -- stdout.txt -- ++ node: sum(http_requests_total{method="GET"} @ 1609746000.000) AggregateExpr: * Type: vector * Op: sum * Expr: http_requests_total{method="GET"} @ 1609746000.000 * Param: * Grouping: [] * Without: false ++ node: http_requests_total{method="GET"} @ 1609746000.000 VectorSelector: * Type: vector * Name: http_requests_total * Offset: 0s * LabelMatchers: [method="GET" __name__="http_requests_total"] ``` -------------------------------- ### Start Pint Watch with Problem Limits Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0048_watch_limit.txt Starts the pint watcher with specified network listening address, maximum problems to report, minimum severity level, and a PID file for process management. Ensure the rules directory is correctly configured. ```bash exec pint watch --listen=127.0.0.1:6048 --max-problems=2 --min-severity=info --pidfile=pint.pid glob rules ``` -------------------------------- ### Enable Cost Check with Prometheus and Rule Blocks Source: https://github.com/cloudflare/pint/blob/main/docs/checks/query/cost.md Example of enabling the cost check by configuring a Prometheus server and a rule block. This setup tests rules matching a specific pattern against a development Prometheus instance. ```js prometheus "dev" { uri = "https://prometheus-dev.example.com" timeout = "30s" include = ["rules/dev/.+"] } rule { cost {} } ``` -------------------------------- ### Setup Test Repository and Initial Commit Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0154_ci_discovery_error.txt Initializes a Git repository, copies configuration files, and makes the first commit. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=master . cp ../src/v1.yml rules.yml cp ../.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Prometheus Recording Rule Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0018_match_alerting.txt An example of a Prometheus recording rule. ```yaml - record: "colo:recording" expr: sum(foo) without(job) ``` -------------------------------- ### Setup Git Repository and Initial Commit Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0028_ci_git_error.txt Initializes a git repository, copies configuration and rules, and makes the first commit. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Setup Test Repository and Files Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0243_ci_deleted_symlink_dependency.txt Initializes a git repository, copies alert and record YAML files, creates a symlink to record.yml, and adds the .pint.hcl configuration file. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/alert.yml alert.yml cp ../src/record.yml record.yml exec ln -s record.yml symlink.yml cp ../src/.pint.hcl . ``` -------------------------------- ### Setup Git Repository and Rules Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0167_rule_duplicate_symlink.txt Initializes a Git repository, copies rule files, creates a symlink to a rule file, and configures Pint. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v0.yml rules.yml exec ln -s rules.yml symlink.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Example Prometheus Rule (a.yml) Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0060_ci_noop.txt This is an example of a Prometheus rule file that might be checked by pint. ```yaml - record: rule1 expr: sum(foo) bi() ``` -------------------------------- ### Setup Test Repository and Initial Commit Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0162_ci_deleted_dependency.txt Initializes a Git repository, copies rule files and pint configuration, and makes the first commit. This sets up the baseline for the test. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/alert.yml alert.yml exec ln -s alert.yml symlink.yml cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Example Excluded File (README.md) Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0180_parser_exclude_md.txt This README.md file should be ignored by Pint due to the exclude rule in the configuration. ```markdown This is a readme file `foo` ``` -------------------------------- ### Start Pint in Watch Mode and Execute Test Script Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0043_watch_cancel.txt This command starts Pint in watch mode, listening on a specific address and writing its PID to a file. It then executes a bash script in the background to kill the Pint process after a delay. ```bash exec bash -x ./test.sh & exec pint --no-color watch --interval=1h --listen=127.0.0.1:6043 --pidfile=pint.pid glob rules ! stdout . stderr 'level=INFO msg="Shutting down"' stderr 'level=INFO msg="Waiting for all background tasks to finish"' stderr 'level=INFO msg="Background worker finished"' ``` -------------------------------- ### Setup Git Repository and Rules Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0172_rule_dependency_symlink_delete.txt Initializes a Git repository, creates directories for rules, copies rule files, and sets up symlinks. This prepares the environment for testing Pint's rule dependency handling. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . mkdir rules1 rules2 cp ../src/alert.yml rules1/alert.yml cp ../src/record.yml rules1/record.yml exec ln -s ../rules1/alert.yml rules2/alert.yml exec ln -s ../rules1/record.yml rules2/record.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Thanos Schema Example Source: https://github.com/cloudflare/pint/blob/main/docs/changelog.md Example of a rule file schema when using 'schema: thanos' in the Pint configuration. ```yaml groups: - name: example partial_response_strategy: abort rules: - record: ... expr: ... - alert: ... expr: ... ``` -------------------------------- ### Example v2.yml rules Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0068_skip_ci.txt Defines two modified alert rules, demonstrating a change in configuration. ```yaml - alert: rule1 expr: sum( for: 0s - alert: rule2 expr: sum(foo) by(job)0) for: 0s ``` -------------------------------- ### Flat Prometheus Rule List Example Source: https://github.com/cloudflare/pint/blob/main/docs/index.md An example of a Prometheus rule file with a flat list of alerts and records. ```yaml # Flat rule list - alert: AlertName expr: up == 0 - record: sum:up expr: count(up == 1) ``` -------------------------------- ### Setup Git Repository and Initial Commit Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0185_state_empty.txt Initializes a Git repository, copies configuration files, sets Git author/committer information, and makes the first commit. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/rules.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Prometheus Recording Rule Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0198_json_lint.txt Example of a Prometheus recording rule using a multiline expression for summing metrics. ```prometheus sum( multiline ) without(job, instance) ``` -------------------------------- ### Setting up and running Pint CI Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0163_ci_comment_resolve_blocker.txt This snippet demonstrates the shell commands to initialize a Git repository, copy configuration and rule files, commit changes, and then execute the Pint CI command. ```shell http start bitbucket 127.0.0.1:7163 env BITBUCKET_AUTH_TOKEN="12345" mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v0.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b modify cp ../src/v1.yml rules.yml exec git commit -am 'v1' ! exec pint --no-color ci stderr 'msg="Problems found" Fatal=1' stderr 'msg="Found open pull request" id=123 srcBranch=modify dstBranch=main' stderr 'msg="Listing existing comments" reporter=BitBucket' stderr 'msg="Creating a new comment" reporter=BitBucket' cmp bitbucket.got ../bitbucket1.expected cp ../src/v2.yml rules.yml exec git commit -am 'v2' exec pint --no-color ci ! stdout . ! stderr 'msg="Problems found"' stderr 'msg="Found open pull request" id=123 srcBranch=modify dstBranch=main' stderr 'msg="Listing existing comments" reporter=BitBucket' stderr 'msg="Trying to delete a stale existing comment" path=rules.yml line=5' cmp bitbucket.got ../bitbucket2.expected ``` -------------------------------- ### v1 YAML Rules Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0069_bitbucket_unmodified.txt Example of a YAML file defining Prometheus alerting rules for version 1. ```yaml -- src/v1.yml -- - alert: rule1a expr: sum(foo{job=~"xxx"}) by(job) - alert: rule2a expr: sum(foo{job=~"xxx"}) by(job) for: 0s ``` -------------------------------- ### Setup and Execution of Pint in GitHub Actions Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0083_github_action.txt This snippet shows the complete process of initializing a repository, configuring Pint, applying different rule sets (v1 and v2), and running Pint in CI mode within a GitHub Actions environment. It includes setting necessary environment variables and comparing the output. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' env GITHUB_AUTH_TOKEN=12345 env GITHUB_ACTION=YES env GITHUB_EVENT_NAME=pull_request env GITHUB_REF=refs/pull/123/merge env GITHUB_BASE_REF=main env GITHUB_REPOSITORY=foo/bar env GITHUB_API_URL=http://127.0.0.1:6083 exec pint -l debug --offline --no-color ci ! stdout . stderr 'level=INFO msg="Pull request review created" status="200 OK"' stderr 'level=INFO msg="Setting GITHUB_PULL_REQUEST_NUMBER from GITHUB_REF env variable" pr=123' stderr 'level=INFO msg="Setting repository owner from GITHUB_REPOSITORY env variable" owner=foo' stderr 'level=INFO msg="Setting repository name from GITHUB_REPOSITORY env variable" repo=bar' stderr 'level=INFO msg="Setting repository base URI from GITHUB_API_URL env variable" baseuri=http://127.0.0.1:6083' stderr 'level=INFO msg="Setting repository upload URI from GITHUB_API_URL env variable" uploaduri=http://127.0.0.1:6083' cmp github.got ../github.expected ``` -------------------------------- ### Nested Prometheus Rule List Example Source: https://github.com/cloudflare/pint/blob/main/docs/index.md An example of a Prometheus rule file with rules nested under a custom YAML tree. ```yaml # Rules nested under custom tree service: prometheus: rules: - alert: AlertName expr: up == 0 - record: sum:up expr: count(up == 1) ``` -------------------------------- ### Example rule for disabling specific instance Source: https://github.com/cloudflare/pint/blob/main/docs/checks/rule/label.md An example 'rule/label' configuration for 'severity' label, which will be targeted by a specific disable comment. ```js label "severity" { value = "(warning|critical)" required = true } ``` -------------------------------- ### Setup Repository and Pint Configuration Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0214_gitlab_no_auth_token.txt Initializes a git repository, copies the Pint configuration file, and sets git author/committer information before committing. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . exec touch rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 ``` -------------------------------- ### Setup Git Repository and Initial Configuration Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0171_rule_duplicate_rename.txt Initializes a Git repository, copies Pint configuration and rule files, and sets Git author/committer information. This sets up the environment for testing rule changes. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/.pint.hcl . cp ../src/v1.yaml rules.yaml env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Prometheus Rule Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0080_lint_online.txt A simple Prometheus alerting rule to detect HTTP errors. This rule is used as an example for linting with Pint. ```yaml - alert: http errors expr: rate(http_errors_total[2d]) > 0 ``` -------------------------------- ### Prometheus Alerting Rule Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0018_match_alerting.txt An example of a Prometheus alerting rule that is configured to always fire and has a required label removed during aggregation. ```yaml - alert: "colo:alerting" expr: sum(bar) without(job) ``` -------------------------------- ### Setup Test Repository and Git Initialization Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0098_rule_file_symlink_gh.txt Initializes a new Git repository and copies rule and configuration files for the test. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . ``` ```bash cp ../src/v1.yml rules.yml exec ln -s rules.yml symlink.yml cp ../src/.pint.hcl . ``` ```bash env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` ```bash exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' ``` -------------------------------- ### Setup Git Repository and Initial Configuration Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0161_ci_move_files.txt Initializes a Git repository, copies configuration files, and sets Git author/committer information before the first commit. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v0.yml prom1.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Example of vector matching with on() and group_left() Source: https://github.com/cloudflare/pint/blob/main/docs/changelog.md This example demonstrates a fix for false positive reports in promql/vector_matching for rules using 'on(...)' and 'group_left()'. ```PromQL sum(foo) without(instance) * on(app_name) group_left() bar ``` -------------------------------- ### Setting up a Test Repository for Pint CI Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0219_ci_gitlab_delete_dependency.txt This section outlines the steps to initialize a Git repository, copy configuration and rule files, and set Git author/committer information for running Pint in CI mode. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1/alert.yml . cp ../src/v1/record.yml . exec ln -s alert.yml symlink.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2/alert.yml . cp ../src/v2/record.yml . exec git commit -am 'v2' ``` -------------------------------- ### Pint Problem Detected Alert Example Source: https://github.com/cloudflare/pint/blob/main/docs/index.md An example Prometheus alert rule to detect problems identified by Pint, utilizing the 'pint_problem' metric. ```yaml - alert: Pint Problem Detected # pint_problem is only present if pint detects any problems # pint disable promql/series(pint_problem) expr: | sum without(instance, problem) (pint_problem) > 0 for: 1h annotations: summary: | {{ with printf "pint_problem{filename='%s', name='%s', reporter='%s'}" .Labels.filename .Labels.name .Labels.reporter | query }} {{ . | first | label "problem" }} {{ end }} docs: "https://cloudflare.github.io/pint/checks/{{ $labels.reporter }}.html" ``` -------------------------------- ### v2 YAML Rules Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0069_bitbucket_unmodified.txt Example of a YAML file defining Prometheus alerting rules for version 2, used after a branch checkout. ```yaml -- src/v2.yml -- - alert: rule1b expr: sum(foo{job=~"xxx"}) by(job) for: 0s - alert: rule2b expr: sum(foo{job=~"xxx"}) by(job) for: 0s ``` -------------------------------- ### Local Repository Setup and Git Operations Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0070_bitbucket_strict.txt This snippet demonstrates the shell commands to set up a local Git repository, initialize it, add configuration files, and create branches for testing. ```shell mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' ``` -------------------------------- ### Prometheus Rule Example (v1) Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0027_ci_branch.txt An example of a Prometheus rule definition. Note the intentional syntax error in the 'rule2' definition which will be caught by Pint. ```yaml - record: rule1 expr: sum(foo) by(job) - record: rule2 expr: sum(foo) bi(job) ``` -------------------------------- ### Test Repository Setup and Pint Execution Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0218_ci_gitlab_delete_dependency_empty_diff.txt This section outlines the shell commands used to set up a test Git repository, initialize it, copy configuration and rule files, set Git environment variables, and execute the Pint CI command. ```shell mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1/alert.yml . cp ../src/v1/record.yml . exec ln -s alert.yml symlink.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2/alert.yml . cp ../src/v2/record.yml . exec git commit -am 'v2' env GITLAB_AUTH_TOKEN=secret exec pint -l error --offline --no-color ci ! stdout . cmp stderr ../stderr.txt cmp gitlab.got ../gitlab.expected ``` -------------------------------- ### Setup Git Repository and Commits Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0029_ci_too_many_commits.txt This sequence of commands initializes a Git repository, sets up author information, creates several commits with rule file changes, and checks out different branches. This is used to simulate a commit history for testing Pint CI's commit limit. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' cp ../src/v1.yml rules.yml exec git commit -am 'recert to v1' cp ../src/v2.yml rules.yml exec git commit -am 'v2' ``` -------------------------------- ### Setup Directory Symlinks Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0092_dir_symlink.txt Creates a directory structure and symbolic links to simulate a scenario with directory symlinks for testing. ```bash mkdir rules mkdir rules/src exec ln -s src rules/dst exec ln -s rules linked ``` -------------------------------- ### Example: Disable Label Value Check for a Rule Source: https://github.com/cloudflare/pint/blob/main/docs/checks/promql/series.md Example of disabling the 'code' label value check for all metrics used in a specific Prometheus rule. ```yaml - alert: ... # disable code label checks for all metrics used in this rule # pint rule/set promql/series ignore/label-value code expr: rate(http_errors_total{code="500"}[2m]) > 0.1 ``` -------------------------------- ### Disable Specific Link Check Instance Example Source: https://github.com/cloudflare/pint/blob/main/docs/checks/rule/link.md Example of disabling a specific instance of the rule/link check using a regular expression pattern in the comment. ```yaml # pint disable rule/link(^https?://.+$) ``` -------------------------------- ### Pint CI Execution with GitHub Integration Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0085_github_no_envs.txt This snippet demonstrates the setup and execution of the Pint CI tool in a simulated GitHub Actions environment. It includes initializing a git repository, configuring Pint, and running the CI check. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=master . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' env GITHUB_AUTH_TOKEN=12345 env GITHUB_ACTION=YES env GITHUB_PULL_REQUEST_NUMBER=123 exec pint -l debug --offline --no-color ci ! stdout . stderr 'level=INFO msg="Pull request review created" status="200 OK"' cmp github.got ../github.expected ``` -------------------------------- ### Input Time Series for NaN Example Source: https://github.com/cloudflare/pint/blob/main/docs/checks/promql/nan.md Provides sample time series data for the 'errors' and 'total' metrics used in the NaN aggregation example. ```text errors{cluster="us", instance="a"} 5 errors{cluster="us", instance="b"} 3 errors{cluster="us", instance="c"} 0 total{cluster="us", instance="a"} 100 total{cluster="us", instance="b"} 200 total{cluster="us", instance="c"} 0 ``` -------------------------------- ### Initialize and Configure Local Repository for Pint CI Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0246_ci_github_new_file.txt This snippet shows the shell commands to set up a local repository, copy Pint configuration and rules, and commit them. It's used to prepare the environment before running the Pint CI check. ```shell mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import config' exec git checkout -b v2 cp ../src/rules.yml rules.yml exec git add . exec git commit -am 'add new rules file' ``` -------------------------------- ### Alert Rule Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0162_ci_deleted_dependency.txt An example of an alert rule in YAML format. This rule triggers when the 'up:sum' metric is 0 and includes annotations and labels. ```yaml groups: - name: g1 rules: - alert: Alert expr: 'up:sum == 0' annotations: summary: 'Service is down' labels: cluster: dev ``` -------------------------------- ### Local Repository Setup and Git Operations Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0069_bitbucket_unmodified.txt Commands to set up a local Git repository, initialize it, add configuration files, commit changes, and create a new branch for testing. ```bash http start bitbucket 127.0.0.1:6069 mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' ``` -------------------------------- ### Local Repository Setup and Configuration Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0075_ci_strict.txt Commands to set up a local Git repository, copy rule and configuration files, and configure Git author/committer information for commits. ```bash http start bitbucket 127.0.0.1:6075 mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' ``` -------------------------------- ### Example of a Relaxed Rule File Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0067_relaxed.txt This is an example of a Prometheus rule file that can be parsed with relaxed rules. It defines an alert 'Owner Set' with a specific expression. ```yaml # pint ignore/line - alert: Owner Set expr: up{job="foo"} == 0 ``` -------------------------------- ### Initialize Git Repository and Configure Pint Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0027_ci_branch.txt Sets up a new Git repository, initializes it with a main branch, copies Pint configuration and rules, and commits the initial setup. Ensures Git author and committer information are set for commits. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' ``` -------------------------------- ### Prometheus Rule Example (v2) Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0027_ci_branch.txt An example of a Prometheus rule definition for v2. This version also contains a syntax error in 'rule2' for demonstration purposes. ```yaml - record: rule1 expr: sum(foo) bi(job) - record: rule2 expr: sum(foo) bi(job) ``` -------------------------------- ### Pint CI Test Setup and Execution Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0273_ci_bitbucket_comment_create_error.txt Sets up a local Git repository, configures Pint for Bitbucket CI, and executes the CI command, simulating an error during report submission. ```shell http start bitbucket 127.0.0.1:7273 mkdir testrepo cd testrepo exec git init --initial-branch=main . cp ../src/v1.yml rules.yml cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import rules and config' exec git checkout -b v2 cp ../src/v2.yml rules.yml exec git commit -am 'v2' env BITBUCKET_AUTH_TOKEN="12345" ! exec pint --no-color ci ! stdout . stderr 'msg="Problems found"' stderr 'submitting reports: POST request failed' ``` -------------------------------- ### Get Current User Information Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0163_ci_comment_resolve_blocker.txt This GET request fetches information about the currently authenticated user. It can be used to verify authentication or gather user-specific details. ```shell GET /plugins/servlet/applinks/whoami Accept-Encoding: gzip Authorization: Bearer "12345" Content-Type: application/json ``` -------------------------------- ### Setting up a Local Git Repository for Pint CI Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0245_ci_gitlab_new_file.txt This sequence of commands initializes a local Git repository, copies Pint configuration files, and sets Git author/committer information before committing. It's used to prepare the environment for Pint's CI checks. ```bash mkdir testrepo cd testrepo exec git init --initial-branch=main . ``` ```bash cp ../src/.pint.hcl . env GIT_AUTHOR_NAME=pint env GIT_AUTHOR_EMAIL=pint@example.com env GIT_COMMITTER_NAME=pint env GIT_COMMITTER_EMAIL=pint@example.com exec git add . exec git commit -am 'import config' ``` ```bash exec git checkout -b v2 cp ../src/rules.yml rules.yml exec git add . exec git commit -am 'add new rules file' ``` -------------------------------- ### Build Pint from Source Source: https://github.com/cloudflare/pint/blob/main/docs/index.md Clone the repository and build the Pint binary using make. This is an alternative to downloading a pre-built binary. ```shell git clone https://github.com/cloudflare/pint.git cd pint make ``` -------------------------------- ### Expected GitHub API GET Request for Comments Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0098_rule_file_symlink_gh.txt Details the expected GET requests to the GitHub API for retrieving pull request and issue comments. ```http GET /api/v3/repos/cloudflare/pint/pulls/1/comments Accept: application/vnd.github.squirrel-girl-preview, application/vnd.github.comfort-fade-preview+json Accept-Encoding: gzip Authorization: Bearer 12345 X-Github-Api-Version: 2022-11-28 GET /api/v3/repos/cloudflare/pint/issues/1/comments Accept: application/vnd.github.squirrel-girl-preview Accept-Encoding: gzip Authorization: Bearer 12345 X-Github-Api-Version: 2022-11-28 ``` -------------------------------- ### Prometheus Rule Example 2 Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0208_lint_full_path.txt Another Prometheus rule definition for a 'test2' group. This demonstrates a separate rule set, similar in structure to the first example. ```yaml groups: - name: test2 rules: - record: "colo:test2" expr: sum(foo) without(job) ``` -------------------------------- ### v2 Alert Rule Example Source: https://github.com/cloudflare/pint/blob/main/cmd/pint/tests/0173_rule_duplicate_move.txt An example of a Prometheus alert rule file in version 2, containing 'Alert1' and a duplicate 'Alert3'. 'Alert2' from v1 is missing. ```yaml groups: - name: g1 rules: - alert: Alert1 expr: up == 0 - alert: Alert3 expr: up == 0 ```