|
20 | 20 | - "charts/memgraph/**" |
21 | 21 | - "charts/memgraph-high-availability/**" |
22 | 22 | - "scripts/remote-monitoring-stack.yaml" |
| 23 | + - "scripts/verify-remote-monitoring.sh" |
23 | 24 | - ".github/workflows/test-remote-monitoring.yaml" |
24 | 25 |
|
25 | 26 | jobs: |
@@ -104,57 +105,9 @@ jobs: |
104 | 105 |
|
105 | 106 | - name: Verify metrics and logs reach monitoring cluster |
106 | 107 | run: | |
107 | | - set -euo pipefail |
108 | | - kubectl wait -n remote-monitoring --for=condition=available deployment/monitoring-gateway --timeout=180s |
109 | | -
|
110 | | - kubectl port-forward -n remote-monitoring svc/monitoring-gateway 18080:80 >/tmp/pf-gateway.log 2>&1 & |
111 | | - PF_GATEWAY_PID=$! |
112 | | - kubectl port-forward -n remote-monitoring svc/victoria-logs 19428:9428 >/tmp/pf-vlogs.log 2>&1 & |
113 | | - PF_VLOGS_PID=$! |
114 | | - trap 'kill $PF_GATEWAY_PID $PF_VLOGS_PID >/dev/null 2>&1 || true' EXIT |
115 | | - sleep 5 |
116 | | -
|
117 | | - GREEN='\033[0;32m' |
118 | | - YELLOW='\033[1;33m' |
119 | | - RED='\033[0;31m' |
120 | | - BLUE='\033[0;34m' |
121 | | - NC='\033[0m' |
122 | | -
|
123 | | - echo -e "${BLUE}Checking remote_write metrics ingestion...${NC}" |
124 | | - for i in $(seq 1 40); do |
125 | | - resp="$(curl -s -u ci-monitor:ci-monitor-pass 'http://127.0.0.1:18080/api/v1/query?query=count(up%7Bjob%3D%22memgraph-exporter%22%2Cservice_name%3D%22memgraph-ha%22%7D)')" |
126 | | - val="$(python3 -c 'import json,sys; r=json.loads(sys.argv[1]).get("data",{}).get("result",[]); print("0" if not r else r[0]["value"][1])' "$resp" 2>/dev/null || echo 0)" |
127 | | - if python3 -c 'import sys; sys.exit(0 if float(sys.argv[1]) > 0 else 1)' "$val" |
128 | | - then |
129 | | - echo -e "${GREEN}Metrics are ingested (matching series: ${val}).${NC}" |
130 | | - break |
131 | | - fi |
132 | | - if [[ "$i" -eq 40 ]]; then |
133 | | - echo -e "${RED}Timed out waiting for remote metrics ingestion.${NC}" |
134 | | - exit 1 |
135 | | - fi |
136 | | - echo -e "${YELLOW}Metrics not ingested yet (attempt ${i}/40, value=${val}).${NC}" |
137 | | - sleep 10 |
138 | | - done |
139 | | -
|
140 | | - echo -e "${BLUE}Checking Loki push traffic on VictoriaLogs...${NC}" |
141 | | - for i in $(seq 1 40); do |
142 | | - log_push_total="$(curl -s http://127.0.0.1:19428/metrics | awk '/\/insert\/loki\/api\/v1\/push/ { sum += ($NF+0) } END { print sum+0 }')" |
143 | | - if python3 -c 'import sys; sys.exit(0 if float(sys.argv[1]) > 0 else 1)' "$log_push_total"; then |
144 | | - echo -e "${GREEN}Logs are ingested (Loki push metric sum: ${log_push_total}).${NC}" |
145 | | - echo -e "${BLUE}Sample gateway access logs (Loki push path):${NC}" |
146 | | - kubectl logs -n remote-monitoring deploy/monitoring-gateway --tail=50 | grep '/loki/api/v1/push' || true |
147 | | - echo -e "${BLUE}Sample Memgraph vector sidecar logs:${NC}" |
148 | | - kubectl logs -n default memgraph-data-0-0 -c memgraph-vector --tail=20 || true |
149 | | - break |
150 | | - fi |
151 | | - if [[ "$i" -eq 40 ]]; then |
152 | | - echo -e "${RED}Timed out waiting for log ingestion.${NC}" |
153 | | - exit 1 |
154 | | - fi |
155 | | - echo -e "${YELLOW}Logs not ingested yet (attempt ${i}/40, push sum=${log_push_total}).${NC}" |
156 | | - sleep 10 |
157 | | - done |
| 108 | + scripts/verify-remote-monitoring.sh \ |
| 109 | + --service-name memgraph-ha \ |
| 110 | + --sample-pod memgraph-data-0-0 |
158 | 111 |
|
159 | 112 | - name: Collect diagnostics on failure |
160 | 113 | if: failure() |
@@ -249,57 +202,9 @@ jobs: |
249 | 202 |
|
250 | 203 | - name: Verify metrics and logs reach monitoring cluster |
251 | 204 | run: | |
252 | | - set -euo pipefail |
253 | | - kubectl wait -n remote-monitoring --for=condition=available deployment/monitoring-gateway --timeout=180s |
254 | | -
|
255 | | - kubectl port-forward -n remote-monitoring svc/monitoring-gateway 18080:80 >/tmp/pf-gateway.log 2>&1 & |
256 | | - PF_GATEWAY_PID=$! |
257 | | - kubectl port-forward -n remote-monitoring svc/victoria-logs 19428:9428 >/tmp/pf-vlogs.log 2>&1 & |
258 | | - PF_VLOGS_PID=$! |
259 | | - trap 'kill $PF_GATEWAY_PID $PF_VLOGS_PID >/dev/null 2>&1 || true' EXIT |
260 | | - sleep 5 |
261 | | -
|
262 | | - GREEN='\033[0;32m' |
263 | | - YELLOW='\033[1;33m' |
264 | | - RED='\033[0;31m' |
265 | | - BLUE='\033[0;34m' |
266 | | - NC='\033[0m' |
267 | | -
|
268 | | - echo -e "${BLUE}Checking remote_write metrics ingestion...${NC}" |
269 | | - for i in $(seq 1 40); do |
270 | | - resp="$(curl -s -u ci-monitor:ci-monitor-pass 'http://127.0.0.1:18080/api/v1/query?query=count(up%7Bjob%3D%22memgraph-exporter%22%2Cservice_name%3D%22memgraph-standalone%22%7D)')" |
271 | | - val="$(python3 -c 'import json,sys; r=json.loads(sys.argv[1]).get("data",{}).get("result",[]); print("0" if not r else r[0]["value"][1])' "$resp" 2>/dev/null || echo 0)" |
272 | | - if python3 -c 'import sys; sys.exit(0 if float(sys.argv[1]) > 0 else 1)' "$val" |
273 | | - then |
274 | | - echo -e "${GREEN}Metrics are ingested (matching series: ${val}).${NC}" |
275 | | - break |
276 | | - fi |
277 | | - if [[ "$i" -eq 40 ]]; then |
278 | | - echo -e "${RED}Timed out waiting for remote metrics ingestion.${NC}" |
279 | | - exit 1 |
280 | | - fi |
281 | | - echo -e "${YELLOW}Metrics not ingested yet (attempt ${i}/40, value=${val}).${NC}" |
282 | | - sleep 10 |
283 | | - done |
284 | | -
|
285 | | - echo -e "${BLUE}Checking Loki push traffic on VictoriaLogs...${NC}" |
286 | | - for i in $(seq 1 40); do |
287 | | - log_push_total="$(curl -s http://127.0.0.1:19428/metrics | awk '/\/insert\/loki\/api\/v1\/push/ { sum += ($NF+0) } END { print sum+0 }')" |
288 | | - if python3 -c 'import sys; sys.exit(0 if float(sys.argv[1]) > 0 else 1)' "$log_push_total"; then |
289 | | - echo -e "${GREEN}Logs are ingested (Loki push metric sum: ${log_push_total}).${NC}" |
290 | | - echo -e "${BLUE}Sample gateway access logs (Loki push path):${NC}" |
291 | | - kubectl logs -n remote-monitoring deploy/monitoring-gateway --tail=50 | grep '/loki/api/v1/push' || true |
292 | | - echo -e "${BLUE}Sample Memgraph vector sidecar logs:${NC}" |
293 | | - kubectl logs -n default memgraph-db-0 -c memgraph-vector --tail=20 || true |
294 | | - break |
295 | | - fi |
296 | | - if [[ "$i" -eq 40 ]]; then |
297 | | - echo -e "${RED}Timed out waiting for log ingestion.${NC}" |
298 | | - exit 1 |
299 | | - fi |
300 | | - echo -e "${YELLOW}Logs not ingested yet (attempt ${i}/40, push sum=${log_push_total}).${NC}" |
301 | | - sleep 10 |
302 | | - done |
| 205 | + scripts/verify-remote-monitoring.sh \ |
| 206 | + --service-name memgraph-standalone \ |
| 207 | + --sample-pod memgraph-db-0 |
303 | 208 |
|
304 | 209 | - name: Collect diagnostics on failure |
305 | 210 | if: failure() |
|
0 commit comments