MCPcopy Index your code
hub / github.com/Qihoo360/influx-proxy

github.com/Qihoo360/influx-proxy @v1.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.1 ↗ · + Follow
162 symbols 452 edges 23 files 29 documented · 18%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

InfluxDB Proxy

This project adds a basic high availability layer to InfluxDB.

NOTE: influx-proxy must be built with Go 1.7+, don't implement udp.

Why

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.

Features

  • Support gzip.
  • Support query.
  • Filter some dangerous influxql.
  • Transparent for client, like cluster for client.
  • Cache data to file when write failed, then rewrite.

Requirements

  • Golang >= 1.7

Usage

$ # Install influx-proxy to your $GOPATH/bin
$ go get -u github.com/wilhelmguo/influx-proxy/service
$ go install github.com/wilhelmguo/influx-proxy/service
$ mv $GOPATH/bin/service $GOPATH/bin/influx-proxy
$ # Start influx-proxy!
$ $GOPATH/bin/influx-proxy -config proxy.json

Description

The architecture is fairly simple, one InfluxDB Proxy process and two or more InfluxDB processes. The Proxy should point HTTP requests with measurements to the two InfluxDB servers.

The setup should look like this:

        ┌─────────────────┐
        │writes & queries │
        └─────────────────┘
                 │
                 ▼
         ┌───────────────┐
         │               │
         │InfluxDB Proxy │
         |  (only http)  |
         │               │
         └───────────────┘
                 │
                 ▼
        ┌─────────────────┐
        │   measurements  │
        └─────────────────┘
          |              |
        ┌─┼──────────────┘
        │ └──────────────┐
        ▼                ▼
  ┌──────────┐      ┌──────────┐
  │          │      │          │
  │ InfluxDB │      │ InfluxDB │
  │          │      │          │
  └──────────┘      └──────────┘

measurements match principle:

  • Exact match first. For instance, we use cpu.load for measurement's name. The KEYMAPS has cpu and cpu.load keys. It will use the cpu.load corresponding backends.

  • Then Prefix match. For instance, we use cpu.load for measurement's name. The KEYMAPS only has cpu key. It will use the cpu corresponding backends.

Query Commands

Unsupported commands

The following commands are forbid.

  • GRANT
  • REVOKE

Supported commands

Only support match the following commands.

  • .*from.*
  • drop measurement.*
  • show.*measurements

License

MIT.

Extension points exported contracts — how you extend this code

Querier (Interface)
(no doc) [3 implementers]
backend/interfaces.go
BackendAPI (Interface)
(no doc)
backend/interfaces.go

Core symbols most depended-on inside this repo

Write
called by 34
backend/interfaces.go
Close
called by 30
backend/interfaces.go
Query
called by 8
backend/interfaces.go
check
called by 6
influx-test/select.py
NewHttpBackend
called by 5
backend/http.go
IsActive
called by 5
backend/interfaces.go
fz
called by 5
influx-test/mytime.py
NewBackends
called by 4
backend/backends.go

Shape

Method 81
Function 62
Struct 16
Interface 2
Class 1

Languages

Go90%
Python10%

Modules by API surface

backend/cluster.go28 symbols
backend/http.go16 symbols
logs/logs.go13 symbols
influx-test/mytime.py11 symbols
backend/interfaces.go11 symbols
backend/http_test.go11 symbols
backend/backends.go11 symbols
backend/file.go9 symbols
backend/config.go8 symbols
service/http.go7 symbols
backend/jsonapi.go6 symbols
backend/cluster_test.go6 symbols

For agents

$ claude mcp add influx-proxy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page