mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-02-11 09:01:10 +00:00
Create forward-logs.sh
Signed-off-by: lii5a <liisa.tallinn@gmail.com>
This commit is contained in:
parent
102107281e
commit
9ab6c941f8
1 changed files with 23 additions and 0 deletions
23
forward-logs.sh
Normal file
23
forward-logs.sh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
LOGFILE="/app/logs/app.log"
|
||||
INGEST_URL="$OPENPIPELINE_URL"
|
||||
TOKEN="$OPENPIPELINE_TOKEN"
|
||||
|
||||
echo "Starting log forwarder..."
|
||||
echo "Sending logs from $LOGFILE to $INGEST_URL"
|
||||
|
||||
mkdir -p /app/logs
|
||||
touch "$LOGFILE"
|
||||
|
||||
tail -F "$LOGFILE" | while read line; do
|
||||
TIMESTAMP=$(date -Iseconds)
|
||||
|
||||
JSON=$(printf '{"timestamp":"%s","message":%s,"source":"petclinic","location":"tallinn"}' \
|
||||
"$TIMESTAMP" "$(printf '%s' "$line" | jq -Rs)")
|
||||
|
||||
curl -s -X POST "$INGEST_URL" \
|
||||
-H "Authorization: Api-Token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON" > /dev/null
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue