-
hi, community, I can successfully do curl: curl -gLs 'http://localhost:8888/api/v1/meters/pod_exec_time/query?subject=wyusera-wenyanzuhu&groupBy=vm_name&filterGroupBy[vm_name]=matest&from=2025-03-21T07:00:00Z&to=2025-03-21T08:00:00Z&windowTimeZone=Etc/GMT-8&windowSize=DAY' curl output {
"data": [
{
"groupBy": {
"vm_name": "matest"
},
"subject": "wyusera-wenyanzuhu",
"value": 3600,
"windowEnd": "2025-03-22T00:00:00+08:00",
"windowStart": "2025-03-21T00:00:00+08:00"
}
],
"from": "2025-03-21T07:00:00Z",
"to": "2025-03-21T08:00:00Z",
"windowSize": "DAY"
} my python import requests
import rich
url = f"http://localhost:8888/api/v1/meters/pod_exec_time/query"
params = {
"subject": [
"wyusera-wenyanzuhu"
],
"groupBy": [
"vm_name"
],
"filterGroupBy": {
"vm_name": "matest"
},
"from": "2025-03-21T07:00:00Z",
"to": "2025-03-21T08:00:00Z",
"windowTimeZone": "Etc/GMT-8",
"windowSize": "DAY",
}
response = requests.get(url, params=params)
rich.print_json(data=response.json()) python output {
"data": [
{
"groupBy": {
"vm_name": "matest"
},
"subject": "wyusera-wenyanzuhu",
"value": 3600,
"windowEnd": "2025-03-22T00:00:00+08:00",
"windowStart": "2025-03-21T00:00:00+08:00"
},
{
"groupBy": {
"vm_name": "ecs1013"
},
"subject": "wyusera-wenyanzuhu",
"value": 3600,
"windowEnd": "2025-03-22T00:00:00+08:00",
"windowStart": "2025-03-21T00:00:00+08:00"
},
{
"groupBy": {
"vm_name": "test1552"
},
"subject": "wyusera-wenyanzuhu",
"value": 360,
"windowEnd": "2025-03-22T00:00:00+08:00",
"windowStart": "2025-03-21T00:00:00+08:00"
},
{
"groupBy": {
"vm_name": "ecs1011"
},
"subject": "wyusera-wenyanzuhu",
"value": 3600,
"windowEnd": "2025-03-22T00:00:00+08:00",
"windowStart": "2025-03-21T00:00:00+08:00"
}
],
"from": "2025-03-21T07:00:00Z",
"to": "2025-03-21T08:00:00Z",
"windowSize": "DAY"
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I've also tried json dumps. It does not work either. please help filters={"vm_name": "matest"},
params = {
"subject": [
"wyusera-wenyanzuhu"
],
"groupBy": [
"vm_name"
],
"filterGroupBy": json.dumps(filters),
"from": "2025-03-21T07:00:00Z",
"to": "2025-03-21T08:00:00Z",
"windowTimeZone": "Etc/GMT-8",
"windowSize": "DAY",
} |
Beta Was this translation helpful? Give feedback.
-
l've figured it out |
Beta Was this translation helpful? Give feedback.
-
I've figured it out: it turns out python request cannot pass a nested json, so one has to flatten it out as: params = {
"subject": [
"wyusera-wenyanzuhu"
],
"groupBy": [
"vm_name"
],
"filterGroupBy[vm_name]": "matest",
"from": "2025-03-21T07:00:00Z",
"to": "2025-03-21T08:00:00Z",
"windowTimeZone": "Etc/GMT-8",
"windowSize": "DAY",
} |
Beta Was this translation helpful? Give feedback.
I've figured it out: it turns out python request cannot pass a nested json, so one has to flatten it out as: