Not a customer? Click the 'Start a free trial' link to begin a 30-day SaaS trial of our product and to join our community.
Existing Cisco AppDynamics customers should click the 'Sign In' button to authenticate to access the community
03-16-2024 04:43 AM
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:
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
|
Thank you! Your submission has been received!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form