O11y toolkit
GitHub Support Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

oy-expose

Usage

usage: oy-expose [<flags>] [<metrics-file>]


Flags:
  -h, --[no-]help                Show context-sensitive help (also try
                                 --help-long and --help-man).
      --[no-]web.systemd-socket  Use systemd socket activation listeners instead
                                 of port listeners (Linux only).
      --web.listen-address=:9099 ...  
                                 Addresses on which to expose metrics and web
                                 interface. Repeatable for multiple addresses.
      --web.config.file=""       Path to configuration file that can
                                 enable TLS or authentication. See:
                                 https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md
      --web.telemetry-path="/metrics"  
                                 Path under which to expose metrics.
      --[no-]web.disable-exporter-metrics  
                                 Exclude metrics about the exporter itself
                                 (promhttp_*, process_*, go_*).
      --log.level=info           Only log messages with the given severity or
                                 above. One of: [debug, info, warn, error]
      --log.format=logfmt        Output format of log messages. One of: [logfmt,
                                 json]
      --[no-]version             Show application version.

Args:
  [<metrics-file>]  File to read metrics from.

Description

oy-expose reads a metrics file and exposes its content to be scraped by a Prometheus server.

This is similar to the Node Exporter Textfile Collector, with a few differences:

  • oy-expose only exposes on file.
  • oy-expose does not embed other collectors.

Example usage

Let’s create a file called “metrics” with the following content:

maintenance_script_run_timestamp_seconds 1647524557
maintenance_script_return_code 0

We can run oy-expose:

$ oy-expose --web.disable-exporter-metrics

And query the metrics:

$ curl localhost:9099/metrics
# HELP maintenance_script_return_code Metric read from metrics
# TYPE maintenance_script_return_code untyped
maintenance_script_return_code 0
# HELP maintenance_script_run_timestamp_seconds Metric read from metrics
# TYPE maintenance_script_run_timestamp_seconds untyped
maintenance_script_run_timestamp_seconds 1.647524557e+09
# HELP node_textfile_mtime_seconds Unixtime mtime of textfiles successfully read.
# TYPE node_textfile_mtime_seconds gauge
node_textfile_mtime_seconds{file="metrics"} 1.647530635e+09
# HELP node_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise
# TYPE node_textfile_scrape_error gauge
node_textfile_scrape_error 0

Downloading

To execute oy-expose within Linux, run:

wget https://github.com/o11ydev/oy-toolkit/releases/download/main/oy-expose -O oy-expose && chmod +x oy-expose && ./oy-expose --help

To execute oy-expose with docker, run:

docker run quay.io/o11y/oy-toolkit:oy-expose --help

To execute oy-expose with nix, run:

nix run github:o11ydev/oy-toolkit#oy-expose -- --help