You can hack your way around it as long as you're not too picky about what you want to query. E.g. if you want to query all up time series and all cpu_utilization time series, you can use something like this:
{__name__=~"up|cpu_utilization"}
It will even work with range queries, as long as you want the same range for all time series:
{__name__=~"up|cpu_utilization"}[1m]
But not if you want different time ranges or want to add selectors (e.g. there's no easy way of combining up{job="prometheus} and cpu_utilization{instance="foo:8080"}).
You can hack your way around it as long as you're not too picky about what you want to query. E.g. if you want to query all up time series and all cpu_utilization time series, you can use something like this:
{__name__=~"up|cpu_utilization"}
It will even work with range queries, as long as you want the same range for all time series:
{__name__=~"up|cpu_utilization"}[1m]
But not if you want different time ranges or want to add selectors (e.g. there's no easy way of combining up{job="prometheus} and cpu_utilization{instance="foo:8080"}).
You can't send multiple queries as query= qry1 qry2.. in a single HTTP API call. If you take a closer look to the response object:
$ curl 'http://localhost:9090/api/v1/query?query=up&time=2015-07-01T20:10:51.781Z'
{
"status" : "success",
"data" : {
"resultType" : "vector",
"result" : [
{
"metric" : {
"__name__" : "up",
"job" : "prometheus",
"instance" : "localhost:9090"
},
"value": [ 1435781451.781, "1" ]
},
{
"metric" : {
"__name__" : "up",
"job" : "node",
"instance" : "localhost:9100"
},
"value" : [ 1435781451.781, "0" ]
}
]
}
}
You will see that "data" field contains only two keys (i.e. "resultType" and "result") and it isn't an array itself. So there is no chance that "data" will hold the result of multiple queries.
Your code is almost correct, just pass the query as a parameter to the URL. See this abbreviated snippet of code taken from here:
response = requests.get('http://localhost:9090/api/v1/query'),
params={'query': "query=container_cpu_load_average_10s{container_name=POD}"})
print(response.json()['data']['result'])
#!/usr/bin/env python
import requests
prome_sql = "(node_memory_MemTotal_bytes - (node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes)) / node_memory_MemTotal_bytes * 100"
response = requests.get('http://192.168.20.249:9090/api/v1/query',
params={'query': prome_sql})
print(response.json()["data"]['result'])