diff --git a/Chart.yaml b/Chart.yaml index e2c00e0..04596fe 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: pgdog-control description: PgDog Control type: application -version: 0.2.15 -appVersion: "29a6513b" +version: 0.2.16 +appVersion: "84c7c56a" diff --git a/README.md b/README.md index 687a58f..40a0210 100644 --- a/README.md +++ b/README.md @@ -662,7 +662,7 @@ control: ### Alerting -`control.config.alerts` enables outbound alert integrations. Leave `incident_io` unset to disable incident.io. Thresholds are optional and only configured metrics create alerts. +`control.config.alerts` enables outbound alert integrations. Leave `incident_io` unset to disable incident.io. Alert conditions are optional; only configured metric thresholds and explicitly enabled query alerts create incidents. ```yaml control: @@ -674,6 +674,7 @@ control: cpu: 90.0 memory: 2048 server_connections: 100 + slow_queries: true incident_io: api_key: inc_live_xxx ``` @@ -685,6 +686,7 @@ control: | `thresholds.cpu` | CPU usage percentage. Must be between `0.0` and `100.0`, inclusive (float, optional). | | `thresholds.memory` | Memory used, in megabytes (int, optional). | | `thresholds.server_connections` | Number of open server connections (int, optional). | +| `thresholds.slow_queries` | Create incidents for queries whose duration reaches `store.slow_queries_threshold` (bool, default `false`). | | `incident_io.api_key` | incident.io API key with permission to create incidents. Missing `incident_io` disables the integration (string, optional). | ### State store @@ -700,6 +702,7 @@ control: evict_after_secs: 60 metrics_retention_secs: 300 query_history_limit: 1000 + slow_queries_threshold: 5000 autoreload: immediately # or in_sync, or off ``` @@ -710,6 +713,7 @@ control: | `evict_after_secs` | Instance is dropped from the store entirely if its newest metric is older than this (int, default `60`). | | `metrics_retention_secs` | How much per-instance metric history is kept in memory. Older points are dropped as new ones arrive (int, default `300`). | | `query_history_limit` | Per-token historical query store capacity. Oldest deduped query entries are evicted first once the limit is reached (int, default `1000`). | +| `slow_queries_threshold` | Minimum query duration, in milliseconds, for classifying a query as slow (int, default `5000`). | | `autoreload` | Automatically enqueue `reload_configuration` for instances that report config drift (enum, default `off`, available options: `off`, `immediately`, `in_sync`). | ### Slack Notifications diff --git a/templates/configmap.yaml b/templates/configmap.yaml index f2ed014..77616b5 100644 --- a/templates/configmap.yaml +++ b/templates/configmap.yaml @@ -93,6 +93,9 @@ data: {{- if hasKey . "query_history_limit" }} query_history_limit = {{ .query_history_limit }} {{- end }} + {{- if hasKey . "slow_queries_threshold" }} + slow_queries_threshold = {{ .slow_queries_threshold }} + {{- end }} {{- if hasKey . "autoreload" }} autoreload = {{ .autoreload | quote }} {{- end }} @@ -207,6 +210,9 @@ data: {{- if hasKey . "server_connections" }} server_connections = {{ .server_connections }} {{- end }} + {{- if hasKey . "slow_queries" }} + slow_queries = {{ .slow_queries }} + {{- end }} {{- end }} {{- with .incident_io }} diff --git a/test/test.sh b/test/test.sh index f4a4d21..df85acd 100755 --- a/test/test.sh +++ b/test/test.sh @@ -14,6 +14,12 @@ for values_file in "$TEST_DIR"/values-*.yaml; do helm template test-release "$CHART_DIR" -f "$values_file" > /dev/null done +echo "" +echo "==> Verifying query alert settings..." +full_render=$(helm template test-release "$CHART_DIR" -f "$TEST_DIR/values-full.yaml") +grep -q '^ slow_queries_threshold = 2500$' <<< "$full_render" +grep -q '^ slow_queries = true$' <<< "$full_render" + echo "" echo "==> Verifying external Redis rendering..." external_render=$(helm template test-release "$CHART_DIR" -f "$TEST_DIR/values-redis-external.yaml") diff --git a/test/values-full.yaml b/test/values-full.yaml index 1b79fb7..3e3d233 100644 --- a/test/values-full.yaml +++ b/test/values-full.yaml @@ -32,6 +32,7 @@ control: process_notify_interval_secs: 30 metrics_retention_secs: 600 query_history_limit: 500 + slow_queries_threshold: 2500 autoreload: "immediately" autoscaling: pool_size: true @@ -68,6 +69,7 @@ control: cpu: 90.0 memory: 2048 server_connections: 100 + slow_queries: true incident_io: api_key: incident-token slack: diff --git a/values.yaml b/values.yaml index 6cf615f..61a5765 100644 --- a/values.yaml +++ b/values.yaml @@ -104,6 +104,7 @@ control: # process_notify_interval_secs: 60 # metrics_retention_secs: 300 # query_history_limit: 1000 + # slow_queries_threshold: 5000 # Minimum query duration in milliseconds. # autoreload: off autoscaling: {} # pool_size: false @@ -155,6 +156,7 @@ control: # cpu: 90.0 # memory: 2048 # server_connections: 100 + # slow_queries: false # incident_io: # api_key: "" slack: {}