Skip to content

Commit 5ab2c5e

Browse files
refactor script
1 parent f8db961 commit 5ab2c5e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

resources/ingest_demo_data.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ curl_with_retry() {
1919
local data="$3"
2020
local content_type="${4:-application/json}"
2121
local max_retries="${5:-3}"
22+
local data_file="$6"
2223
local retry_count=0
23-
local data_file="$7"
2424

2525
# Create temp file if data is provided (either as string or file)
2626
if [[ -n "$data_file" ]]; then
@@ -214,7 +214,7 @@ send_batch() {
214214
return 1
215215
fi
216216

217-
curl_with_retry "$P_URL/api/v1/ingest" "POST" "$data" "application/json" 3 15
217+
curl_with_retry "$P_URL/api/v1/ingest" "POST" "$data" "application/json" 3
218218
}
219219

220220
# Main ingest function
@@ -291,7 +291,7 @@ create_sql_filters() {
291291

292292
json="{\"stream_name\":\"sql\",\"filter_name\":\"$name\",\"filter_description\":\"$escaped_desc\",\"query\":{\"filter_type\":\"sql\",\"filter_query\":\"$escaped_query\"},\"time_filter\":null}"
293293

294-
if curl_with_retry "$P_URL/api/v1/filters" "POST" "$json" "application/json" 3 10; then
294+
if curl_with_retry "$P_URL/api/v1/filters" "POST" "$json" "application/json" 3; then
295295
sql_success_count=$((sql_success_count + 1))
296296
echo "Created SQL filter: $name"
297297
else
@@ -341,7 +341,7 @@ create_saved_filters() {
341341

342342
json="{\"stream_name\":\"$P_STREAM\",\"filter_name\":\"$name\",\"filter_description\":\"$escaped_desc\",\"query\":{\"filter_type\":\"filter\",\"filter_query\":\"$escaped_query\"},\"time_filter\":null,\"tableConfig\":{\"visibleColumns\":[$visible_cols_json],\"pinnedColumns\":[]},\"groupBy\":\"$group_by\"}"
343343

344-
if curl_with_retry "$P_URL/api/v1/filters" "POST" "$json" "application/json" 3 10; then
344+
if curl_with_retry "$P_URL/api/v1/filters" "POST" "$json" "application/json" 3; then
345345
saved_success_count=$((saved_success_count + 1))
346346
echo "Created saved filter: $name"
347347
else
@@ -409,7 +409,7 @@ create_alerts() {
409409
# Alert 1: Error Count (severity_number = 18)
410410
alert1_json="{\"severity\":\"high\",\"title\":\"error count\",\"stream\":\"$P_STREAM\",\"alertType\":\"threshold\",\"aggregates\":{\"aggregateConfig\":[{\"aggregateFunction\":\"count\",\"conditions\":{\"operator\":null,\"conditionConfig\":[{\"column\":\"severity_number\",\"operator\":\"=\",\"value\":\"18\"}]},\"column\":\"severity_number\",\"operator\":\">\",\"value\":1000}]},\"evalConfig\":{\"rollingWindow\":{\"evalStart\":\"5h\",\"evalEnd\":\"now\",\"evalFrequency\":1}},\"targets\":[\"$target_id\"]}"
411411

412-
response1=$(curl_with_retry "$P_URL/api/v1/alerts" "POST" "$alert1_json" "application/json" 3 10)
412+
response1=$(curl_with_retry "$P_URL/api/v1/alerts" "POST" "$alert1_json" "application/json" 3)
413413
if [[ $? -eq 0 ]]; then
414414
echo "Alert 1 (Error Count) created successfully"
415415
else
@@ -420,7 +420,7 @@ create_alerts() {
420420
# Alert 2: 400 Errors
421421
alert2_json="{\"severity\":\"critical\",\"title\":\"400 Errors\",\"stream\":\"$P_STREAM\",\"alertType\":\"threshold\",\"aggregates\":{\"aggregateConfig\":[{\"aggregateFunction\":\"count\",\"conditions\":{\"operator\":null,\"conditionConfig\":[{\"column\":\"body\",\"operator\":\"contains\",\"value\":\"400\"}]},\"column\":\"body\",\"operator\":\">\",\"value\":10}]},\"evalConfig\":{\"rollingWindow\":{\"evalStart\":\"5h\",\"evalEnd\":\"now\",\"evalFrequency\":1}},\"targets\":[\"$target_id\"]}"
422422

423-
response2=$(curl_with_retry "$P_URL/api/v1/alerts" "POST" "$alert2_json" "application/json" 3 10)
423+
response2=$(curl_with_retry "$P_URL/api/v1/alerts" "POST" "$alert2_json" "application/json" 3)
424424
if [[ $? -eq 0 ]]; then
425425
echo "Alert 2 (400 Errors) created successfully"
426426
else
@@ -431,7 +431,7 @@ create_alerts() {
431431
# Alert 3: Trace ID or Span ID null
432432
alert3_json="{\"severity\":\"high\",\"title\":\"Trace ID or Span ID null\",\"stream\":\"$P_STREAM\",\"alertType\":\"threshold\",\"aggregates\":{\"aggregateConfig\":[{\"aggregateFunction\":\"count\",\"conditions\":{\"operator\":null,\"conditionConfig\":[{\"column\":\"trace_id\",\"operator\":\"is null\",\"value\":\"\"}]},\"column\":\"trace_id\",\"operator\":\">\",\"value\":0}]},\"evalConfig\":{\"rollingWindow\":{\"evalStart\":\"5h\",\"evalEnd\":\"now\",\"evalFrequency\":1}},\"targets\":[\"$target_id\"]}"
433433

434-
response3=$(curl_with_retry "$P_URL/api/v1/alerts" "POST" "$alert3_json" "application/json" 3 10)
434+
response3=$(curl_with_retry "$P_URL/api/v1/alerts" "POST" "$alert3_json" "application/json" 3)
435435
if [[ $? -eq 0 ]]; then
436436
echo "Alert 3 (Trace ID null) created successfully"
437437
else
@@ -795,7 +795,7 @@ update_dashboard() {
795795
EOF
796796
)
797797

798-
response=$(curl_with_retry "$P_URL/api/v1/dashboards/$dashboard_id" "PUT" "$dashboard_config" "application/json" 3 10)
798+
response=$(curl_with_retry "$P_URL/api/v1/dashboards/$dashboard_id" "PUT" "$dashboard_config" "application/json" 3)
799799
if [[ $? -eq 0 ]]; then
800800
echo "Dashboard updated successfully"
801801
return 0

0 commit comments

Comments
 (0)