Skip to content

Commit c317271

Browse files
committed
feat: Support configuring Parseable via TOML config file
Signed-off-by: “niladrix719” <niladrix719@gmail.com>
1 parent 7adda55 commit c317271

File tree

7 files changed

+474
-95
lines changed

7 files changed

+474
-95
lines changed

Cargo.lock

Lines changed: 93 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ erased-serde = "=0.3.16"
6262
serde = { version = "1.0", features = ["rc", "derive"] }
6363
serde_json = "1.0"
6464
serde_repr = "0.1.17"
65+
toml = "0.9.8"
6566

6667
# Async and Runtime
6768
async-trait = "0.1"

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,26 @@ curl --location --request POST 'http://localhost:8000/api/v1/ingest' \
8585

8686
Access the UI at [http://localhost:8000 ↗︎](http://localhost:8000). You can login to the dashboard default credentials `admin`, `admin`.
8787

88+
### Configure with TOML
89+
90+
We can keep Parseable configuration in a TOML file instead of managing dozens of environment variables. When a file named `parseable.toml` is present in the working directory, Parseable automatically loads it; you can also point to a different file via `parseable --config-file /path/to/config.toml` (or by setting `P_CONFIG_FILE`).
91+
92+
Example:
93+
94+
```toml
95+
# parseable.toml
96+
storage = "s3-store"
97+
98+
[env]
99+
P_S3_URL = "https://s3.amazonaws.com"
100+
P_S3_REGION = "us-east-1"
101+
P_S3_BUCKET = "my-observability-bucket"
102+
P_USERNAME = "admin"
103+
P_PASSWORD = "super-secret"
104+
```
105+
106+
Values from the TOML file are written to the corresponding `P_*` environment variables unless they are already set in the shell. Command-line flags still take precedence over everything else, so you can override individual fields without editing the file.
107+
88108
## Getting started :bulb:
89109

90110
For quickstart, refer the [quickstart section ↗︎](#quickstart-zap).

src/cli.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ Join the community at https://logg.ing/community.
6666
subcommand_required = true,
6767
)]
6868
pub struct Cli {
69+
#[arg(
70+
long = "config-file",
71+
short = 'c',
72+
env = "P_CONFIG_FILE",
73+
value_name = "path",
74+
global = true,
75+
value_parser = validation::file_path,
76+
help = "Path to a TOML file containing Parseable environment defaults"
77+
)]
78+
pub config_file: Option<PathBuf>,
6979
#[command(subcommand)]
7080
pub storage: StorageOptions,
7181
}

0 commit comments

Comments
 (0)