logs.unturf.com/test_agent.sh
Russell Ballestrini 65df3368f3 the ability to search is done.
modified:   .gitignore
	modified:   app.py
	modified:   templates/base.html.j2
	modified:   templates/view_namespace_logs.html.j2
	modified:   test_agent.sh
2025-01-12 06:57:06 -05:00

34 lines
1.1 KiB
Bash

#!/usr/bin/env bash
# Usage:
# ./test_agent.sh "Your log message"
# Description:
# Sends a log message to the PyraLogs server using the provided JWT token.
# Adjust the BASE_URL and JWT_TOKEN variables as needed.
# Variables
BASE_URL="http://127.0.0.1:6544"
JWT_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZ2VudF9pZCI6IjcxZmQ0ZjA0LTQ2NzgtNGEyNi05ZmU4LTkxNjU2OTNmOTBmOSIsImFnZW50X25hbWUiOiJ0ZXN0LTkwMDAiLCJuYW1lc3BhY2VfaWQiOiJhZGQwYWQ1YS0zNjE0LTRhODgtOTRmZC0xNGQ4ZDBkYjIxYjUiLCJ0b2tlbl92ZXJzaW9uIjo1LCJpYXQiOjE3MzY2ODIxMTV9.p2HQmjFBtL9XLePtVCu3HyPhw89993BO4b6E82SwyEM"
# Log message from the first argument
LOG_MESSAGE="$1"
# Check if a log message was provided
if [[ -z "$LOG_MESSAGE" ]]; then
echo "Usage: $0 \"Your log message\""
exit 1
fi
# Send the log message using curl
RESPONSE=$(curl -s -X POST "$BASE_URL/webhook" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $JWT_TOKEN" \
-d "{
\"message\": \"$LOG_MESSAGE\",
\"level\": \"INFO\",
\"metadata\": {\"w\": 1}
}")
# Output the server's response
echo "Server Response: $RESPONSE"