Prakhar Gurunani
07/15/2024, 8:19 AMSrikanth Chekuri
07/15/2024, 8:30 AMPrakhar Gurunani
07/15/2024, 12:02 PMPrakhar Gurunani
07/15/2024, 12:08 PMquery_range
endpoint on v4
.Srikanth Chekuri
07/15/2024, 12:29 PMPrakhar Gurunani
07/15/2024, 4:02 PMimport requests
import json
url = "<QUERY_SERVICE_URL>/api/v4/query_range"
headers = {
"authorization": "<AUTH_TOKEN>",
"content-type": "application/json",
"Cache-Control": "no-cache"
}
data = {'start': 1721022356, 'end': 1721027356, 'step': 60, 'variables': {}, 'compositeQuery': {'queryType': 'promql', 'panelType': 'graph', 'promQueries': {'default': {'disabled': False, 'legend': '', 'name': 'default', 'query': 'sum(kube_pod_info{cluster="cluster"})'}}}}
try:
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print("Request successful!")
print(json.dumps(response.json(), indent=2))
else:
print(f"Request failed with status code: {response.status_code}")
print(response.text)
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
Srikanth Chekuri
07/15/2024, 10:35 PM