Giter Site home page Giter Site logo

metrics-relay's Introduction

metrics-relay

mypy

``You miss 100% of the shots you don't take.''
                  -- Wayne Gretzky
                     -- Michael Scott

Send your Neo4j metrics to the cloud!

Install

I recommend a virtual environment.

$ python3 -m venv venv
$ . venv/bin/activate
(venv) $ pip install -U pip
(venv) $ pip install -r requirements.txt

Configuring Neo4j

You need a Neo4j 5 Enterprise instance. (It may or may not work with v4.x.). Enable metrics and configure the graphite metrics support like so in neo4j.conf or the like:

server.metrics.graphite.enabled=true
server.metrics.graphite.server=${hostname:port}
server.metrics.graphite.interval=30s
server.metrics.graphite.prefix=${your_neo4j_instance_name}

Replacing the ${hostname:port} with the network info to reach your metrics-relay app and make sure to set ${your_neo4j_instance_name} to something identifable to distinguish the source of data.

NOTE: you may also want to set server.metrics.filter=* to unmask all metrics.

Running

Assumes you're running on a GCP VM or GKE container. (Maybe we add other clouds later.)

Simple, assuming you've activated your virtual environment:

$ python main.py

You have a few optional config options:

usage: metrics-relay [-h] [-d] [-s] [--host HOST] [--port PORT]

Sends Neo4j metrics to the Cloud

options:
  -h, --help   show this help message and exit
  -d, --debug  turn on debug logging
  -s, --simple  simplify logging output for journald
  --host HOST  hostname or ip to listen on
  --port PORT  tcp port to listen on

Running as a Service

First, either clone or download a release to a location of your choosing. The default is currently /usr/local/src/metrics-relay.

Make sure you've created a virtualenv and installed the dependencies as mentioned in the above [Install][#install] section.

Install the provided unit file and enable it at boot:

# cp metrics-relay.service /etc/systemd/system/
# systemctl enable metrics-relay.service

To start:

# systemctl start metrics-relay.service

The unit file is preconfigured to turn down the logging complexity so you can view the output using journalctl:

# journalctl -u metrics-relay.service

Metrics & You

The app should add labels to your metrics, including:

  • neo4j_label: the label you set in server.metrics.graphite.prefix
  • neo4j_system: the reporting subsystem (i.e. dbms, db)
  • neo4j_db_name: name of the database, if applicable
  • neo4j_instance_name: ip/hostname of the client reporting metrics

Hacking

Want to do me a favor and add another cloud platform? Take a look at relay/gcp.py. The API is still congealing, but in short you just need to implement an async function that looks like:

async def write_to_my_cloud(metrics: List[Neo4j5Metric]) -> None:
    pass

Async What Now?

Yeah, this uses Python's asyncio. Works shockingly well for this type of application once you get your head around the annoyances of async/await in Python land.

License & Copywrite

Unless otherwise noted, this project is (c) Neo4j, Inc and provided under the terms of the Apache License 2.0. No warranty or support.

metrics-relay's People

Contributors

voutilad 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.