Skip to content

dbsync metrics query filter by namespace #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions operator/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ pub async fn run_metrics_collector(state: Arc<State>) {
let config = get_config();
let mut last_execution = Utc::now();

let current_namespace = client.default_namespace();

loop {
tokio::time::sleep(config.metrics_delay).await;

Expand All @@ -154,10 +156,9 @@ pub async fn run_metrics_collector(state: Arc<State>) {
last_execution = end;

let query = format!(
"sum by (user) (avg_over_time(pgbouncer_pools_client_active_connections{{user=~\"dmtr_.*\"}}[{interval}s] @ {})) > 0",
"sum by (user) (avg_over_time(pgbouncer_pools_client_active_connections{{user=~\"dmtr_.*\", namespace=\"{current_namespace}\"}}[{interval}s] @ {})) > 0",
end.timestamp_millis() / 1000
);
dbg!(&query);

let response = collect_prometheus_metrics(config, query).await;
if let Err(err) = response {
Expand Down
Loading