Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/denisidoro/pipers

Use pipe expressions in your PromQL queries or code!
https://github.com/denisidoro/pipers

grafana pipe prometheus query

Last synced: 3 months ago
JSON representation

Use pipe expressions in your PromQL queries or code!

Awesome Lists containing this project

README

        

# Pipers

Use pipe expressions in your PromQL queries or code!

For example, the following query...
```coffee
sum(irate(node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}(node_cpu_seconds_total){mode='idle'}[5m](node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}(node_cpu_seconds_total)))) / count(count(node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}(node_cpu_seconds_total)) by (cpu))
```
...can be written as:
```coffee
cpuSeconds = node_cpu_seconds_total
| x -> x{instance=~"$node:$port",job=~"$job"}

cpuCount = cpuSeconds
| s -> count(s) by (cpu)
| count

cpuIdle = cpuSeconds
| s -> s{mode='idle'}[5m]
| irate
| sum

cpuIdle / cpuCount
```

## Syntax and live playground

Check [this page](https://denisidoro.github.io/pipers/) to try it out!

## Using it inside your IDE

### add the binary to your `$PATH`
```bash
git clone https://github.com/denisidoro/pipers
cargo build --release
```
### setup your IDE accordingly

E.g., in VSCode you can use the [Filter Text](https://marketplace.visualstudio.com/items?itemName=yhirose.FilterText) extension:

![Demo](https://user-images.githubusercontent.com/3226564/109806044-f9f08380-7c02-11eb-9429-92d26ee7084c.gif)