Code Monkey home page Code Monkey logo

nri-flex's Introduction

New Relic - Flex

Build Status

  • Flex is an agnostic AIO New Relic Integration, that can:
    • Abstract the need for end users to write any code other then to define a configuration yml, allowing you to consume metrics from practically anywhere!
    • Run any HTTP/S request, read file, shell command, consume from any Prometheus Exporter, Database Query, or JMX Query (Java 7+ is required for JMX to work).
    • Can generate New Relic metric samples automatically from almost any endpoint for almost any payload, useful helper functions exist to tidy up your output neatly.
    • Simplies deployment and configuration as a single Flex integration can be running multiple integrations which would be just config files.
    • Provides over 200+ Integrations
    • Has agnostic Service / Container Discovery built-in,
    • Flex's Service Discovery is tidy, it avoids the need of applying annotations, labels or additional configs against your existing deployments!
    • Runs on Linux & Windows Hosts and Kubernetes, ECS, Fargate, and other container based platforms.
    • As updates and upgrades are made, all Flex Integrations reap the benefits.
    • Can send data via the New Relic Infrastructure Agent, or the New Relic Insights Event API,

Requirements

  • Linux
  • Windows
  • New Relic Infrastructure

Usage

Visualizing & Managing with the Flex Manager UI

Further Documentation


Installation

  • Setup your configuration(s) see inside examples/flexConfigs for examples
  • Flex will run everything by default in the default flexConfigs/ folder (so keep what you want before deploy)
  • Flex provides two options for ingesting your events, via the New Relic Infrastructure Agent, & the New Relic Insights Event API

New Relic Infrastructure Agent Install

Installs Flex on Linux with defaults and without any Flex Configs

sudo bash -c "$(curl -L https://newrelic-flex.s3-ap-southeast-2.amazonaws.com/install_linux_s3.sh)"

# Unpacked in /tmp/nri-flex-linux-$VERSION/...

Standard Install

  • Compiled Releases
  • Review the commented out portions in the install_linux.sh and/or Dockerfile depending on your config setup
  • Run scripts/install_linux.sh or build the docker image
  • Alternatively use the scripts/install_linux.sh as a guide for setting up (or scripts/install_win.bat)

Standard Configuration

  • Default configuration looks for Flex config files in /flexConfigs.
  • Run ./nri-flex -help for all available flags.
  • Flex has an Event Limiter built in - the event_limit argument is available and there to ensure you don't spam heaps of events unknowingly, the default is 500 per execution/run, which can be dialled up if required.
The below two flags you could specific a single Flex Config, or another config directory.

-config_dir string
        Set directory of config files (default "flexConfigs/")
-config_file string
        Set a specific config file

With these flags, you could also define multiple instances with different configurations of Flex within "nri-flex-config.yml" 

Typical file/directory structure layout:

/etc/newrelic-infra/integrations.d/nri-flex-config.yml <- config 
(/examples/nri-flex-config.yml)

/var/db/newrelic-infra/custom-integrations/nri-flex-def-nix.yml <- definition 
(/examples/nri-flex-def-nix.yml)

/var/db/newrelic-infra/custom-integrations/nri-flex <- binary 
(compiled binary)

/var/db/newrelic-infra/custom-integrations/flexConfigs/ <- standard flexConfigs (refer to examples here: /examples/flexConfigs)

/var/db/newrelic-infra/custom-integrations/flexContainerDiscovery/ <- if using container discovery 
(refer to examples here: /examples/flexContainerDiscovery)

New Relic Insights Event API

  -insights_api_key string
        Set Insights API key - from link above
  -insights_url string
        Set Insights URL eg. "https://insights-collector.newrelic.com/v1/accounts/YOUR_ACCOUNT_ID/events"
  -insights_output bool
        Output the events generated to standard out true/false
  • Run ./nri-flex -help for all available options

Typical file/directory structure layout:

From any location:

nri-flex <- binary
# below folders in the same location as the binary unless you've specific a different location
flexConfigs/ <- folder
flexContainerDiscovery/ <- folder (v1 service discovery, see v2)

Serverless

Serverless README

Kubernetes

Testing

Testing a single config
./nri-flex -config_file "examples/flexConfigs/redis-cmd-raw-example.yml"

Running without any flags, will default to run all configs within ./flexConfigs
./nri-flex 

Additional Logging
./nri-flex -verbose

Development

Requirements

  • Make
  • Go 1.10 or later
  • dep - Dependency management tool
  • Docker Compose (Integration tests)

Setup

Note: 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

Build

# Default command runs clean, linter, unit test, and compiles for the local OS
make

# run all tests + linter
make test

# run integration tests
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

Cross-Compiling

# 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

Packaging

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

Docker Related

# 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

Other Utility Commands

# Use godocdown to create Markdown documentation for all commands and packages
# this is run by default.
make document

Releasing

The build process sets the package version based on the latest git tag. After all changes have been made for the lastest release, make a new tag with NO commits after, and then make package-all to create the artifacts.

This process should be automated someday.

Finally, upload the artifacts on Github to the tag release.

Contributing

  • Submit a pull request for review.
  • If it's a code change make sure you run "make test" to confirm it's all good.
  • Since Flex has a lot of moving parts, its best to write tests so all contributors don't impact each others work.

Docker

  • Set your configs, modify Dockerfile if need be
  • Build & Run Image
Example:

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

Features & Support

  • Run any HTTP/S request, read file, shell command, consume from any Prometheus Exporter, Database Query, or JMX Query. (Java 7+ is required for JMX to work)
  • Service / Container Discovery
  • Attempt to cleverly flatten to samples
  • Use environment variables anywhere within config files (eg. using double dollar signs -> $$MY_ENV_VAR)
  • Detect and flatten dimensional data from Prometheus style payloads (vector, matrix, targets supported)
  • Merge different samples and outputs together
  • Key Remover & Replacer
  • Metric Parser for RATE & DELTA support (has capability to auto set rates and deltas)
  • Define multiple APIs / commands or mix
  • event_type autoset or override
  • Define custom attributes (more granular control, compared to NR infra agent)
  • Command allows horizontal split (useful for table style data) (use only once per command set)
  • snake_case to CamelCase conversion
  • Percentage to Decimal conversion
  • ToLower conversion
  • SubParse functionality (see redis config for an example)
  • LookUp Store - save attributes from previously generated samples to use in requests later (see rabbit example)
  • LazyFlatten - for arrays
  • Inbuilt data caching - useful for processing samples at different points
  • +more here

Integrations

For all see within the examples directory as there are many more.

  • All Prometheus Exporters
  • Consul
  • Vault (shows merge functionality)
  • Bamboo
  • Teamcity
  • CircleCI
  • RabbitMQ (shows metric parser, and lookup store functionality)
  • Elasticsearch (shows inbuilt URL cache functionality)
  • Traefik
  • Kong
  • etcd (shows custom sample keys functionality)
  • Varnish
  • Redis (more metrics, multi instance support, multi db support) (shows snake to camel, perc to decimal, replace keys, rename keys & sub parse functionality)
  • Zookeeper
  • OpsGenie
  • VictorOps
  • PagerDuty (shows lazy_flatten functionality)
  • AlertOps (shows lazy_flatten functionality)
  • New Relic Alert Ingestion (provides similar output to nri-alerts-pipe)
  • New Relic App Status Health Ingestion (appSample to present your app health, language, and aggregated summary)
  • http/s testing & request performance via curl
  • Postgres Custom Querying
  • MySQL Custom Querying
  • MariaDB Custom Querying
  • Percona Server, Google CloudSQL or Sphinx (2.2.3+) Custom Querying
  • MS SQL Server Custom Querying
  • JMX via nrjmx // (nrjmx is targetted to work with Java 7+, see cassandra and tomcat examples)
  • cassandra - via jmx
  • tomcat - via jmx
  • bind9
  • df display disk & inode info (shows horizontal split functionality)

Disclaimer

New Relic has open-sourced this integration to enable monitoring of various technologies. This integration is provided AS-IS WITHOUT WARRANTY OR SUPPORT, although you can report issues and contribute to this integration via GitHub. Support for this integration is available with an Expert Services subscription.

nri-flex's People

Contributors

alijared avatar ayork22 avatar goldenplec avatar haihongren avatar heaje avatar jdezego avatar jkt628 avatar kav91 avatar prodjito avatar sschwartzman 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.