Example Configuration
Baragon Service
Example Baragon Service Config
# Configuration for Baragon Service and the corresponding request worker and ui
#
# The `server` section is the `server` configuration for a dropwizard application.
# `logging` and other dropwizard configurations can also be used
server:
type: simple
applicationContextPath: /baragon/v2
connector:
type: http
port: 8080
zookeeper:
quorum: localhost:2181 # comma separated list of zookeeper host:port goes here
zkNamespace: baragon # name of the base zk node
sessionTimeoutMillis: 60000
connectTimeoutMillis: 5000
retryBaseSleepTimeMilliseconds: 1000
retryMaxTries: 3
# Auth configuration
auth:
key: test-key # This key must be provided as the authkey parameter on requests to Baragon Service
enabled: true # Will use the specified key for auth if set to true
uiWriteEnabled: true # Does this key allow edit access in BaragonUI
# Master auth key, can be used to create/destroy other auth keys
masterAuthKey: test-master-key
# Hostname, used in name during creation of leader latch
hostname: localhost
# Baragon request worker configuration, used for the worker process that executes requests
worker:
enabled: true # Determines if the worker should start for this instance of Baragon Service
intervalMs: 1000 # Interval between checks of the pending request queue
initialDelayMs: 0 # Initial delay before the first check of the pending request queue
# (Optional) Format for building requests to Baragon Agents. First %s is substituted with the value created using
# the value from the agent configs baseUrlTemplate, and the second %s is substituted with the request ID, generally
# you will not need to set this field
agentRequestUriFormat: "%s/request/%s"
# (Optional) Number of times to try and complete a successful request on an agent before failing the request
agentMaxAttempts: 5
# (Optional) Time to wait for a response from a Baragon Agent
agentRequestTimeoutMs: 60000
# (Optional) Configuration to purge old requests from zookeeper, defaults shown
history:
purgeOldRequests: false # Should we purge old requests
purgeOldRequestsAfterDays: 7 # delete requests older than this many days
purgeWhenDateNotFound: false # if we can't determine when a request was last updated, should we delete it
purgeEveryHours: 24 # how often to run the purger
# (Optional) Elb Sync configuration
elb:
enabled: false # Determines if the ELB sync worker should start, defaults to false
awsAccessKeyId: somekey # AWS credentials for accessing ELB api
awsAccessKeySecret: somesecret # AWS credentials for accessing ELB api
intervalSeconds: 120 # How oftent he sync worker should run, defaults to 120s
initialDelaySeconds: 0 # How long to wait before starting ELB sync worker, defaults to 0
deregisterEnabled: false # Is the sync worker allowed to remove instances from the elb, defaults to false
removeKnownAgentEnabled: false # Is the sync worker allowed to remove an instance from the ELB if it is still in the known agents list, defaults to false
removeKnownAgentMinutes: 30 # How long must an instance be inactive before it can be removed
removeLastHealthyEnabled: false # If there is only one healthy instance left, can the sync worker remove it, defaults to false
# (Optional) HTTP client configuration, used by Baragon Service to comunicate with Baragon Agents
httpClient:
maxRequestRetry: 5 # (Optional) Defaults to 5
requestTimeoutInMs: 10000 # (Optional) Defaults to 10000
connectionTimeoutInMs: 5000 # (Optional) Defaults to 5000
userAgent: "Baragon/0.1 (+https://github.com/HubSpot/Baragon)" # (Optional) defaults to "Baragon/0.1 (+https://github.com/HubSpot/Baragon)"
# (Optional) Baragon UI configuration
ui:
title: Baragon # Shown in ui nav bar
navColor: null
baseUrl: null # Different url to host the ui, otherwise the ui will be rechable at /[contextPath]/ui
allowEdit: false # Allow the ui to run in edit mode (user can trigger requests and make changes), defaults to false (read-only)
allowEditKey: test-ui-key # A separate key to enable edit mode in an otherwiser read-only ui (can also be accomplished using an auth key with uiWriteEnabled set to true)
# (Optional) enable a cors filter for this host, defaults to false
enableCorsFilter: false
Baragon Agent
Example Baragon Agent Config
# Configuration for Baragon Agent instances running on each load balancer
#
# Example configuration for use with nginx is shown
#
# The `server` section is the `server` configuration for a dropwizard application.
# `logging` and other dropwizard configurations can also be used
server:
type: simple
applicationContextPath: /baragon-agent/v2
connector:
type: http
port: 8882
zookeeper:
quorum: localhost:2181 # comma separated list of ZK host:port goes here
zkNamespace: baragon # name of the base zk node
sessionTimeoutMillis: 60000
connectTimeoutMillis: 5000
retryBaseSleepTimeMilliseconds: 1000
retryMaxTries: 3
loadBalancerConfig:
name: loadBalancerGroupName # load balancer group name
rootPath: /etc/nginx/conf.d # base path for writing load balancer configs goes here
checkConfigCommand: "nginx -t" # command for checking configs goes here
reloadConfigCommand: "service nginx reload" # command for reloading configs goes here
# Auth configuration
auth:
enabled: true
# Host on which this agent is running, will be used to build the baseUrl
hostname: localhost
# (Optional) used to define the base url that Baragon Service will use to contact the Agent
baseUrlTemplate: "http://%s:%d%s"
# (Optional) amount of time to block other requests to this agent while an initial request is being processed
agentLockTimeoutMs: 5000
# (Optional) used in the formatTimestamp handlebars helper
defaultDateFormat: "yyyy-MM-dd hh:mm a"
# (Optional) enable a cors filter for this host, defaults to false
enableCorsFilter: false
# (Optional) set the heartbeat/agent-check-in interval for updating knownAgents metadata, default is 15
heartbeatIntervalSeconds: 15
# (Optional) Testing configuration
testing:
enabled: false
applyDelayMs: 0 # delay the processing of apply requests
applyFailRate: 0 # Cause more failures during the application of a request
revertDelayMs: 0 # Delay the processing of revert requests
revertFailRate: 0 # Cause more failures during the processing of a revert request
# Templates used to render load balancer configuration files
templates:
# File to render, the file will be written to `loadBalancerConfig.rootPath`/`filename` with %s replaced by the serivce ID
- filename: "proxy/%s.conf"
# Handlebars template used for this file, this template will be the default for all requests if no template name is specified
# All variables from the BaragonService object will be available here,
# this includes any custom `options` fields sent in the BAragonRequest
#
# The template below is an example used to proxy requests for a service at a particular path (serviceBasePath) on this
# load balancer to one of the defined upstreams
template: |
# This configuration is automatically generated by Baragon, local changes may be lost!
#
# Service ID: {{{service.serviceId}}}
# Service base path: {{{service.serviceBasePath}}}
#
# Service owner(s):
{{#each service.owners}}
# - {{{.}}}
{{else}}# (no owners defined)
{{/each}}#
{{#if upstreams}}
{{#if service.options.nginxExtraConfigs}}
# BEGIN CUSTOM NGINX CONFIGS
{{#each service.options.nginxExtraConfigs}}{{{.}}}
{{/each}}
# END CUSTOM NGINX CONFIGS
{{/if}}
location {{{service.options.nginxLocationModifier}}} {{{service.serviceBasePath}}} {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Request-Start "${msec}";
{{#if service.options.nginxProxyPassOverride}}
proxy_pass http://{{{service.options.nginxProxyPassOverride}}};
{{else}}
proxy_pass http://baragon_{{{service.serviceId}}};
{{/if}}
proxy_connect_timeout {{firstOf service.options.nginxProxyConnectTimeout 55}};
proxy_read_timeout {{firstOf service.options.nginxProxyReadTimeout 60}};
{{#if service.options.nginxExtraLocationConfigs}}
# BEGIN CUSTOM NGINX LOCATION CONFIGS
{{#each service.options.nginxExtraLocationConfigs}}{{{.}}}
{{/each}}
# END CUSTOM NGINX LOCATION CONFIGS
{{/if}}
}
{{else}}
#
# Service has no defined upstreams -- delete service from Baragon if not needed
#
location {{{service.options.nginxLocationModifier}}} {{{service.serviceBasePath}}} {
return 503;
}
{{/if}}
# Additional templates for this file path can also be specified and given a name. To render an alternate template for a request
# include the `templateName` field in your BaragonRequest
#
# The example below shows a template named `custom` which will write each line of the config defined in the `proxyConfig`
# section of the BaragonRequest options to the nginx config file
#
# Named templates will be written to the file path under when they are defined
namedTemplates:
custom: |
# This configuration is automatically generated by Baragon, local changes may be lost!
# Service ID: {{{service.serviceId}}}
# Service base path: {{{service.serviceBasePath}}}
# Template: loadbalancer
# Owners:
{{#each service.owners}}
# - {{{.}}}
{{else}}
# No owners!
{{/each}}
# This is a blank template for writing custom configuration
# BEGIN CUSTOM PROXY CONFIG
{{#each service.options.proxyConfig}}{{{.}}}
{{/each}}
# END CUSTOM PROXY CONFIG
# Multiple filenames to render for each request can be specified. While the file defined above writes the proxy config,
# this additional file will define the upstreams
- filename: "upstreams/%s.conf"
template: |
# This configuration is automatically generated by Baragon, local changes may be lost!
#
# Service ID: {{{service.serviceId}}}
# Service base path: {{{service.serviceBasePath}}}
#
# Service owner(s):
{{#each service.owners}}# - {{{.}}}
{{else}}# (no owners defined)
{{/each}}#
{{#if upstreams}}
upstream baragon_{{{service.serviceId}}} {
{{#each upstreams}}server {{{upstream}}}; # {{{requestId}}}
{{/each}}
{{#if service.options.nginxExtraUpstreamConfigs}}
# BEGIN CUSTOM NGINX UPSTREAM CONFIGS
{{#each service.options.nginxExtraUpstreamConfigs}}{{{.}}}
{{/each}}
# END CUSTOM NGINX UPSTREAM CONFIGS
{{/if}}
}
{{else}}
#
# Service is disabled due to no defined upstreams!
# It's safe to delete this file if not needed.
#
{{/if}}