Skip to content

Commit 16d0bcb

Browse files
authored
feat: Make configurable cubestore metrics address (#6437) Thanks @fbalicchia !
* make configurable metrics address * fix merge * run fmt * apply change to doc
1 parent 771f661 commit 16d0bcb

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

docs/content/Reference/Configuration/Environment-Variables-Reference.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,32 @@ If `true`, then send telemetry to Cube.
887887
| --------------- | ---------------------- | --------------------- |
888888
| `true`, `false` | `true` | `true` |
889889

890+
## `CUBESTORE_METRICS_FORMAT`
891+
892+
Define which metrics collector format.
893+
894+
| Possible Values | Default in Development | Default in Production |
895+
| --------------- | ---------------------- | --------------------- |
896+
| `statsd`, `dogstatsd` | `statsd` | `statsd` |
897+
898+
899+
## `CUBESTORE_METRICS_ADDRESS`
900+
901+
Required IP address to send metrics.
902+
903+
| Possible Values | Default in Development | Default in Production |
904+
| --------------- | ---------------------- | --------------------- |
905+
| A valid IP address | `127.0.0.1` | `127.0.0.1` |
906+
907+
908+
## `CUBESTORE_METRICS_PORT`
909+
910+
Required port to send where collector server accept UDP connections.
911+
912+
| Possible Values | Default in Development | Default in Production |
913+
| --------------- | ---------------------- | --------------------- |
914+
| A valid port number | `8125` | `8125` |
915+
890916
## `CUBEJS_TOUCH_PRE_AGG_TIMEOUT`
891917

892918
The number of seconds without a touch before pre-aggregation is considered

rust/cubestore/cubestore/src/bin/cubestored.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,26 @@ fn main() {
2222
.as_str()
2323
.unwrap()
2424
.to_string();
25-
let metrics_mode = match std::env::var("CUBESTORE_METRICS") {
25+
let metrics_format = match std::env::var("CUBESTORE_METRICS_FORMAT") {
2626
Ok(s) if s == "statsd" => metrics::Compatibility::StatsD,
2727
Ok(s) if s == "dogstatsd" => metrics::Compatibility::DogStatsD,
2828
Ok(s) => panic!(
29-
"CUBESTORE_METRICS must be 'statsd' or 'dogstatsd', got '{}'",
29+
"CUBESTORE_METRICS_FORMAT must be 'statsd' or 'dogstatsd', got '{}'",
3030
s
3131
),
3232
Err(_) => metrics::Compatibility::StatsD,
3333
};
34-
init_metrics("127.0.0.1:0", "127.0.0.1:8125", metrics_mode, vec![]);
34+
let metrics_addr =
35+
std::env::var("CUBESTORE_METRICS_ADDRESS").unwrap_or("127.0.0.1".to_string());
36+
let metrics_port = std::env::var("CUBESTORE_METRICS_PORT").unwrap_or("8125".to_string());
37+
let metrics_server_address = format!("{}:{}", metrics_addr, metrics_port);
38+
39+
init_metrics(
40+
"127.0.0.1:0",
41+
metrics_server_address,
42+
metrics_format,
43+
vec![],
44+
);
3545
let telemetry_env = std::env::var("CUBESTORE_TELEMETRY")
3646
.or(std::env::var("CUBEJS_TELEMETRY"))
3747
.unwrap_or("true".to_string());

0 commit comments

Comments
 (0)