prom_text_format_parser 0.1.0

A crate to parse and print Prometheus exposition text format
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use prom_text_format_parser::Scrape;

fn main() {
    let path = std::env::args().nth(1).expect("A path to scrape text");
    let text = std::fs::read_to_string(path).expect("file read");
    let mut scrape = Scrape::parse(&text).expect("valid scrape");

    // Add a label to all metrics
    scrape.add_label("source", "invalid");

    // Print the scrape in the Prometheus exposition text format
    println!("{scrape}");
}