REST API knowledge exchange
Post Reply
UmeshP
Influencer
Posts: 14
Liked: 3 times
Joined: Jan 14, 2021 8:01 am
Full Name: Umesh Phendarkar
Contact:

How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by UmeshP »

How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by Natalia Lupacheva » 1 person likes this post

Hi Umesh,

You can use Filter options.
You can use the filter we've discussed before (Result==failed) to get the jobs with 'Failed' status.

Possible values for Result parameters are:
  • Success
  • Warning
  • Failed
Here you can find the full list of the parameters you can use to filter the backup session data.

Thanks!
UmeshP
Influencer
Posts: 14
Liked: 3 times
Joined: Jan 14, 2021 8:01 am
Full Name: Umesh Phendarkar
Contact:

Re: How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by UmeshP »

Thanks ..Natalia, It is working for Filtering the Result for the job. However when i give Backup Server name, it does not give any output.

veeamEMUrl="https://XXmyveeam.net:9398/api/query?fo ... erver.NET)"

I wish to filter by particular backup Server.
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by Natalia Lupacheva »

Umesh,

you can add

Code: Select all

 BackupServerName==<your Backup server name>
or

Code: Select all

BackupServerUid==<your backup server id>
to the list of your filters.
Please let me know if it helps.

Thanks!
UmeshP
Influencer
Posts: 14
Liked: 3 times
Joined: Jan 14, 2021 8:01 am
Full Name: Umesh Phendarkar
Contact:

Re: How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by UmeshP »

Thanks ..Natalia.. By giving BackupServerName==<your Backup server name> it is not working.. Though i am filtering it with "grep -i " Command for linux. It is doing job for me now.
chris.arceneaux
VeeaMVP
Posts: 695
Liked: 374 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by chris.arceneaux »

Hi Umesh,

I was able to successfully use the BackupServerName filter in my lab. Please see below for my final URL. Perhaps you're missing quotes around the server name?

Code: Select all

/api/query?format=Entities&sortDesc=EndTime&type=backupJobSession&filter=EndTime>="2021-01-21T12:00:00.103Z";Result==Success;BackupServerName=="veeam.arsano.lab"
The name matches what I see in the API results without the filter in place:

Image
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by Natalia Lupacheva »

Umesh,

yep, Chris is right, I should have mentioned the quotes.
Also, you can try with BackupServerUid.

Thanks!
UmeshP
Influencer
Posts: 14
Liked: 3 times
Joined: Jan 14, 2021 8:01 am
Full Name: Umesh Phendarkar
Contact:

Re: How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by UmeshP »

Thanks For your Reply, However i have Figured it out and it is Working very Nice for me now. Below is my Complete Bash script for it :-

#!/bin/bash
veeamUsername="VeeamUSerName"
veeamPassword='VeeamPassword'
veeamJobSessions="100"
veeamAuth=$(echo -ne "$veeamUsername:$veeamPassword" | base64)
veeamRestServer="VeeamServerURL"
veeamRestPort="9398"
veeamSessionId=$(curl -X POST "https://$veeamRestServer:$veeamRestPort/api/sessionMngr/?v=latest" -H "Authorization:Basic $veeamAuth" -H "Content-Length: 0" -H "Accept: application/json" -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1' | jq --raw-output '.SessionId')

veeamXRestSvcSessionId=$(echo -ne "$veeamSessionId" | base64)
#echo $veeamXRestSvcSessionId >> /dev/null


timeend=$(date --date="-1 days" +%FT%TZ)


veeamEMUrl="https://aammsvemp001.aam.net:9398/api/q ... t==Success"

curl -k -X GET "$veeamEMUrl" -H "Accept:application/json" -H "X-RestSvcSessionId: $veeamXRestSvcSessionId" -H "Set-Cookie: X-RestSvcSessionId=veeamXRestSvcSessionId; Path=/api;" -H "Content-Length: 0" 2>&1 -k --silent | awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1' | python3.7 -m json.tool | grep -E '("BackupServerName"|"Result"|"EndTimeUTC")[^ ]*' | column -t

****************************************************************************************************************************************
It gives me below Responce or Output, And it will give response only for which BackupServer i am going to filter with Grep, Also is working for time and date variable, it is sending me response for last 24 Hours. :-

EndTimeUTC": "2021-01-29T03:30:56.16Z",
"Result": "Success",
"EndTimeUTC": "2021-01-29T03:28:48.813Z",
"Result": "Success",
"EndTimeUTC": "2021-01-29T03:23:50.507Z",
"Result": "Success",
"EndTimeUTC": "2021-01-29T03:22:49.713Z",
"Result": "Success",
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: How i can filter by BAckupServer name and Job Result Status as Failed and Success,Warning status ?

Post by Natalia Lupacheva »

Hi Umesh,

Thank you for sharing your results! Glad you've succeeded with it.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests