{"repo":"perses/promql-builder","free":true,"listed":false,"github":"https://github.com/perses/promql-builder","clone":"git clone https://github.com/perses/promql-builder.git","description":"A library to build PromQL expression in Golang.","language":"Go","stars":33,"topics":["prometheus","promql"],"license":"Apache-2.0","category":"analytics","readme_excerpt":"PromQL Builder ============== A library to build PromQL expression fully in Golang. Usage Create an instant vector To handle this use case, we are providing the package vector that proposes various options to create your instant vector. For example: It will give the following output: Create a range vector To handle this usecase, we are providing the package matrix that proposes various options to create your range vector. For example: It will give the following output: Note that as a duration we are using a variable. This is useful when you are using this library in a Dashboard As Code context, because likely the range duration will use the building variable coming with the dashboard tools like Grafana or Perses. Of course, you can define a proper range duration using the option WithRangeAsString : It will give the following output: Use PromQL function All functions, aggregations and binary operations are available at the root of this package promqlbuilder . For example, with the function rate : It will give the following output: Create your custom/non-standard PromQL function If you want to use a function that is not provided by this library, you can create your own function using the promqlbuilder.NewFunction function. For example, with a custom function my custom function : It will give the following output: Use aggregation function As you may know, all aggregation functions can be combined with the keywords by or without in order to specify on which labels you would like ","default_branch":null,"files":null,"tree":[],"storefront":"/r/perses","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/perses/promql-builder/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}