npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

influxdb-timeshift-proxy

v0.0.8

Published

This proxy server will add *timeshift* feature to you *influxDB* server. This feature is extremely helpful to compare periods in *Grafana*.

Downloads

13

Readme

Timeshift influxDB proxy with Mathematics across measurements feature

This proxy server will add timeshift feature to you influxDB server. This feature is extremely helpful to compare periods in Grafana.

Proxy can to mathematical operations between queries (i.e. between metrics).

Installation

Node.js version 6 or later is required to run the code.

git clone https://github.com/maxsivanov/influxdb-timeshift-proxy.git
cd influxdb-timeshift-proxy
npm i
INFLUXDB=192.168.33.11:8086 npm run start

Proxy will be available on port 8089.

It is possible to use already proxied InfluxDB.

INFLUXDB=http://my.host.lan/api/datasources/proxy/19 npm run start

Proxying of Proxied :) feature is not very stable yet. Sometimes proxy will fail with HTTP 500. Waiting for this bug in express-http-proxy to fix. Anyway direct connection i.e INFLUXDB=192.168.33.11:8086 npm run start works fine.

Usage

Proxy will go timeshift on queries with fields listed with alias AS "shift_1_weeks". 1 can be any positive integer number. weeks can be any unit described here https://momentjs.com/docs/#/manipulating/add/.

You can use MATH query to do mathematical operation between previously defined queries.

Example of MATH query

  • name and expr attributes are mandatory.
  • You can use any mathematical operation in expr: +, -, *, /, %.
  • $0, $1 ... etc are indexes of query results to be used in expression.
  • Infinity and NaN results will be converted to null, so do not be afraid of division by zero.
  • MATH will clear returned values from query results used for mathematical operation. Use keep attribute to keep source data.
  • Use singlestat attribute if you want to use MATH in Singlestat panels.

Example of MATH query

Example requests

Shift one week back:

SELECT non_negative_derivative("value", 1h) AS "shift_1_weeks" FROM "CPU_LOAD" WHERE "tag" = 'all' 

Shift two days back:

SELECT non_negative_derivative("value", 1h) AS "shift_2_days" FROM "CPU_LOAD" WHERE "tag" = 'all' 

Sum two metrics and clear source metrics from result

MATH name="ALL" expr="$0 + $1"

Sum two metrics and keep source metrics in result

MATH name="ALL" expr="$0 + $1" keep="$0,$1"

Sum two metrics for singlestat panel

MATH name="ALL" expr="$0 + $1" singlestat

Debugging

Run proxy with DEBUG environment variable set:

  • query -- display all queries
  • rewrite -- display all query rewrites
  • math -- display all MATH calculations are made