Hi everyone, As you know from the dashboard the least standard timeframe is the last 5 minutes, we wanted to know the last 1 minute, so I used the same script as I did before when I wanted to get the visits per day (Check the article). And just changed the time frame I now made a new script that checks the concurrent visits for the last minute. The script is below: #!/bin/bash
now=$(date +"%s.%3N" | awk '{printf "%d%03d\n", $1, substr($2,1,3)}')
lastmin=$(date -d "now - 1 minute" +"%s.%3N" | awk '{printf "%d%03d\n", $1, substr($2,1,3)}')
scrollid=$(curl -s -X POST "<ES_IP>:9080/events/query?start=${lastmin}&end=${now}" -H"X-Events-API-Key:<API-KEY>" -H"X-Events-API-AccountName:<Your-Account-Global-Name>" -H"Content-Type:application/vnd.appd.events+text;v=2" -H"Accept:application/vnd.appd.events+json;v=2" -d"[{ \"query\": \"SELECT * FROM web_session_records\", \"mode\": \"scroll\"}]" | grep -oP '(?<="scrollid":").*?(?=",)')
curlout=$(curl -s -i \
-H "Accept: application/vnd.appd.events+json;v=2" \
-H "Content-Type:application/vnd.appd.events+text;v=2" \
-H "X-Events-API-Key:<API-KEY>" \
-H "X-Events-API-AccountName:<Your-Account-Global-Name>" \
-d "[{ \"query\": \"SELECT count(*) FROM web_session_records\", \"mode\": \"scroll\", \"scrollid\":\"$scrollid\"}]" \
-X POST "http://<ES_IP>:9080/events/query?start=${lastmin}&end=${now}")
echo "$curlout" | grep -o '"results":\[\[[0-9]*\]\]' | cut -d "[" -f3 | cut -d "]" -f1 Also, I made a small webserver on port 8000 that returns the output of this script: https://<Contoller_IP>:8000 Do you guys have a better way to do it? Best regards, Mohamed Ashraf Mohamed Ashraf Application Operations Engineer Platform & IT Solution Ops team Saudi Company for Visa and Travel Solutions (SVTS) Phone: +966549574746 Email: mmahmoud.c@saudivts.com Riyadh, Saudi Arabia
... View more