在 curl 命令中分配标签值

Assignin labelvalues in curl command

os.system('curl --insecure -g  https://ab/api/v1/query?query=m{site_name="a"}')

//每当我 运行 时,我都会收到错误消息 {"status":"error","errorType":"bad_data","error":"parse error at char 25: unexpected \"}\" in label matching, expected string"}

我假设您想在 curl 命令中按标签值查询,因为无法通过 HTTP API.

分配新标签

以下示例将 return 所有与您问题中给出的选择器相匹配的系列:

os.system('curl --insecure -g \'http://localhost:9090/api/v1/series?match[]=mulpi_Version{site_name="BishopGate"}\'')

这在 Prometheus documentation

请注意,使用库查询 API 可能比使用 Python 发出 curl 请求更好。