Skip to content

Commit

Permalink
fix: reformatting query
Browse files Browse the repository at this point in the history
  • Loading branch information
Russ Savage committed Feb 16, 2021
1 parent 6310fc9 commit ba81890
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions influxdb2_oss_metrics/influxdb2_oss_metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,28 @@ spec:
kind: Xy
name: Memory Usage (%)
queries:
- query: "bytes_used = from(bucket: \"oss_metrics\")\n |> range(start:
v.timeRangeStart,stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement
== \"go_memstats_alloc_bytes\")\n |> filter(fn: (r) => r.host ==
v.oss_host)\n |> filter(fn: (r) => r._field == \"gauge\")\n |> drop(columns:[\"_start\",
\"_stop\"])\n \ntotal_bytes = from(bucket: \"oss_metrics\")\n |>
range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn:(r)
=> r._measurement == \"go_memstats_sys_bytes\")\n |> filter(fn: (r)
=> r.host == v.oss_host)\n |> filter(fn:(r) => r._field == \"gauge\")\n
\ |> drop(columns: [\"_start\", \"_stop\"])\n\njoin(tables:{key1:
bytes_used, key2: total_bytes}, on: [\"_time\", \"_field\"],method:
\"inner\")\n |> map(fn: (r) => ({\n _time: r._time,\n _value:
(float(v: r._value_key1) / float(v: r._value_key2)) *100.0,\n _field:
\"Memory Usage Percent\"\n }))\n |> yield(name:\"percentage\")"
- query: |-
bytes_used = from(bucket: "oss_metrics")
|> range(start:v.timeRangeStart,stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "go_memstats_alloc_bytes")
|> filter(fn: (r) => r.host == v.oss_host)
|> filter(fn: (r) => r._field == "gauge")
|> drop(columns:["_start","_stop"])
total_bytes = from(bucket: "oss_metrics")
|>range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn:(r)=> r._measurement == "go_memstats_sys_bytes")
|> filter(fn: (r)=> r.host == v.oss_host)
|> filter(fn:(r) => r._field == "gauge")
|> drop(columns: ["_start", "_stop"])
join(tables:{key1:bytes_used, key2: total_bytes}, on: ["_time", "_field"],method:"inner")
|> map(fn: (r) => ({
_time: r._time,
_value:(float(v: r._value_key1) / float(v: r._value_key2)) *100.0,
_field:"Memory Usage Percent"
}))
|> yield(name:"percentage")
width: 4
xCol: _time
xPos: 4
Expand Down

0 comments on commit ba81890

Please sign in to comment.