forked from grafana/pyroscope
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial docs for the /pyroscope/render API endpoint (grafana#2837)
* Add initial docs for the /pyroscope/render API endpoint * Improve /render endpoint docs following feedback * Add two more links
- Loading branch information
Showing
2 changed files
with
245 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requests | ||
from requests.auth import HTTPBasicAuth | ||
|
||
# NOTE: For original docs visit information visit: | ||
# https://grafana.com/docs/pyroscope/next/configure-server/about-server-api/ | ||
|
||
# Authentication details if using cloud | ||
basic_auth_username = '<username>' # Replace with your Grafana Cloud stack user | ||
basic_auth_password = '<password>' # Replace with your Grafana Cloud API key | ||
pyroscope_server = 'https://profiles-prod-001.grafana.net' | ||
|
||
# If not using cloud, use the following: | ||
# pyroscope_server = 'http://localhost:4040' # replace with your server address:port | ||
|
||
application_name = 'my_application_name' | ||
query = f'process_cpu:cpu:nanoseconds:cpu:nanoseconds{{service_name="{application_name}"}}' | ||
query_from = 'now-1h' | ||
pyroscope_url = f'{pyroscope_server}/pyroscope/render?query={query}&from={query_from}' | ||
|
||
# Sending the request with authentication | ||
response = requests.get( | ||
pyroscope_url, | ||
auth=HTTPBasicAuth(basic_auth_username, basic_auth_password) | ||
) | ||
|
||
# Checking the response | ||
if response.status_code == 200: | ||
print(response.text) | ||
else: | ||
print(f"Failed to query data. Status code: {response.status_code}, Message: {response.text}") |