All Projects → caarlos0 → promfmt

caarlos0 / promfmt

Licence: MIT license
format prometheus .rules files

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Makefile
30231 projects

promfmt

This is in an early stage. It works, but may change in the future!

Creates a pattern for Prometheus .rules files.

In short, files like this:

# this is my custom metric
custom_metric = sum(another_metric) BY (name)



# this will alert when blah blah blah blah
alert MyAlert
 IF custom_metric > 10 FOR 10m
  Labels {
	  call= "ghostbusters",
  }
  aNnotations { foo ="bar"}

# sometimes people do comment in blocks
# let's also make that work as expected...
alert Super_Alert
 if blah > 1
 for 1m

Will look like this:

# this is my custom metric
custom_metric{} = sum(another_metric) BY (name)

# this will alert when blah blah blah blah
ALERT MyAlert
  IF custom_metric > 10
  FOR 10m
  LABELS {
    call = "ghostbusters",
  }
  ANNOTATIONS {
    foo = "bar",
  }

# sometimes people do comment in blocks
# let's also make that work as expected...
ALERT Super_Alert
  IF blah > 1
  FOR 1m

Usage

# format and prints the output to stdout
promfmt FILE

# format and rewrites the file
promfmt --write FILE

# prints the diff
promfmt --diff FILE

# fails if not formatted
promfmt --fail FILE

Installing

On macOS with homebrew:

brew install caarlos0/tap/promfmt

Or, on Linux or macOS boxes without homebrew:

curl -sfL https://git.io/promfmt | bash -s -- -b /usr/local/bin
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].