This project adds a basic high availability and consistent hash layer to InfluxDB.
NOTE: influx-proxy must be built with Go 1.8+, don't implement udp.
We used InfluxDB Relay before, but it doesn't support some demands. We use grafana for visualizing time series data, so we need add datasource for grafana. We need change the datasource config when influxdb is down. We need transfer data across idc, but Relay doesn't support gzip. It's inconvenient to analyse data with connecting different influxdb. Therefore, we made InfluxDB Proxy. More details please visit https://github.com/shell909090/influx-proxy.
Forked from the above InfluxDB Proxy, after many improvements and optimizations, InfluxDB Proxy v1 has released, which no longer depends on python and redis, and supports more features.
Since the InfluxDB Proxy v1 version is limited by the KEYMAPS
configuration, we refactored InfluxDB Proxy v2 with high availability and consistent hash, which supports tools to rebalance, recovery, resync and clear.
- Support gzip.
- Support query.
- Support some cluster influxql.
- Filter some dangerous influxql.
- Transparent for client, like cluster for client.
- Cache data to file when write failed, then rewrite.
- Support database sharding with consistent hash.
- Support tools to rebalance, recovery, resync and clear.
- Load config file and no longer depend on python and redis.
- Support precision query parameter when writing data.
- Support influxdb-java, influxdb shell and grafana.
- Support authentication and https.
- Support health status query.
- Support database whitelist.
- Support version display.
- Golang >= 1.8
$ go get -u github.com/kali-brandwatch/influx-proxy
$ $GOPATH/bin/influx-proxy -config /path/to/proxy.json
$ # build current platform
$ make build
$ # build linux amd64
$ make linux
The architecture is fairly simple, one InfluxDB Proxy instance and two consistent hash circles with two InfluxDB instances respectively. The Proxy should point HTTP requests with db and measurement to the two circles and the four InfluxDB servers.
The setup should look like this:
┌──────────────────┐
│ writes & queries │
└──────────────────┘
│
▼
┌──────────────────┐
│ │
│ InfluxDB Proxy │
│ (only http) │
│ │
└──────────────────┘
│
▼
┌──────────────────┐
│ db,measurement │
│ consistent hash │
└──────────────────┘
| |
┌─┼──────────────┘
│ └────────────────┐
▼ ▼
Circle 1 Circle 2
┌────────────┐ ┌────────────┐
│ │ │ │
│ InfluxDB 1 │ │ InfluxDB 3 │
│ InfluxDB 2 │ │ InfluxDB 4 │
│ │ │ │
└────────────┘ └────────────┘
The configurations in proxy.json
are the following:
circles
: circle listname
: circle name,required
backends
: backend list belong to the circle,required
name
: backend name,required
url
: influxdb addr or other http backend which supports influxdb line protocol,required
username
: influxdb username, with encryption if proxy auth_secure is enabled, default isempty
which means no authpassword
: influxdb password, with encryption if proxy auth_secure is enabled, default isempty
which means no auth
listen_addr
: proxy listen addr, default is:7076
db_list
: database list permitted to access, default is[]
data_dir
: data dir to save .dat .rec, default isdata
mlog_dir
: log dir to save rebalance, recovery, resync or clear operation, default islog
hash_key
: backend key for consistent hash, including "idx", "name" or "url", default isidx
, once changed rebalance operation is necessaryvnode_size
: the size of virtual nodes for consistent hash, default is256
flush_size
: default is10000
, wait 10000 points writeflush_time
: default is1
, wait 1 second write whether point count has bigger than flush_size configcheck_interval
: default is1
, check backend active every 1 secondrewrite_interval
: default is10
, rewrite every 10 secondswrite_timeout
: default is10
, write timeout until 10 secondsidle_timeout
: default is10
, keep-alives wait time until 10 secondslog_enabled
: enable the logging of debug messages for troubleshooting, default isfalse
username
: proxy username, with encryption if auth_secure is enabled, default isempty
which means no authpassword
: proxy password, with encryption if auth_secure is enabled, default isempty
which means no authauth_secure
: secure auth with encryption, default isfalse
https_enabled
: enable https, default isfalse
https_cert
: the ssl certificate to use when https is enabledhttps_key
: use a separate private key location
The following commands are forbid.
ALTER
GRANT
REVOKE
KILL
SELECT INTO
Multiple queries
delimited by semicolon;
Only support match the following commands.
select from
show from
show measurements
show series
show field keys
show tag keys
show tag values
show retention policies
show stats
show databases
create database
drop database
delete from
drop series from
drop measurement
on clause
(thedb
parameter takes precedence when the parameter is set in/query
http endpoint)
MIT.