通过API接口创建grafana的dashboard
  uvM09mQNI0hF 2023年11月19日 30 0


curl -v -H 'Content-Type:application/json;charset=utf8' -X POST -d pro-kube-system-grafana.json -u admin:xxxxxxx http://114.114.114.114:3000/api/dashboards/db
#需要注意
批量替换json文件中的servicename,NAMESPACE,grafanaEnv,grafanaFolderId才可使用
pro-kube-system-grafana.json

{
"dashboard": {
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana -",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": null,
  "graphTooltip": 0,
  "id": null,
  "iteration" 1693480666423,
  "links": [],
  "panels": [
    {
      "datasource": "Loki",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "gridPos": {
        "h": 20,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "showLabels": false,
        "showTime": false,
        "sortOrder": "Descending",
        "wrapLogMessage": true
      },
      "pluginVersion": "7.3.1",
      "tagets": [
        {
          "expr": "{env=\"grafanaEnv\",namspace=\"NAMESPACE\",container=\"servicename\"} |= \"$ServicePersonalKW"",
          "legendFormat": "",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "servicename",
      "type": "logs"
    }
  ],
  "schemaVersion": 26,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "",
          "value": ""
        },
        "error": null,
        "hide": 0,
        "label": "关键字",
        "name": "ServicePersonalKW",
        "options": [
          {
            "selected": true,
            "text": "",
            "value": ""
          }
        ],
        "query": "",
        "skipUrlSync": false,
        "type": "textbox"
      }
    ]
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "servicename",
  "version": 3
},
  "folderId": grafanaFolderId     #grafanaFolderId 需要自己在grafana查看,此次不做说明
}

参考官网:https://grafana.com/docs/grafana/latest/developers/http_api/dashboard/


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: 注释 下一篇: Linux三剑客(1)·grep
  1. 分享:
最后一次编辑于 2023年11月19日 0

暂无评论

推荐阅读
  m33FiQF5dk1h   2023年11月13日   18   0   0 重启IISjson
  0C74k909wmgc   2023年11月13日   19   0   0 pythonjson
  hs9CtFCuSvuL   2023年11月19日   21   0   0 DatabaseHCLjson
uvM09mQNI0hF