Skip to content

Commit ad4e004

Browse files
add stream name to the ingest script param (#1696)
1 parent c849704 commit ad4e004

2 files changed

Lines changed: 28 additions & 23 deletions

File tree

scripts/ingest.ps1

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ param(
88
[string]$Param2,
99

1010
[Parameter(Position=2)]
11-
[string]$Param3
11+
[string]$Param3,
12+
13+
[Parameter(Position=3)]
14+
[string]$Param4
1215
)
1316

1417
$ProgressPreference = 'SilentlyContinue'
@@ -261,11 +264,12 @@ function Restart-FluentBit {
261264
function Setup-FluentBit {
262265
param(
263266
[string]$IngestorHost,
267+
[string]$StreamName,
264268
[string]$ApiKey,
265269
[string]$TenantId
266270
)
267271

268-
if ([string]::IsNullOrWhiteSpace($IngestorHost) -or [string]::IsNullOrWhiteSpace($ApiKey)) {
272+
if ([string]::IsNullOrWhiteSpace($IngestorHost) -or [string]::IsNullOrWhiteSpace($StreamName) -or [string]::IsNullOrWhiteSpace($ApiKey)) {
269273
Write-ErrorMsg "Invalid setup parameters"
270274
exit 1
271275
}
@@ -336,7 +340,7 @@ function Setup-FluentBit {
336340
}
337341

338342
$configLines += @(
339-
" Header X-P-Stream node-metrics",
343+
" Header X-P-Stream $StreamName",
340344
" Header X-P-Log-Source otel-metrics"
341345
)
342346

@@ -355,7 +359,7 @@ function Show-Help {
355359
Fluent Bit Setup and Management Script for Windows
356360
357361
Usage:
358-
Setup: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 [host[:port]] [api_key] [tenant_id]
362+
Setup: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 [host[:port]] [stream] [api_key] [tenant_id]
359363
Stop: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 stop
360364
Start: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 start
361365
Restart: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 restart
@@ -364,8 +368,8 @@ Usage:
364368
Debug: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 debug
365369
366370
Example:
367-
powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 https://your-host.com:443 px_api_key
368-
powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 http://localhost:8000 px_api_key tenant-id
371+
powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 https://your-host.com:443 node-metrics px_api_key
372+
powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 http://localhost:8000 node-metrics px_api_key tenant-id
369373
370374
"@
371375
}
@@ -420,11 +424,11 @@ switch ($Param1.ToLower()) {
420424
Show-Help
421425
}
422426
default {
423-
if ([string]::IsNullOrWhiteSpace($Param2)) {
424-
Write-ErrorMsg "Usage: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 [host[:port]] [api_key] [tenant_id]"
427+
if ([string]::IsNullOrWhiteSpace($Param2) -or [string]::IsNullOrWhiteSpace($Param3)) {
428+
Write-ErrorMsg "Usage: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 [host[:port]] [stream] [api_key] [tenant_id]"
425429
Write-ErrorMsg " Or: powershell -NoProfile -ExecutionPolicy Bypass -File .\ingest.ps1 [start|stop|restart|status|logs|debug|help]"
426430
exit 1
427431
}
428-
Setup-FluentBit -IngestorHost $Param1 -ApiKey $Param2 -TenantId $Param3
432+
Setup-FluentBit -IngestorHost $Param1 -StreamName $Param2 -ApiKey $Param3 -TenantId $Param4
429433
}
430434
}

scripts/ingest.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Fluent Bit Setup and Management Script
44
# Usage:
5-
# Setup: ./ingest.sh <host[:port]> <api_key> [tenant_id]
5+
# Setup: ./ingest.sh <host[:port]> <stream> <api_key> [tenant_id]
66
# Stop: ./ingest.sh stop
77
# Restart: ./ingest.sh restart
88
# Status: ./ingest.sh status
@@ -241,17 +241,18 @@ install_fluent_bit() {
241241
# Setup function
242242
setup_fluent_bit() {
243243
local INGESTOR_HOST="$1"
244-
local API_KEY="$2"
245-
local TENANT_ID="${3:-}"
244+
local STREAM_NAME="$2"
245+
local API_KEY="$3"
246+
local TENANT_ID="${4:-}"
246247
local TENANT_HEADER=""
247248
local TLS_SETTING="On"
248249
local DEFAULT_PORT="443"
249250
local PORT=""
250251

251252
# Validate all fields are present
252-
if [ -z "$INGESTOR_HOST" ] || [ -z "$API_KEY" ]; then
253+
if [ -z "$INGESTOR_HOST" ] || [ -z "$STREAM_NAME" ] || [ -z "$API_KEY" ]; then
253254
print_error "Invalid setup parameters"
254-
print_error "Expected format: $0 <host[:port]> <api_key> [tenant_id]"
255+
print_error "Expected format: $0 <host[:port]> <stream> <api_key> [tenant_id]"
255256
exit 1
256257
fi
257258

@@ -330,7 +331,7 @@ setup_fluent_bit() {
330331
TLS $TLS_SETTING
331332
Header X-API-Key $API_KEY
332333
${TENANT_HEADER}
333-
Header X-P-Stream node-metrics
334+
Header X-P-Stream $STREAM_NAME
334335
Header X-P-Log-Source otel-metrics
335336
EOF
336337
chmod 600 "$CONFIG_FILE"
@@ -363,7 +364,7 @@ case "${1:-}" in
363364
echo ""
364365
echo "Usage:"
365366
echo " Setup and start:"
366-
echo " $0 <host[:port]> <api_key> [tenant_id]"
367+
echo " $0 <host[:port]> <stream> <api_key> [tenant_id]"
367368
echo ""
368369
echo " Management commands:"
369370
echo " $0 start - Start Fluent Bit (if config exists)"
@@ -373,18 +374,18 @@ case "${1:-}" in
373374
echo " $0 logs - Show Fluent Bit logs"
374375
echo ""
375376
echo "Example:"
376-
echo " $0 https://example.parseable.com:443 px_api_key"
377-
echo " $0 http://localhost:8000 px_api_key tenant-id"
377+
echo " $0 https://example.parseable.com:443 node-metrics px_api_key"
378+
echo " $0 http://localhost:8000 node-metrics px_api_key tenant-id"
378379
;;
379380
*)
380381
# If not a command, treat as setup parameters
381-
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
382-
print_error "Usage: $0 <host[:port]> <api_key> [tenant_id]"
382+
if [ $# -lt 3 ] || [ $# -gt 4 ]; then
383+
print_error "Usage: $0 <host[:port]> <stream> <api_key> [tenant_id]"
383384
print_error " Or: $0 [start|stop|restart|status|logs|help]"
384385
print_error ""
385386
print_error "Example:"
386-
print_error " $0 https://ec9cfee0-2fd4-45eb-8209-d7cd992c4bcc-ingestor.workspace-staging.parseable.com:443 px_api_key"
387-
print_error " $0 http://localhost:8000 px_api_key tenant-id"
387+
print_error " $0 https://ec9cfee0-2fd4-45eb-8209-d7cd992c4bcc-ingestor.workspace-staging.parseable.com:443 node-metrics px_api_key"
388+
print_error " $0 http://localhost:8000 node-metrics px_api_key tenant-id"
388389
print_error ""
389390
print_error "Management commands:"
390391
print_error " $0 status - Check if running"
@@ -393,6 +394,6 @@ case "${1:-}" in
393394
print_error " $0 logs - View logs"
394395
exit 1
395396
fi
396-
setup_fluent_bit "$1" "$2" "${3:-}"
397+
setup_fluent_bit "$1" "$2" "$3" "${4:-}"
397398
;;
398399
esac

0 commit comments

Comments
 (0)