promtoolfmt

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

promtoolfmt

promtoolfmt is made for linting and formating prometheus metrics in text-based format.

How it works

promtoolfmt remove any duplicate metric/comment, performs a linting pass on metrics and format them using expfmt.

Usage

Usage of promtoolfmt:
  -silent
      Silent or quiet mode.
  -version
      Show version.

Run it

$ cat testdata/metrics-test.prom | promtoolfmt
# HELP test_metric_info A metric with a constant '1' value labeled by testlabel.
# TYPE test_metric_info gauge
test_metric_info{testlabel="testvalue1"} 1
test_metric_info{testlabel="testvalue2"} 1
# HELP test_metric_duplicate_info A metric with a constant '1' value labeled by testlabel.
# TYPE test_metric_duplicate_info gauge
test_metric_duplicate_info{testlabel="testvalue1"} 1
# HELP test_metric_with_spaces_info A metric with a constant '1' value labeled by testlabel.
# TYPE test_metric_with_spaces_info gauge
test_metric_with_spaces_info{testlabel="testvalue1",testanotherlabel="testanothervalue1"} 1
test_metric_with_spaces_info{testlabel="testvalue2",testanotherlabel="testanothervalue2"} 1

With silent mode

Use this mode to get exit code only (suppress any output/error)

$ cat testdata/metrics-test.prom | promtoolfmt -silent

Errors examples

$ cat testdata/invalid-metrics-no-help-text.prom | promtoolfmt
test_metric_info no help text
$ cat testdata/invalid-metrics-float-value.prom | promtoolfmt
error while linting: text format parsing error in line 4: expected float as value, got "1m"

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL