cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.12.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/index.md

134lines · modecode

1---
2layout: default
3title: Documentation
4nav_order: 1
5has_children: true
6---
7
8# pint
9
10pint is a Prometheus rule linter.
11
12## Usage
13
14There are three modes it works in:
15
16- CI PR linting
17- Ad-hoc linting of a selected files or directories
18- A daemon that continuously checks selected files or directories and expose metrics describing
19 all discovered problems.
20
21### Pull Requests
22
23Run it with `pint ci`.
24
25It currently supports git for which it will find all commits on the current branch that are not
26present in the parent branch and scan all modified files included in those changes.
27
28Results can optionally be reported using
29[BitBucket API](https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-code-insights-rest.html)
30or [GitHub API](https://docs.github.com/en/rest) to generate a report with any found issues.
31If you are using BitBucket API then each issue will create an inline annotation in BitBucket with a description of
32the issue. If you are using GitHub API then each issue will appear as a comment on your pull request.
33
34Exit code will be one (1) if any issues were detected with severity `Bug` or higher. This permits running
35`pint` in your CI system whilst at the same you will get detailed reports on your source control system.
36
37### Ad-hoc
38
39Lint specified files and report any found issue.
40
41You can lint selected files:
42
43```shell
44pint lint rules.yml
45```
46
47or directories:
48
49```shell
50pint lint path/to/dir
51```
52
53or both:
54
55```shell
56pint lint path/to/dir file.yml path/file.yml path/dir
57```
58
59### Daemon
60
61Run the daemon:
62
63```shell
64pint watch rules.yml
65```
66
67By default it will start a HTTP server on port `8080` and run all checks every
6810 minutes. This can be customized by passing extra flags to the `watch` command.
69Run `pint watch -h` to see all available flags.
70
71Query `/metrics` to see all expose metrics, example with default flags:
72
73```shell
74curl -s http://localhost:8080/metrics
75```
76
77Or setup Prometheus scrape job:
78
79```yaml
80scrape_configs:
81 - job_name: pint
82 static_configs:
83 - targets: ['localhost:8080']
84```
85
86Available metrics:
87
88- `pint_problem` - exported for every problem detected by pint.
89 To avoid exposing too many metrics at once pass `--max-problems` flag to watch command.
90 When this flag is set pint will expose only up to `--max-problems` value number of
91 `pint_problem` metrics.
92- `pint_problems` - this metric is the total number of all problems detected by pint,
93 including those not exported due to the `--max-problems` flag.
94
95## Release Notes
96
97See [changelog](changelog.md) for history of changes.
98
99## Quick start
100
101Requirements:
102
103- [Git](https://git-scm.com/)
104- [Go](https://golang.org/) - current stable release
105
106Steps:
107
1081. Download a binary from [Releases](https://github.com/cloudflare/pint/releases) page
109 or build from source:
110
111 ```shell
112 git clone https://github.com/cloudflare/pint.git
113 cd pint
114 make
115 ```
116
1172. Run a simple syntax check on Prometheus
118 [alerting](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/)
119 or [recording](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/)
120 rules file(s).
121
122 ```shell
123 ./pint lint /etc/prometheus/*.rules.yml
124 ```
125
1263. Configuration file is optional, but without it pint will only run very basic
127 syntax checks. See [configuration](configuration.md) for details on
128 config syntax.
129 By default pint will try to load configuration from `.pint.hcl`, you can
130 specify a different path using `--config` flag:
131
132 ```shell
133 ./pint --config /etc/pint.hcl lint /etc/prometheus/rules/*.yml
134 ```
135