Coder Social home page Coder Social logo

vamp-gateway-agent's Introduction

Vamp Gateway Agent

HAProxy with configuration from ZooKeeper, etcd or Consul.

Build Status Download

HAProxy is a tcp/http load balancer, the purpose of this agent is to:

  • read the HAProxy configuration from ZooKeeper, etcd or Consul and reloads the HAProxy on each configuration change with as close to zero client request interruption as possible.
  • read the logs from HAProxy over socket and push them to Logstash over UDP.
  • handle and recover from ZooKeeper, etcd, Consul and Logstash outages without interrupting the haproxy process and client requests.

It is possible to specify a custom configuration (based on arguments configurationPath/configurationBasicFile). In that case any configuration read from KV store is appended to the content of custom configuration, stored as configurationPath/haproxy.cnf and used for the next HAProxy reload.

Usage

$ ./vamp-gateway-agent: -h
                                       
Usage of ./vamp-gateway-agent:
  -configurationBasicFile string
        Basic HAProxy configuration. (default "haproxy.basic.cfg")
  -configurationPath string
        HAProxy configuration path. (default "/usr/local/vamp/")
  -debug
        Switches on extra log statements.
  -help
        Print usage.
  -logo
        Show logo. (default true)
  -logstash string
          Logstash 'host:port' (UDP), if set to '' then sending logs is disabled. (default "127.0.0.1:10001")
  -retryTimeout int
        Default retry timeout in seconds. (default 5)
  -scriptPath
        HAProxy validation and reload script path. (default "/usr/local/vamp/")
  -storeConnection string
        Key-value store connection string.
  -storeKey string
        HAProxy configuration store key. (default "/vamp/gateways/haproxy/1.6")
  -storeType string
        zookeeper, consul or etcd.

Logstash example configuration:

input {
  udp {
    port => 10001
    type => haproxy
  }
}

filter {
  grok {
    match => ["message", "^.+?]: (?<metrics>{.*})$"]
    match => ["message", "^.*$"]
  }
  if [metrics] =~ /.+/ {
    json {
      source => "metrics"
    }
    if [t] =~ /.+/ {
      date {
        match => ["t", "dd/MMM/YYYY:HH:mm:ss.SSS"]
      }
    }
  }
}

output {
  elasticsearch {
    hosts => "elasticsearch:9200"
  }
  stdout {
    codec => rubydebug
  }
}

Note: Logstash configuration depends on HAProxy log configuration and that is not in the scope of the agent (HAProxy configuration is retrieved from ZooKeeper, etcd or Consul).

Building Binary

Using the build.sh script:

  ./build.sh --make

Alternatively:

  • go get github.com/tools/godep
  • godep restore
  • go install
  • CGO_ENABLED=0 go build -v -a -installsuffix cgo

Building Docker Images

$ ./build.sh -h

Usage of ./build.sh:

  -h|--help   Help.
  -l|--list   List built Docker images.
  -r|--remove Remove Docker image.
  -m|--make   Build the binary and copy it to the Docker directories.
  -b|--build  Build Docker image.
  -a|--all    Build all binaries, by default only linux:amd64.

Docker images after the build (e.g. ./build.sh -b):

  • magneticio/vamp-gateway-agent:0.9.1

Docker Image

Docker Hub Repo

docker run --net=host --restart=always magneticio/vamp-gateway-agent:0.9.1

vamp-gateway-agent's People

Contributors

dragoslav avatar

Watchers

 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.