apiVersion: influxdata.com/v2alpha1 kind: Task metadata: name: Http.POST Synthetic (POST) spec: every: 5m query: |- import "strings" import "csv" import "http" import "system" timeDiff = (t1, t2) => { return duration(v: uint(v: t2) - uint(v: t1)) } timeDiffNum = (t1, t2) => { return uint(v: t2) - uint(v: t1) } urlToPost = "http://www.duckduckgo.com" timeBeforeCall = system.time() responseCode = http.post(url: urlToPost, data: bytes(v: "influxdata")) timeAfterCall = system.time() responseTime = timeDiff(t1: timeBeforeCall, t2: timeAfterCall) responseTimeNum = timeDiffNum(t1: timeBeforeCall, t2: timeAfterCall) data = "#group,false,false,true,true,true,true,true,true #datatype,string,long,string,string,string,string,string,string #default,mean,,,,,,, ,result,table,service,response_code,time_before,time_after,response_time_duration,response_time_ns ,,0,http_post_ping,${string(v: responseCode)},${string(v: timeBeforeCall)},${string(v: timeAfterCall)},${string(v: responseTime)},${string(v: responseTimeNum)}" theTable = csv.from(csv: data) theTable |> map(fn: (r) => ({r with _time: now()})) |> map(fn: (r) => ({r with _measurement: "PingService", url: urlToPost, method: "POST"})) |> drop(columns: ["time_before", "time_after", "response_time_duration"]) |> to(bucket: "Pingpire", orgID: "039346c3777a1000", fieldFn: (r) => ({"responseCode": r.response_code, "responseTime": int(v: r.response_time_ns)})) --- apiVersion: influxdata.com/v2alpha1 kind: Task metadata: name: Monitor Docs Website spec: every: 1m query: |- import "strings" import "csv" import "experimental/http" import "system" differenceInNanosec = (earlierTime, laterTime) => { return uint(v: laterTime) - uint(v: earlierTime) } theURLtoMonitor = "https://v2.docs.influxdata.com/v2.0/" timeBeforeCall = system.time() response = http.get(url: theURLtoMonitor) timeAfterCall = system.time() responseTime = differenceInNanosec(earlierTime: timeBeforeCall, laterTime: timeAfterCall) data = "#group,false,false,true,true #datatype,string,long,string,string #default,mean,,, ,result,table,service,response_code ,,0,http_ping,${string(v: response.statusCode)}" csv.from(csv: data) |> map(fn: (r) => ({r with _time: now()})) |> map(fn: (r) => ({r with _measurement: "PingService", url: theURLtoMonitor, method: "GET"})) |> to(bucket: "Pingpire", orgID: "039346c3777a1000", fieldFn: (r) => ({"response_time_ms": uint(v: responseTime) / uint(v: 1000000) })) --- apiVersion: influxdata.com/v2alpha1 kind: Bucket metadata: name: Pingpire spec: {} --- apiVersion: influxdata.com/v2alpha1 kind: Dashboard metadata: name: Blog - Response Time Monitor spec: charts: - axes: - base: "10" name: x scale: linear - base: "10" name: y scale: linear colors: - hex: '#31C0F6' name: Nineteen Eighty Four type: scale - hex: '#A500A5' name: Nineteen Eighty Four type: scale - hex: '#FF7E27' name: Nineteen Eighty Four type: scale geom: line height: 8 kind: Xy name: V2 Docs Response Time position: overlaid queries: - query: |- from(bucket: "Pingpire") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "PingService") |> filter(fn: (r) => r._field == "responseTime") |> filter(fn: (r) => r.method == "GET") width: 12 xCol: _time yCol: _value description: "" --- apiVersion: influxdata.com/v2alpha1 kind: Dashboard metadata: name: Performance of Interesting Websites spec: charts: - axes: - base: "10" name: x scale: linear - base: "10" label: milliseconds name: y scale: linear colors: - hex: '#31C0F6' name: Nineteen Eighty Four type: scale - hex: '#A500A5' name: Nineteen Eighty Four type: scale - hex: '#FF7E27' name: Nineteen Eighty Four type: scale geom: line height: 5 kind: Xy name: Response Time (ms) queries: - query: |- from(bucket: "Pingpire") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "PingService") |> filter(fn: (r) => r._field == "responseTime") |> map(fn: (r) => ({ r with _value: r._value / 1000000 })) |> aggregateWindow(every: 1m, fn: mean) width: 12 xCol: _time yCol: _value - colors: - hex: '#513CC6' name: planet type: text decimalPlaces: 1 height: 3 kind: Single_Stat name: V2 Docs Response Time queries: - query: |- from(bucket: "Pingpire") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "PingService") |> filter(fn: (r) => r._field == "responseTime") |> filter(fn: (r) => r.url == "https://v2.docs.influxdata.com/v2.0/") |> map(fn: (r) => ({ r with _value: r._value / 1000000 })) |> mean() suffix: ms width: 6 yPos: 5 - colors: - hex: '#00C9FF' name: laser type: text - hex: '#00C9FF' name: laser type: text decimalPlaces: 1 height: 3 kind: Single_Stat name: Search Engine Response Time queries: - query: |- from(bucket: "Pingpire") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "PingService") |> filter(fn: (r) => r._field == "responseTime") |> filter(fn: (r) => r.url == "http://www.duckduckgo.com") |> map(fn: (r) => ({ r with _value: r._value / 1000000 })) |> mean() suffix: ms width: 6 xPos: 6 yPos: 5 description: ""