Skip to content

Commit

Permalink
prompt for default nest/module in fluent-bit-setup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed Jul 29, 2024
1 parent 8405dec commit 8476f11
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions scripts/third-party-logs/fluent-bit-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ function InstallFluentBit() {
###############################################################################
# identify malcolm connection information
function GetMalcolmConnInfo() {
local INPUT_NAME="$1"
IP=
PORT=
FORMAT=
Expand All @@ -210,6 +211,8 @@ function GetMalcolmConnInfo() {
SUGGESTED_PORT=5045
SUGGESTED_FORMAT=json_lines
SUGGESTED_AGENT_NAME="$(hostname)"
SUGGESTED_NEST="$INPUT_NAME"
SUGGESTED_MODULE="$INPUT_NAME"

while [[ -z "$IP" ]] || \
[[ -z "$PORT" ]] || \
Expand All @@ -219,8 +222,8 @@ function GetMalcolmConnInfo() {
PORT="$(_GetString "Enter Malcolm Filebeat TCP port ($SUGGESTED_PORT):" "$SUGGESTED_PORT")"
AGENT_NAME="$(_GetString "Enter agent hostname ($SUGGESTED_AGENT_NAME):" "$SUGGESTED_AGENT_NAME")"
FORMAT="$(_GetString "Enter fluent-bit output format ($SUGGESTED_FORMAT):" "$SUGGESTED_FORMAT")"
NEST="$(_GetString "Nest values under field:")"
MODULE="$(_GetString "Add \"module\" value:")"
NEST="$(_GetString "Nest values under field ($SUGGESTED_NEST):" "$SUGGESTED_NEST")"
MODULE="$(_GetString "Add \"module\" value ($SUGGESTED_MODULE):" "$SUGGESTED_MODULE")"
done

if [[ -r "$SCRIPT_PATH"/ca.crt ]] && \
Expand Down Expand Up @@ -322,7 +325,7 @@ function GetMalcolmConnInfo() {
###############################################################################
# identify information for fluent-bit intput/output
function GetFluentBitFormatInfo() {
INPUT_NAME=
local INPUT_NAME=
declare -A PARAMS

echo "Choose input plugin and enter parameters. Leave parameters blank for defaults." >&2
Expand Down Expand Up @@ -587,6 +590,9 @@ function GetFluentBitFormatInfo() {
done

FLUENTBIT_ARGS=()
# this one's not actually going in the arguments, but is returned at the beginning
# so it can be shifted off and used in gathering some other information
FLUENTBIT_ARGS+=( "$INPUT_NAME" )
FLUENTBIT_PARSER_CFG=$(_fluentbit_parser_cfg)
if [[ -n "$FLUENTBIT_PARSER_CFG" ]]; then
FLUENTBIT_ARGS+=( -R )
Expand Down Expand Up @@ -710,8 +716,10 @@ if [[ -z "$USER_FUNCTION_IDX" ]] || (( $USER_FUNCTION_IDX == 0 )); then
# do everything, in order
if InstallFluentBit; then
readarray -t FLUENTBIT_INPUT_INFO < <(GetFluentBitFormatInfo)
if [[ "${#FLUENTBIT_INPUT_INFO[@]}" -ge 2 ]]; then
readarray -t MALCOLM_CONN_INFO < <(GetMalcolmConnInfo)
if [[ "${#FLUENTBIT_INPUT_INFO[@]}" -ge 3 ]]; then
INPUT_NAME="${FLUENTBIT_INPUT_INFO[0]}"
FLUENTBIT_INPUT_INFO=("${FLUENTBIT_INPUT_INFO[@]:1}")
readarray -t MALCOLM_CONN_INFO < <(GetMalcolmConnInfo "$INPUT_NAME")
if [[ "${#MALCOLM_CONN_INFO[@]}" -ge 4 ]]; then
FLUENTBIT_COMMAND=("$(_fluentbit_bin)" "${FLUENTBIT_INPUT_INFO[@]}" "${MALCOLM_CONN_INFO[@]}")
echo
Expand Down

0 comments on commit 8476f11

Please sign in to comment.