prometheus-textformat-merge

command module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

README

Utility to merge Prometheus textformat files

Latest release Release workflow CI workflow Go reference

prometheus-textformat-merge is a command line program to combine multiple Prometheus textformat inputs.

Prometheus' node exporter has a textfile collector reading textformat files in a predetermined directory. When multiple files contain the same metrics, albeit with different labels, collection fails (see also prometheus/node_exporter#1885).

There are other use cases where combining multiple metrics sources is useful, e.g. after downloading them from a collector using cURL.

The following inputs are supported:

  • Regular files using the Prometheus text format
  • Standard input
  • Directories with multiple files with the --dirs flag (enumerates *.prom in the given directories by default)

Example usage

$ cat >first.prom <<'EOF'
# HELP node_disk_io_time_seconds_total Total seconds spent doing I/Os.
# TYPE node_disk_io_time_seconds_total counter
node_disk_io_time_seconds_total{device="dm-0"} 581.412
node_disk_io_time_seconds_total{device="dm-1"} 483.348
EOF

$ cat >second.prom <<'EOF'
# HELP node_load5 5m load average.
# TYPE node_load5 gauge
node_load5 0.42
EOF

$ prometheus-textformat-merge first.prom second.prom
# HELP node_disk_io_time_seconds_total Total seconds spent doing I/Os.
# TYPE node_disk_io_time_seconds_total counter
node_disk_io_time_seconds_total{device="dm-0"} 581.412
node_disk_io_time_seconds_total{device="dm-1"} 483.348
# HELP node_load5 5m load average.
# TYPE node_load5 gauge
node_load5 0.42

Reading from standard input is also supported with the - placeholder:

$ prometheus-textformat-merge --output all.prom first.prom - <<'EOF'
# TYPE node_disk_io_time_seconds_total counter
node_disk_io_time_seconds_total{device="dm-4"} 104.156
node_disk_io_time_seconds_total{device="dm-5"} 0.372
EOF

$ cat all.prom
# HELP node_disk_io_time_seconds_total Total seconds spent doing I/Os.
# TYPE node_disk_io_time_seconds_total counter
node_disk_io_time_seconds_total{device="dm-0"} 581.412
node_disk_io_time_seconds_total{device="dm-1"} 483.348
node_disk_io_time_seconds_total{device="dm-4"} 104.156
node_disk_io_time_seconds_total{device="dm-5"} 0.372

Note how the same metric was combined from multiple sources and written to a file. See the --help output for available flags.

Installation

Pre-built binaries are provided for all releases:

  • Binary archives (.tar.gz)
  • Debian/Ubuntu (.deb)
  • RHEL/Fedora (.rpm)
  • Microsoft Windows (*.zip)

With the source being available it's also possible to produce custom builds directly using Go or GoReleaser.

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