【问题标题】:Assignin labelvalues in curl command在 curl 命令中分配标签值
【发布时间】:2017-09-15 11:53:04
【问题描述】:
os.system('curl --insecure -g  https://ab/api/v1/query?query=m{site_name="a"}')

//每当我运行它时,我都会遇到错误 {"status":"error","errorType":"bad_data","error":"在 char 25 处解析错误:标签匹配中出现意外 \"}\",预期字符串"}

【问题讨论】:

    标签: python curl prometheus


    【解决方案1】:

    我假设您想通过 curl 命令中的标签值进行查询,因为无法通过 HTTP API 分配新标签。

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

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

    Prometheus documentation 对此进行了介绍

    请注意,最好使用库来查询 API,而不是使用 Python 发出 curl 请求。

    【讨论】:

    • 相同的 curl 命令在 shell 中运行,但我遇到了问题 {"status":"error","errorType":"bad_data","error":"parse error at char 25 : 标签匹配中出现意外标识符“BishopGate”。
    • 知道如何解析“BishopGate”。我尝试了“BishopGate”
    • @ush 很高兴我能帮上忙。您是否考虑过使用库而不是在 python 中发出 curl 请求?这样查询 api 可能会容易得多!
    猜你喜欢
    • 2021-03-06
    • 1970-01-01
    • 1970-01-01
    • 2012-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-27
    相关资源
    最近更新 更多