Giter Club home page Giter Club logo

prometheus-grafana's Introduction

Start a container with Prometheus

docker run \
    --name prometheus \
    -d \
    -v prometheus:/prometheus \
    -v $(pwd)/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
    -p 9090:9090 \
    prom/prometheus

Monitoring an Application with Prometheus

In this example we work with a node application, see on app folder.

Added a Gauge Metric

Can increase or decrease arbitrarily

const gauge = new promClient.Gauge({
    name: 'class_free_bytes',
    help: 'Example of gauge'
});

gauge.set(100*Math.random());

Added a Histogram Metric

Used to measure the distribution

const histogram = new promClient.Histogram({
    name: 'class_request_time_seconds',
    help: 'Time to response from API',
    buckets: [0.1, 0.2, 0.3, 0.4, 0.5],
});

histogram.observe(Math.random()); // Observe value in histogram

Added a Summary Metric

Used to measure the distribution with percentiles

const summary = new promClient.Summary({
    name: 'class_summary_request_time_seconds',
    help: 'Time to response from API',
    percentiles: [0.01, 0.1, 0.5, 0.9, 0.99] // percentiles 1%, 10%, 50%, 90%, 99%
});

summary.observe(time);

Links https://prometheus.io/docs/instrumenting/clientlibs/ https://github.com/siimon/prom-client#labels

Monitoring Servers with Prometheus

Install node_exporter on server for registrer metrics

version: '3.8'

services:
  node_exporter:
    image: quay.io/prometheus/node-exporter:latest
    container_name: node_exporter
    command:
      - '--path.rootfs=/host'
    network_mode: bridge
    restart: unless-stopped
    volumes:
      - '/:/host:ro,rslave'     
    ports:
      - 9100:9100

Add a new target on prometheus.yml

- job_name: server-001
  static_configs:
  - targets:
    - 3.87.217.36:9100    

Restart de container to update de configuration

docker container restart prometheus

Done! Now you can see the metrics on http://<IP_ADDRESS>:9100/metrics

Links https://prometheus.io/docs/instrumenting/exporters/

prometheus-grafana's People

Contributors

xcirel avatar

Watchers

 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.