Giter Club home page Giter Club logo

metrix's Introduction

Table of Contents

What is this project about?

This is a Golang REST API server (and client) able to collect Server metrics about Memory and Cpu usage for each process or as a total, and then generate analytics results, like average report and others. It is Kubernetes/Docker compatible and able to scale through Kubernetes Deployment/Pods

Prerequisites

Minikube deployed

run the following commands to unset http proxy and setup the minikube context

unset http_proxy
unset https_proxy
kubectl config use-context minikube
eval $(minikube docker-env)

Install and Deploy

Clone repository

git clone https://github.com/zilard/metrix.git

Run CI/CD

cd metrix
make deploy

CI/CD will:

  • cleanup previous build results and Kubernetes deployment
  • build the source of both "metrix" REST API server and "mx" REST API client
  • run the Golden tests
  • create Docker image for "metrix" REST API server
  • create a Kubernetes deployment for the "metrix" REST API server and expose it through a NodePort service

metrix Server Usage

Start the server

Listening on default port: 8080

./build/metrix/metrix        

OR

Listening on specified port:

./build/metrix/metrix -p <PORT>

You don't need to run the server separately in case you executed "make deploy" "make deploy" will deploy the server in a kubernetes deployment, and expose it through a NodePort service

You can check the local server port on which the NodePort service exposed the "metrix" REST API server with

kubectl get svc
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP          2d22h
metrix       NodePort    10.107.231.48   <none>        8080:30094/TCP   15s

In this case this is PORT 30094

mx API Client Usage

Send metrics using the mx API client:

./build/bin/mx send nm -i 192.168.39.210 -o 32202 -n node3 -t 100 -c 67 -m 80

URL: http://192.168.39.210:32202/v1/metrics/node/node2/

NODE MEASUREMENT SENT: 

{
  "timeslice": 360,
  "cpu": 45,
  "mem": 70
}

Get analytics using the mx API client:

./build/bin/mx get na -i 192.168.39.210 -o 32202

URL: http://192.168.39.210:32202/v1/analytics/nodes/average?timeslice=60.000000

NODE ANALYTICS: 

{
  "timeslice": 60,
  "cpu_used": 45,
  "mem_used": 70
}

If no IP address is specified through "-i" flag and/or no port is specified through "-o" flag then the mx API Client will use 127.0.0.1 as IP address and default port 8080

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.