Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to get HUE metrics thru rest API end point "/desktop/metrics"

Highlighted

How to get HUE metrics thru rest API end point "/desktop/metrics"

New Contributor

Hi,

I am trying to access REST API metric end point thru my python code running on my desktop. But I am getting the HTML page only and not the actual metrics.
How should I access the metrics using this API end point?
Can this be accessed like what I am doing?
Hue version - 4.4
 
import requests
 
next_url = "/"
login_url = "http://<hostname>:8080/accounts/login"
 
session = requests.Session()
response = session.get(login_url)
 
form_data = {
    'username': 'xxxxx',
    'password': 'xxxxxx',
    'csrfmiddlewaretoken': session.cookies['csrftoken'],
    'next': next_url
}
response = session.post(login_url, data=form_data, cookies={}, headers={'Referer': login_url})
 
print('Logged in successfully: %s %s' % (response.status_code == 200, response.status_code))
 
cookies = session.cookies
headers = session.headers
 
response = session.get('http://<hostname>:8080/desktop/metrics')
print(response.status_code)
print(response.text)
 
 
Any help is highly appreciated.
 

 

Don't have an account?
Coming from Hortonworks? Activate your account here