1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Emits a minimal Snappy-compressed Prometheus WriteRequest to stdout.
//!
//! Used by `scripts/verify-http-auth.sh` to produce a valid remote-write payload
//! for testing auth (401 vs 200). The payload contains one series with one sample.
//!
//! When ugnosd has auth enabled, configure `UGNOS__HTTP_WRITE_TOKEN` or `http_write_token`
//! in TOML (see README). POST with `Authorization: Bearer <token>`.
//!
//! Run with: `cargo run --example gen_minimal_write_request`
//!
//! Output is raw binary (Snappy-compressed protobuf). Running directly will show
//! garbled bytes in the terminal; pipe the output to curl or another consumer.
//!
//! Simplest way: run `./scripts/verify-http-auth.sh`. To do it manually:
//!
//! Terminal 1 (start daemon, leave running):
//! ```ignore
//! DATA=$(mktemp -d)
//! UGNOS__HTTP_WRITE_TOKEN=verify-auth-token ./target/release/ugnosd \
//! --no-config --data-dir "$DATA" --http-bind 127.0.0.1:18180
//! ```
//!
//! Terminal 2 (pipe payload to curl):
//! ```ignore
//! TOKEN=verify-auth-token cargo run -q --example gen_minimal_write_request 2>/dev/null | \
//! curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/x-protobuf" \
//! --data-binary @- http://127.0.0.1:18180/api/v1/write
//! ```
//!
//! Stop daemon with Ctrl+C in terminal 1. Wait for it to exit fully before `rm -rf "$DATA"`.
use Message;
use ;