Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

Periscope API doesn't work for auto scaling

Hello Everyone,

I have installed Cloudbreak on Azure VM and provisioned HDP using it which has also enabled Periscope (default) Web UI (Uluwatu). This has helped me setting manual alarms and scaling policy from the UI. However, my aim is to achieve the same through API calls. I was able to connect Cloudbreak using below API method, first generate the access token and then connect to Cloudbreak through API:

Token Generation for Cloudbreak Shell (Worked):

export TOKEN=$(curl -iX POST -H "accept: application/x-www-form-urlencoded" -d 'credentials={"username":"admin@example.com","password":"password"}' "http://cloudbreakURI:8089/oauth/authorize?response_type=token&client_id=cloudbreak_shell" | grep Location | cut -d'=' -f 3 | cut -d'&' -f 1)

API call to Cloudbreak (Worked):

curl -k -X GET -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" https://cloudbreakUI/cb/api/v1/stacks/user

Now, I want to do the same thing with Periscope. I have followed the Periscope API "https://periscope.docs.apiary.io" which explains that we need to attach Ambari REST API Endpoint with Periscope. Here I got confused that if Periscope is running by default in Cloudbreak machine and I am able to set alarms in Periscope UI using Ambari alerts then why do I need to attach with a an existing cluster for API calls?

Periscope is running in CloudbreakVM:

[hduser@cloudbreakVM ~]$ ps -ef | grep periscope
hduser    41503  38823  0 06:55 pts/0    00:00:00 grep --color=auto periscope
root      66067  58001  0 Nov24 ?        00:00:00 /bin/bash /start_periscope_app.sh
root      66075  66067  0 Nov24 ?        00:07:55 java -jar /periscope.jar

In one of the github repository, I found below call method to generate the token for Periscope client but it doesn't generate in my case:

Token Generation for Periscope client (Doesn't work):

curl -iX POST -H "accept: application/x-www-form-urlencoded" -d 'credentials={"username":"admin@example.com","password":"password"}' "http://cloudbreakURI:8089/oauth/authorize?response_type=token&client_id=periscope-client&scope.0=openid&source=login&redirect_uri=http://periscope.client"

ERROR:

HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Cache-Control: no-store
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Content-Language: en
Content-Length: 0
Date: Sat, 25 Nov 2017 06:57:19 GMT
Connection: close


I also tried adding Ambari REST API endpoint as follows but no luck:

Attaching Ambari REST API to Periscope (Doesn't work):

curl --include \
    --request POST \
    --header "Content-Type: application/json" \
    -H "Authorization: Bearer $TOKEN" \
    --data-binary "{
   \"host\": \"AmbariURI\",
   \"port\": \"8080\",
   \"user\": \"admin\",
   \"pass\": \"admin\"
}" \
'http://AmbariURI:8080/api/v1/clusters/'

ERROR:

{
  "status": 403,
  "message": "Missing authentication token"
}

When I try to directly calls from Ambari REST API, it doesn't return any result:

curl -k -X GET -H "Content-Type: application/json" --user admin:admin http://AmbariURI:8080/api/v1/clusters/<clustername>/policies
curl -k -X GET -H "Content-Type: application/json" --user admin:admin http://AmbariURI:8080/api/v1/clusters/<clustername>/alarms

Can someone help in connecting Periscope APIs for autoscaling on a running HDP cluster.

Regards,

2 REPLIES 2

@Artem Ervits

@Neeraj Sabharwal

Could you please help in answering this question?

Finally, nailed it! Periscope has an additional path prefix which can be found with docker inspection command:

docker inspect <periscopeContainer> | grep path

Using the same token generated by cloudbreak client has worked.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.