Here you can learn how to build Flex from source, run it as a Docker image, or run it without the New Relic agent (development mode). Development mode is useful when developing and testing your config files.
- Flex outputs to the terminal/console, so you don't need to send the data to New Relic to see the results of running Flex against you config file.
- Flex runs everything by default in the
flexConfigs/
folder, next to the binary file. - Browse
examples/flexConfigs
for Flex configurations that you can reuse.
- Download the latest release for your development platform.
- Unpack the file.
- Run
./nri-flex -help
to see all available flags.
Flex looks for configuration files in a folder named flexConfigs
by default.
You can use the following flags to instruct Flex to read configuration files from somewhere else than the default folder:
config_dir
string
Specifies a directory of configurations filesconfig_file
(or-config_path
)string
Specifies a single config file
Running without any flags defaults to running all configs within ./flexConfigs
:
./nri-flex
To test a single Flex config file use -config_file
:
./nri-flex -config_file "examples/flexConfigs/redis-cmd-raw-example.yml"
For additional logging, use -verbose
:
./nri-flex -verbose
Once you've tested your configuration and you're ready to use in production, you can:
- Add your configuration to the integrations config file in
integrations.d
.orintegrations: # OHI configuration starts here - name: nri-flex # OHI to be executed by the Agent config: # OHI configuration to be parsed by Flex # Actual Flex configuration starts here
- Use
config_template_path
to reference your Flex configuration file from the integrations config file:integrations: - name: nri-flex interval: 60s timeout: 5s config_template_path: /path/to/flex/integration.yml
- Make
- Go 1.13 or higher
- dep - Dependency management tool (if not using
go mod
, which we advise you to use) - golangci-lint v1.22.2
- Docker Compose (for integration tests)
This assumes that you have a functional Go environment:
go get github.com/newrelic/nri-flex
cd ${GOPATH}/src/github.com/newrelic/nri-flex
# Ensure a clean start
make clean
# Download all required libraries
make dep
# Default command runs clean, linter, unit test, and compiles for the local OS
make
# run all tests + linter
make test
# run integration tests (requires docker-compose)
make test-integration
# run unit tests
make test-unit
# run only linter
make lint
# Create a coverage report
make cover
# Launch the coverage report into a web browser
make cover-view
# Build binary for current OS
make build
# Build binaries for all supported OSes
make build-all
# Build binaries for a specific OS
make build-darwin
make build-linux
make build-windows
To build tar.gz files for distribution:
# Create a package for the current OS
make package
# Create packages for all supported OSes
make package-all
# Create packages for a specific OS
make package-darwin
make package-linux
make package-windows
# clean/remove any docker containers that have been created
make docker-clean
# Build a new docker image
make docker-image
# Run via docker-compose
make docker-run
# Testing within docker
make docker-test
# Testing with the Infrastructure Agent within Docker
make docker-test-infra
# Use godocdown to create Markdown documentation for all commands and packages
# this is run by default.
make document
- Set your configs, modify Dockerfile if need be.
- Build and run the image.
# BUILD
docker build -t nri-flex .
# RUN - standard
docker run -d --name nri-flex --network=host --cap-add=SYS_PTRACE -v "/:/host:ro" -v "/var/run/docker.sock:/var/run/docker.sock" -e NRIA_LICENSE_KEY="yourInfraLicenseKey" nri-flex:latest
# RUN - with container discovery reverse lookup (ensure -container_discovery is set to true nri-flex-config.yml)
docker run -d --name nri-flex --network=host --cap-add=SYS_PTRACE -l flexDiscoveryRedis="t=redis,c=redis,tt=img,tm=contains,r=true" -v "/:/host:ro" -v "/var/run/docker.sock:/var/run/docker.sock" -e NRIA_LICENSE_KEY="yourInfraLicenseKey" nri-flex:latest
# Example: Run Redis with a flex discovery label
docker run -it -p 9696:6379 --label flexDiscoveryRedis="t=redis,c=redis,tt=img,tm=contains" --name redis-svr -d redis