1、/api/v1/query(GET/POST)
     即时查询,使用参数如下:
     - query=<查询语句>
     - time=<rfc3339 | unix_timestamp>时间戳,可选项
     - timeout=<duration>: 超时时间,-query.timeout限制,可选项
     若time不给定,默认为服务器当前时间。
     
     curl 'http://localhost:9090/api/v1/query?query=up'
     curl 'http://localhost:9090/api/v1/query?query=up&time=2022-11-28T02:10:30.781Z'

2、/api/v1/query_range(GET/POST)
     范围查询,使用参数如下:
     - query=<查询语句>
     - start=<rfc3339 | unix_timestamp>:开始时间(包含该值)
     - end=<rfc3339 | unix_timestamp>:结束时间(包含该值)
     - step=<duration | float>duration:浮点格式的步长
     - timeout=<duration>: 超时时间
      curl 'http://localhost:9090/api/v1/query_range?query=up&start=2022-11-28T02:10:30.781Z&end=2022-11-29T20:11:00.781Z&step=15m'

3、/api/v1/series(GET/POST)
    元数据序列查询,使用参数如下:
    - match[]=<series_selector>:选择返回参数
    - start=<rfc3339 | unix_timestamp>:开始时间
    - end=<rfc3339 | unix_timestamp>:结束时间

    curl -g 'http://localhost:9090/api/v1/series?''match[]=up'

4、/api/v1/labels
    获取元数据标签
    - match[]=<series_selector>:选择返回参数
    - start=<rfc3339 | unix_timestamp>:开始时间
    - end=<rfc3339 | unix_timestamp>:结束时间

删除数据

curl -X POST -g 'http://127.0.0.1:9090/api/v1/admin/tsdb/delete_series?match[]=node_cpu_seconds_total{mode="idle"}'
curl -X POST -g 'http://127.0.0.1:8001/api/v1/admin/tsdb/delete_series?match[]=node_cpu_seconds_total{mode="idle"}&start=684810073&end=1685069273'
#注:需加上 --web.enable-admin-api 启动参数才能删除操作
#nohup ./prometheus --config.file=prometheus.yml --web.listen-address=:8001 --storage.tsdb.retention.time=90d --web.enable-lifecycle --web.enable-admin-api &

  

 posted on 2023-05-16 09:19  boye169  阅读(70)  评论(0编辑  收藏  举报