curl 返回json 并格式化

应用

curl http://url/path | python -m json.tool

例子

curl 'http://localhost:9090/api/v1/targets?state=active' | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   573  100   573    0     0  50087      0 --:--:-- --:--:-- --:--:-- 95500
{
    "status": "success",
    "data": {
        "activeTargets": [
            {
                "discoveredLabels": {
                    "__address__": "localhost:9090",
                    "__metrics_path__": "/metrics",
                    "__scheme__": "http",
                    "__scrape_interval__": "15s",
                    "__scrape_timeout__": "10s",
                    "job": "prometheus"
                },
                "labels": {
                    "instance": "localhost:9090",
                    "job": "prometheus"
                },
                "scrapePool": "prometheus",
                "scrapeUrl": "http://localhost:9090/metrics",
                "globalUrl": "http://5139fd605963:9090/metrics",
                "lastError": "",
                "lastScrape": "2022-08-24T07:16:13.163976926Z",
                "lastScrapeDuration": 0.013138167,
                "health": "up",
                "scrapeInterval": "15s",
                "scrapeTimeout": "10s"
            }
        ],
        "droppedTargets": []
    }
}
posted @   Star-Hitian  阅读(759)  评论(0编辑  收藏  举报
历史上的今天:
2021-08-24 Python3 re
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 海阔天空 Beyond
  2. 2 此生过半 Audio artist
  3. 3 让我欢喜让我忧 Audio artist
  4. 4 P.I.M.P. Audio artist
  5. 5 Extasy Audio artist
此生过半 - Audio artist
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

Not available