Skip to content

Service Discovery

Kavashen Pather edited this page Mar 15, 2019 · 4 revisions

Flex Auto Container Discovery

  • Flex has the capability to auto discovery containers in your surrounding environment, and dynamically monitor them regardless of changing IP addresses and ports
  • See flexContainerDiscovery/ for examples

Also note as an alternative in a Kubernetes environment, service environment variables are passed to every container, so your flex container will have access. Therefore you could even simply use environment variable substitution in a normal config file without using this container discovery feature. Environment variables can be passed into config files by simply using a double dollar sign eg. $$MY_ENVIRONMENT_VAR

Configuration

  -container_discovery
        Enable container auto discovery
  -container_discovery_dir string
        Set directory of auto discovery config files (default "flexContainerDiscovery/")
  -docker_api_version string
        Force Docker client API version

Flex Auto Container Discovery

  • Requires access to /var/run/docker.sock (same as the New Relic Infrastructure Agent, so it is convenient to bake flex into the newrelic/infrastructure image)
  • Add a label or annotation that contains the keyword - "flexDiscovery"
  • For Kubernetes add it as an environment variable
  • To that same label or annotation add a flex discovery configuration eg. "t=redis,c=redis,tt=img,tm=contains"
  • Complete example flexDiscoveryRedis="t=redis,c=redis,tt=img,tm=contains"
  • You could have varying configs on one container as well like flexDiscoveryRedis1, flexDiscoveryZookeeper etc.
  • Flex Container Discovery Configs are placed within "flexContainerDiscovery/" directory
  • For an example see "flexContainerDiscovery/redis.yml"
  • Use ${auto:host} and ${auto:port} anywhere in your config, this will dynamically be substituted per container discovered
  • This makes it possible to have multiple containers re-use the same config with different ip/port configurations

Flex Discovery Configuration Parameters

  • tt=targetType - are we targetting an img = image or cname = containerName? (default "img")
  • t=target - the keyword to target based on the targetType eg. "redis"
  • tm=targetMode - contains, prefix or regex to match the target (default "contains")
  • c=config - which config file will we use to create the dynamic configs from eg. "redis" .yml (defaults to the "target value")
  • p=port - force set a chosen target port
  • r=reverse - if set eg. reverse=true on nri-flex itself, it will perform a reverse lookup to match against containers (this means you don't have to set labels on individal containers)
  • ip=ipMode - default private can be set to public
  • If config is nil, use the target (t), as the yaml file to look up, eg. if target (t) = redis, lookup the config (c) redis.yml if config not set
Clone this wiki locally