Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana API ---生成数据源,Jmeter模板的报表 #6

Open
margaretmm opened this issue Apr 27, 2018 · 0 comments
Open

Grafana API ---生成数据源,Jmeter模板的报表 #6

margaretmm opened this issue Apr 27, 2018 · 0 comments

Comments

@margaretmm
Copy link
Owner

#!/usr/bin/env python

-- coding: utf-8 --

import json
from urllib import response

import python_http_client
import sys
import time

#interval unit: seceond
import http.client
import urllib

def rest_get(host,url,auth=0):
conn = http.client.HTTPConnection(host)
if auth:
headers = {
'Accept': 'application / json',
'Connection': 'keep-alive',
'Authorization': 'Bearer '+auth
}
conn.request("GET", url,headers=headers)
else:
conn.request("GET", url)
r = conn.getresponse()
print(r.status, r.reason)
data1 = r.read()
print(data1)

def rest_post(host,url,data,auth=0):
conn = http.client.HTTPConnection(host)

if auth:
    headers = {
        'Accept': 'application / json',
        'Content-Type': 'application / json; charset=UTF-8',
        'Connection': 'keep-alive',
        'Authorization': 'Bearer ' + auth
    }
    conn.request("POST", url, body=json.dumps(data),headers=headers)
else:
    conn.request("POST", url, body=json.dumps(data))
r = conn.getresponse()
print(r.status, r.reason)
data1 = r.read()
print(data1)

if name == 'main':
auth_edit="eyJrIjoiQXZISTdPSEN5THMxNW81cm54SmVOajA4MWhIeFVZNHUiLCJuIjoiam1ldGVyIiwiaWQiOjF9"
auth_admin="eyJrIjoia2FQOEdWQk05VTZuSEZYVThBZlluVE1uMjlvcUhrT0UiLCJuIjoiam1ldGVyX2FkbWluIiwiaWQiOjF9"
dashboard_json = {
"dashboard": {
"__requires": [
{
"type": "panel",
"id": "text",
"name": "Text",
"version": ""
},
{
"type": "panel",
"id": "singlestat",
"name": "Singlestat",
"version": ""
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"version": ""
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "4.0.2"
},
{
"type": "datasource",
"id": "influxdb",
"name": "InfluxDB",
"version": "1.0.0"
}
],
"id": None,
"title": "ds_exe_id_4351",
"description": "This dashboard shows live load test metrics provided by JMeter.",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": True,
"sharedCrosshair": True,
"hideControls": False,
"time": {
"from": "now-1d/d",
"to": "now-1d/d"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"templating": {
"list": [
{
"allValue": None,
"current": {},
"datasource": "ds_exe_id_4351",
"hide": 0,
"includeAll": False,
"label": "Request",
"multi": False,
"name": "request",
"options": [],
"query": "SHOW TAG VALUES FROM "requestsRaw" WITH KEY = "requestName"",
"refresh": 1,
"regex": "",
"sort": 0,
"tagValuesQuery": None,
"tagsQuery": None,
"type": "query"
},
{
"auto": False,
"current": {
"tags": [],
"text": "1m",
"value": "60"
},
"datasource": None,
"hide": 0,
"includeAll": False,
"label": "Aggregation Interval",
"multi": False,
"name": "aggregation",
"options": [
{
"selected": False,
"text": "1s",
"value": "1"
},
{
"selected": False,
"text": "10s",
"value": "10"
},
{
"selected": False,
"text": "30s",
"value": "30"
},
{
"selected": True,
"text": "1m",
"value": "60"
},
{
"selected": False,
"text": "10m",
"value": "600"
},
{
"selected": False,
"text": "30m",
"value": "1800"
},
{
"selected": False,
"text": "1h",
"value": "3600"
}
],
"query": "1,10,30,60,600,1800,3600",
"refresh": 0,
"type": "custom",
"allValue": None
}
]
},
"annotations": {
"list": [
{
"datasource": "ds_exe_id_4351",
"enable": True,
"iconColor": "rgb(23, 255, 0)",
"name": "Test Start",
"query": "SELECT * FROM testStartEnd WHERE type='started'",
"tagsColumn": "type",
"titleColumn": "testName"
},
{
"datasource": "ds_exe_id_4351",
"enable": True,
"iconColor": "rgba(255, 96, 96, 1)",
"name": "Test End",
"query": "SELECT * FROM testStartEnd WHERE type='finished'",
"tagsColumn": "type",
"titleColumn": "testName"
}
]
},
"refresh": "5s",
"schemaVersion": 13,
"version": 2,
"links": [],
"gnetId": 1152,
"rows": [
{
"title": "Overview",
"panels": [
{
"content": "<h3 style="text-align: center;">The following panels show aggregated metrics for <span style="color: #00ccff;">all requests",
"editable": True,
"error": False,
"height": "180",
"id": 25,
"links": [],
"mode": "html",
"span": 2,
"title": "",
"transparent": True,
"type": "text"
},
{
"cacheTimeout": None,
"colorBackground": False,
"colorValue": False,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "ds_exe_id_4351",
"editable": True,
"error": False,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": False,
"thresholdLabels": False,
"thresholdMarkers": True
},
"height": "120",
"id": 14,
"interval": None,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"NonePointMode": "connected",
"NoneText": None,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "None",
"text": "N/A",
"to": "None"
}
],
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": False,
"lineColor": "rgb(31, 120, 193)",
"show": False
},
"targets": [
{
"dsType": "influxdb",
"groupBy": [],
"measurement": "virtualUsers",
"policy": "default",
"query": "SELECT last("startedThreads") FROM "virtualUsers" WHERE $timeFilter",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"meanActiveThreads"
],
"type": "field"
}
]
],
"tags": []
}
],
"thresholds": "",
"title": "Active Users",
"transparent": True,
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "None"
}
],
"valueName": "current"
},
{
"cacheTimeout": None,
"colorBackground": False,
"colorValue": False,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "ds_exe_id_4351",
"decimals": 1,
"editable": True,
"error": False,
"format": "ops",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": False,
"thresholdLabels": False,
"thresholdMarkers": True
},
"height": "120",
"id": 17,
"interval": None,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"NonePointMode": "connected",
"NoneText": None,
"postfix": "",
"postfixFontSize": "30%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "None",
"text": "N/A",
"to": "None"
}
],
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": False,
"lineColor": "rgb(31, 120, 193)",
"show": False
},
"targets": [
{
"dsType": "influxdb",
"groupBy": [],
"measurement": "virtualUsers",
"policy": "default",
"query": "SELECT count("responseTime")/$aggregation FROM "requestsRaw" WHERE $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"finishedThreads"
],
"type": "field"
}
]
],
"tags": []
}
],
"thresholds": "",
"title": "Overall Throughput",
"transparent": True,
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "None"
}
],
"valueName": "current"
},
{
"cacheTimeout": None,
"colorBackground": False,
"colorValue": False,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "ds_exe_id_4351",
"decimals": 1,
"editable": True,
"error": False,
"format": "percentunit",
"gauge": {
"maxValue": 1,
"minValue": None,
"show": True,
"thresholdLabels": False,
"thresholdMarkers": True
},
"height": "180",
"id": 18,
"interval": None,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"NonePointMode": "connected",
"NoneText": None,
"postfix": "",
"postfixFontSize": "30%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "None",
"text": "N/A",
"to": "None"
}
],
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": False,
"lineColor": "rgb(31, 120, 193)",
"show": False
},
"targets": [
{
"dsType": "influxdb",
"groupBy": [],
"measurement": "virtualUsers",
"policy": "default",
"query": "SELECT 1 - sum("errorCount")/count("responseTime") FROM "requestsRaw" WHERE $timeFilter",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"finishedThreads"
],
"type": "field"
}
]
],
"tags": []
}
],
"thresholds": "-1,-1",
"title": "Success Rate",
"transparent": True,
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "None"
}
],
"valueName": "current"
},
{
"cacheTimeout": None,
"colorBackground": False,
"colorValue": False,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "ds_exe_id_4351",
"decimals": 0,
"editable": True,
"error": False,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": False,
"thresholdLabels": False,
"thresholdMarkers": True
},
"height": "120",
"id": 20,
"interval": None,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"NonePointMode": "connected",
"NoneText": None,
"postfix": "",
"postfixFontSize": "30%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "None",
"text": "N/A",
"to": "None"
}
],
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": False,
"lineColor": "rgb(31, 120, 193)",
"show": False
},
"targets": [
{
"dsType": "influxdb",
"groupBy": [],
"measurement": "virtualUsers",
"policy": "default",
"query": "SELECT count("responseTime") FROM "requestsRaw" WHERE $timeFilter",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"finishedThreads"
],
"type": "field"
}
]
],
"tags": []
}
],
"thresholds": "",
"title": "Request Count",
"transparent": True,
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "None"
}
],
"valueName": "current"
},
{
"cacheTimeout": None,
"colorBackground": False,
"colorValue": False,
"colors": [
"rgb(109, 109, 109)",
"rgba(237, 129, 40, 0.89)",
"rgba(126, 0, 0, 0.9)"
],
"datasource": "ds_exe_id_4351",
"decimals": 2,
"editable": True,
"error": False,
"format": "percentunit",
"gauge": {
"maxValue": 1,
"minValue": None,
"show": True,
"thresholdLabels": False,
"thresholdMarkers": True
},
"height": "180",
"id": 21,
"interval": None,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"NonePointMode": "connected",
"NoneText": None,
"postfix": "",
"postfixFontSize": "30%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "None",
"text": "N/A",
"to": "None"
}
],
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": False,
"lineColor": "rgb(31, 120, 193)",
"show": False
},
"targets": [
{
"dsType": "influxdb",
"groupBy": [],
"measurement": "virtualUsers",
"policy": "default",
"query": "SELECT sum("errorCount")/count("responseTime") FROM "requestsRaw" WHERE $timeFilter",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"finishedThreads"
],
"type": "field"
}
]
],
"tags": []
}
],
"thresholds": "0.01,0.1",
"title": "Error Rate",
"transparent": True,
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "None"
}
],
"valueName": "current"
},
{
"aliasColors": {},
"bars": False,
"datasource": "ds_exe_id_4351",
"editable": True,
"error": False,
"fill": 1,
"grid": {},
"height": "300",
"id": 6,
"legend": {
"avg": False,
"current": False,
"max": False,
"min": False,
"show": True,
"total": False,
"values": False
},
"lines": True,
"linewidth": 1,
"links": [],
"NonePointMode": "None",
"percentage": False,
"pointradius": 5,
"points": False,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "Throughput",
"yaxis": 2
}
],
"span": 12,
"stack": False,
"steppedLine": False,
"targets": [
{
"alias": "Num Users",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"10s"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"hide": False,
"measurement": "virtualUsers",
"policy": "default",
"query": "SELECT mean("startedThreads") FROM "virtualUsers" WHERE $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"startedThreads"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
},
{
"alias": "Throughput",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"10s"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"hide": False,
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT count("responseTime")/$aggregation FROM "requestsRaw" WHERE $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"responseTime"
],
"type": "field"
},
{
"params": [],
"type": "count"
}
]
],
"tags": []
}
],
"thresholds": [],
"timeFrom": None,
"timeShift": None,
"title": "Load",
"tooltip": {
"msResolution": False,
"shared": True,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"name": None,
"show": True,
"values": []
},
"yaxes": [
{
"format": "short",
"label": None,
"logBase": 1,
"max": None,
"min": None,
"show": True
},
{
"format": "ops",
"label": "",
"logBase": 1,
"max": None,
"min": None,
"show": True
}
]
},
{
"columns": [],
"datasource": "ds_exe_id_4351",
"editable": True,
"error": False,
"fontSize": "80%",
"height": "300",
"id": 9,
"links": [],
"pageSize": 10,
"scroll": True,
"showHeader": True,
"sort": {
"col": 0,
"desc": True
},
"span": 12,
"styles": [
{
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "Time",
"type": "date"
},
{
"colorMode": "cell",
"colors": [
"rgba(0, 0, 0, 0)",
"rgba(183, 84, 26, 0.89)",
"rgba(245, 54, 54, 0.9)"
],
"decimals": 2,
"pattern": "Error Rate",
"thresholds": [
"0.00000001",
"0.01"
],
"type": "number",
"unit": "percentunit"
},
{
"colorMode": None,
"colors": [
"rgba(50, 172, 45, 0.97)",
"rgba(237, 129, 40, 0.89)",
"rgba(245, 54, 54, 0.9)"
],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 2,
"pattern": "/.*/",
"thresholds": [
"0.01",
"0.05"
],
"type": "number",
"unit": "short"
}
],
"targets": [
{
"alias": "",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$interval"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"hide": False,
"measurement": "requests",
"policy": "default",
"query": "SELECT count(responseTime) as Count, mean(responseTime) as Avg, min(responseTime) as Min, median(responseTime) as Median, percentile(responseTime, 90) as "90%",percentile(responseTime, 95) as "95%",percentile(responseTime, 99) as "99%", max(responseTime) as Max, (sum(errorCount)/count(responseTime)) as "Error Rate" FROM "requestsRaw" WHERE $timeFilter GROUP BY requestName",
"rawQuery": True,
"refId": "A",
"resultFormat": "table",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"title": "Metrics Overview",
"transform": "table",
"transparent": False,
"type": "table"
}
],
"showTitle": False,
"titleSize": "h3",
"height": 250,
"repeat": None,
"repeatRowId": None,
"repeatIteration": None,
"collapse": False
},
{
"title": "Selected Request - $request",
"panels": [
{
"content": "<h3 style="text-align: center;">The following panels show request-specific metrics for the request <span style="color: #00ccff;">"[[request]]"",
"editable": True,
"error": False,
"height": "110",
"id": 23,
"links": [],
"mode": "html",
"span": 12,
"title": "",
"transparent": True,
"type": "text"
},
{
"aliasColors": {},
"bars": False,
"datasource": "ds_exe_id_4351",
"editable": True,
"error": False,
"fill": 1,
"grid": {},
"height": "300px",
"id": 7,
"legend": {
"alignAsTable": True,
"avg": True,
"current": True,
"max": True,
"min": True,
"show": True,
"total": False,
"values": True
},
"lines": True,
"linewidth": 1,
"links": [],
"NonePointMode": "connected",
"percentage": False,
"pointradius": 5,
"points": False,
"renderer": "flot",
"seriesOverrides": [],
"span": 6,
"stack": False,
"steppedLine": False,
"targets": [
{
"alias": "Throughput",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"10s"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT count("responseTime")/$aggregation FROM "requestsRaw" WHERE "requestName" =~ /^$request$/ AND $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"responseTime"
],
"type": "field"
},
{
"params": [],
"type": "count"
}
]
],
"tags": [
{
"key": "requestName",
"operator": "=",
"value": "/^$request$/"
}
]
}
],
"thresholds": [],
"timeFrom": None,
"timeShift": None,
"title": "Throughput",
"tooltip": {
"msResolution": False,
"shared": True,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"name": None,
"show": True,
"values": []
},
"yaxes": [
{
"format": "ops",
"label": "",
"logBase": 1,
"max": None,
"min": None,
"show": True
},
{
"format": "short",
"label": None,
"logBase": 1,
"max": None,
"min": None,
"show": True
}
]
},
{
"cacheTimeout": None,
"colorBackground": False,
"colorValue": False,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(61, 165, 30, 0.97)"
],
"datasource": "ds_exe_id_4351",
"editable": True,
"error": False,
"format": "percentunit",
"gauge": {
"maxValue": 1,
"minValue": 0,
"show": True,
"thresholdLabels": False,
"thresholdMarkers": True
},
"height": "180",
"id": 12,
"interval": None,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"NonePointMode": "connected",
"NoneText": None,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "None",
"text": "N/A",
"to": "None"
}
],
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": False,
"lineColor": "rgb(31, 120, 193)",
"show": False
},
"targets": [
{
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$interval"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requests",
"policy": "default",
"query": "SELECT 1 - sum("errorCount")/count("responseTime") FROM "requestsRaw" WHERE $timeFilter AND "requestName" =
/^$request$/",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": "-1,-1",
"title": "Success Rate",
"transparent": True,
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "None"
}
],
"valueName": "current"
},
{
"cacheTimeout": None,
"colorBackground": False,
"colorValue": False,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(4, 106, 0, 0.97)"
],
"datasource": "ds_exe_id_4351",
"editable": True,
"error": False,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": False,
"thresholdLabels": False,
"thresholdMarkers": True
},
"height": "160",
"id": 3,
"interval": None,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"NonePointMode": "connected",
"NoneText": None,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "None",
"text": "N/A",
"to": "None"
}
],
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": False,
"lineColor": "rgb(31, 120, 193)",
"show": False
},
"targets": [
{
"dsType": "influxdb",
"groupBy": [],
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT count("responseTime") FROM "requestsRaw" WHERE "requestName" =~ /^$request$/ AND $timeFilter",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"responseTime"
],
"type": "field"
},
{
"params": [],
"type": "count"
}
]
],
"tags": [
{
"key": "requestName",
"operator": "=",
"value": "/^$request$/"
}
]
}
],
"thresholds": "",
"title": "Request Count",
"transparent": True,
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "None"
}
],
"valueName": "current"
},
{
"cacheTimeout": None,
"colorBackground": False,
"colorValue": False,
"colors": [
"rgb(100, 100, 100)",
"rgba(237, 129, 40, 0.89)",
"rgba(150, 20, 20, 0.9)"
],
"datasource": "ds_exe_id_4351",
"decimals": 2,
"editable": True,
"error": False,
"format": "percentunit",
"gauge": {
"maxValue": 1,
"minValue": 0,
"show": True,
"thresholdLabels": False,
"thresholdMarkers": True
},
"height": "180",
"id": 5,
"interval": None,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"NonePointMode": "connected",
"NoneText": None,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "None",
"text": "N/A",
"to": "None"
}
],
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": False,
"lineColor": "rgb(31, 120, 193)",
"show": False
},
"targets": [
{
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$interval"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requests",
"policy": "default",
"query": "SELECT sum("errorCount")/count("responseTime") FROM "requestsRaw" WHERE $timeFilter AND "requestName" =
/^$request$/",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"thresholds": "0.01,0.1",
"title": "Error Rate",
"transparent": True,
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "None"
}
],
"valueName": "current"
},
{
"content": "",
"editable": True,
"error": False,
"height": "110",
"id": 24,
"links": [],
"mode": "markdown",
"span": 6,
"title": "",
"transparent": True,
"type": "text"
},
{
"aliasColors": {
"95 perc": "#F9934E",
"99 perc": "#E24D42",
"Max": "#BF1B00"
},
"bars": False,
"datasource": "ds_exe_id_4351",
"editable": True,
"error": False,
"fill": 3,
"grid": {},
"height": "300",
"id": 1,
"legend": {
"alignAsTable": False,
"avg": False,
"current": False,
"max": False,
"min": False,
"show": True,
"total": False,
"values": False
},
"lines": True,
"linewidth": 1,
"links": [],
"NonePointMode": "None",
"percentage": False,
"pointradius": 5,
"points": False,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "Mean",
"zindex": 3
},
{
"alias": "90 perc",
"zindex": 2
},
{
"alias": "95 perc",
"zindex": 1
},
{
"alias": "99 perc",
"zindex": 0
},
{
"alias": "Max",
"zindex": -1
}
],
"span": 6,
"stack": False,
"steppedLine": False,
"targets": [
{
"alias": "Mean",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$aggregation"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT mean("responseTime") FROM "requestsRaw" WHERE "requestName" =~ /^$request$/ AND $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"responseTime"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": [
{
"key": "requestName",
"operator": "=",
"value": "/^$request$/"
}
]
},
{
"alias": "90 perc",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$aggregation"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT percentile("responseTime", 90) FROM "requestsRaw" WHERE "requestName" =
/^$request$/ AND $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"responseTime"
],
"type": "field"
},
{
"params": [
"90"
],
"type": "percentile"
}
]
],
"tags": [
{
"key": "requestName",
"operator": "=",
"value": "/^$request$/"
}
]
},
{
"alias": "95 perc",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$aggregation"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT percentile("responseTime", 95) FROM "requestsRaw" WHERE "requestName" =
/^$request$/ AND $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "D",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"responseTime"
],
"type": "field"
},
{
"params": [
95
],
"type": "percentile"
}
]
],
"tags": [
{
"key": "requestName",
"operator": "=",
"value": "/^$request$/"
}
]
},
{
"alias": "99 perc",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$aggregation"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT percentile("responseTime", 99) FROM "requestsRaw" WHERE "requestName" =
/^$request$/ AND $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "C",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"responseTime"
],
"type": "field"
},
{
"params": [
"99"
],
"type": "percentile"
}
]
],
"tags": [
{
"key": "requestName",
"operator": "=",
"value": "/^$request$/"
}
]
},
{
"alias": "Max",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$aggregation"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT max("responseTime") FROM "requestsRaw" WHERE "requestName" =
/^$request$/ AND $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "E",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"responseTime"
],
"type": "field"
},
{
"params": [],
"type": "max"
}
]
],
"tags": [
{
"key": "requestName",
"operator": "=",
"value": "/^$request$/"
}
]
}
],
"thresholds": [],
"timeFrom": None,
"timeShift": None,
"title": "Response Times",
"tooltip": {
"msResolution": True,
"shared": True,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"name": None,
"show": True,
"values": []
},
"yaxes": [
{
"format": "ms",
"label": None,
"logBase": 1,
"max": None,
"min": None,
"show": True
},
{
"format": "short",
"label": None,
"logBase": 1,
"max": None,
"min": None,
"show": True
}
]
},
{
"aliasColors": {},
"bars": False,
"datasource": "ds_exe_id_4351",
"editable": True,
"error": False,
"fill": 1,
"grid": {},
"height": "300",
"id": 11,
"legend": {
"alignAsTable": True,
"avg": True,
"current": True,
"max": True,
"min": True,
"show": True,
"total": False,
"values": True
},
"lines": True,
"linewidth": 2,
"links": [],
"NonePointMode": "connected",
"percentage": False,
"pointradius": 5,
"points": False,
"renderer": "flot",
"seriesOverrides": [],
"span": 6,
"stack": False,
"steppedLine": False,
"targets": [
{
"alias": "Errors per Second",
"dsType": "influxdb",
"groupBy": [
{
"params": [
"$aggregation"
],
"type": "time"
},
{
"params": [
"None"
],
"type": "fill"
}
],
"measurement": "requestsRaw",
"policy": "default",
"query": "SELECT sum("errorCount")/$aggregation FROM "requestsRaw" WHERE "requestName" =
/^$request$/ AND $timeFilter GROUP BY time([[aggregation]]s) fill(null)",
"rawQuery": True,
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"errorCount"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": [
{
"key": "requestName",
"operator": "=~",
"value": "/^$request$/"
}
]
}
],
"timeFrom": None,
"timeShift": None,
"title": "Error Rate",
"tooltip": {
"msResolution": False,
"shared": True,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"show": True,
"mode": "time",
"name": None,
"values": []
},
"yaxes": [
{
"format": "short",
"label": "errors / s",
"logBase": 1,
"max": None,
"min": "0",
"show": True
},
{
"format": "short",
"label": "",
"logBase": 1,
"max": None,
"min": None,
"show": True
}
],
"thresholds": []
}
],
"showTitle": False,
"titleSize": "h3",
"height": "250px",
"repeat": None,
"repeatRowId": None,
"repeatIteration": None,
"collapse": False
}
]
},
"folderId": 0,
"overwrite": False
}

ds_json={
    "name":"test_datasource",

"type":"influxdb",
"url":"http://10.66.170.42:8086",
"access":"proxy",
"basicAuth":False,
"password": "",
"user": "",
"database": "jmeter2",
"basicAuth": False,
"basicAuthUser": "basicuser",
"basicAuthPassword": "basicuser",
"isDefault": False
}
#rest_get("10.66.170.42:3000", "/org/apikeys")
#rest_get("10.66.170.42:3000","/api/datasources/1",auth_admin)
#rest_post("10.66.170.42:3000","/api/datasources",ds_json,auth_admin)
rest_post("10.66.170.42:3000","/api/dashboards/db",dashboard_json,auth_admin)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant