Giter Club home page Giter Club logo

influxdb-grafana-rp-proxy's Introduction

influxdb-grafana-rp-proxy

Auto select infuxdb 0.10 Retention Policy

Until influxdb fixes this and enables downsampling of data internally this workaround will do.

  • works only with Influx Auth disabled
  • have only tested it with tag based measurements (dotted series names need to be fixed)
  • selection of RP depends on "group by time()" of the query.
  • First part of a dotted series name should NOT be the same as existing RP name( Not OK: Series="5min.hosts.cpu" RP="5min")

Original code: @PaulKuiper influxdata/influxdb#2625 (comment)

Ubuntu 14.04 setup:

apt install python-regex python-bottle python-requests python-gevent

Prepare influxdb Database:

  1. Create Retencion Policy for every database.
ALTER RETENTION POLICY "default" ON "graphite" DURATION 12h REPLICATION 1 DEFAULT
CREATE RETENTION POLICY "10sec"  ON graphite DURATION 2h   REPLICATION 1
CREATE RETENTION POLICY "30sec"  ON graphite DURATION 6h   REPLICATION 1
CREATE RETENTION POLICY "1min"   ON graphite DURATION 24h  REPLICATION 1
CREATE RETENTION POLICY "5min"   ON graphite DURATION 48h  REPLICATION 1
CREATE RETENTION POLICY "30min"  ON graphite DURATION 7d   REPLICATION 1
CREATE RETENTION POLICY "1hour"  ON graphite DURATION 31d  REPLICATION 1
CREATE RETENTION POLICY "3hour"  ON graphite DURATION 93d  REPLICATION 1
CREATE RETENTION POLICY "12hour" ON graphite DURATION 370d REPLICATION 1
CREATE RETENTION POLICY "24hour" ON graphite DURATION inf  REPLICATION 1
  1. Create Continuous Queries
CREATE CONTINUOUS QUERY graphite_cq_10sec  ON graphite BEGIN SELECT mean(value) as value INTO graphite."10sec".:MEASUREMENT  FROM graphite."default"./.*/ GROUP BY time(10s), * END
CREATE CONTINUOUS QUERY graphite_cq_30sec  ON graphite BEGIN SELECT mean(value) as value INTO graphite."30sec".:MEASUREMENT  FROM graphite."default"./.*/ GROUP BY time(30s), * END
CREATE CONTINUOUS QUERY graphite_cq_1min   ON graphite BEGIN SELECT mean(value) as value INTO graphite."1min".:MEASUREMENT   FROM graphite."10sec"./.*/ GROUP BY time(1m), * END
CREATE CONTINUOUS QUERY graphite_cq_5min   ON graphite BEGIN SELECT mean(value) as value INTO graphite."5min".:MEASUREMENT   FROM graphite."30sec"./.*/ GROUP BY time(5m), * END
CREATE CONTINUOUS QUERY graphite_cq_30min  ON graphite BEGIN SELECT mean(value) as value INTO graphite."30min".:MEASUREMENT  FROM graphite."5min"./.*/ GROUP BY time(30m), * END
CREATE CONTINUOUS QUERY graphite_cq_1hour  ON graphite BEGIN SELECT mean(value) as value INTO graphite."1hour".:MEASUREMENT  FROM graphite."5min"./.*/ GROUP BY time(1h), * END
CREATE CONTINUOUS QUERY graphite_cq_3hour  ON graphite BEGIN SELECT mean(value) as value INTO graphite."3hour".:MEASUREMENT  FROM graphite."5min"./.*/ GROUP BY time(3h), * END
CREATE CONTINUOUS QUERY graphite_cq_12hour ON graphite BEGIN SELECT mean(value) as value INTO graphite."12hour".:MEASUREMENT FROM graphite."1hour"./.*/ GROUP BY time(12h), * END
CREATE CONTINUOUS QUERY graphite_cq_24hour ON graphite BEGIN SELECT mean(value) as value INTO graphite."24hour".:MEASUREMENT FROM graphite."1hour"./.*/ GROUP BY time(24h), * END
  1. Backfill historical data XX days.(only if needed)
SELECT mean(value) as value INTO graphite."10sec".:MEASUREMENT FROM graphite."default"./.*/ WHERE time > now() - XXd GROUP BY time(10s),*
SELECT mean(value) as value INTO graphite."30sec".:MEASUREMENT FROM graphite."default"./.*/ WHERE time > now() - XXd GROUP BY time(30s),*
SELECT mean(value) as value INTO graphite."1min".:MEASUREMENT FROM graphite."10sec"./.*/    WHERE time > now() - XXd GROUP BY time(1m),*
SELECT mean(value) as value INTO graphite."5min".:MEASUREMENT FROM graphite."30sec"./.*/    WHERE time > now() - XXd GROUP BY time(5m),*
SELECT mean(value) as value INTO graphite."30min".:MEASUREMENT FROM graphite."5min"./.*/    WHERE time > now() - XXd GROUP BY time(30m),*
SELECT mean(value) as value INTO graphite."1hour".:MEASUREMENT FROM graphite."5min"./.*/    WHERE time > now() - XXd GROUP BY time(1h),*
SELECT mean(value) as value INTO graphite."3hour".:MEASUREMENT FROM graphite."5min"./.*/    WHERE time > now() - XXd GROUP BY time(3h),*
SELECT mean(value) as value INTO graphite."12hour".:MEASUREMENT FROM graphite."1hour"./.*/  WHERE time > now() - XXd GROUP BY time(12h),*
SELECT mean(value) as value INTO graphite."24hour".:MEASUREMENT FROM graphite."1hour"./.*/  WHERE time > now() - XXd GROUP BY time(24h),*
  1. Edit config settings, and point Grafana DataSources to host:port defined here
CONFIG = {
    'influxdb_http':'http://localhost:8086',

    'bind_host': '0.0.0.0',
    'bind_port': '3004',

    ..
}

influxdb-grafana-rp-proxy's People

Contributors

lupul avatar tparker-p10 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.