Git Product home page Git Product logo

prometheus's Introduction

git clone https://github.com/alkorolyov/prometheus; cd prometheus; sudo bash ./install.sh

./node_exporter --collector.disable-defaults --collector.cpu --collector.diskstats --collector.filesystem --collector.netdev --collector.meminfo --collector.mdadm --collector.textfile --collector.textfile.direc
tory .

custom prometheus metrics

prometheus.yml

# my global config
global:
  scrape_interval: 1s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 1s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
#  - job_name: "prometheus"
#    static_configs:
#      - targets: ["localhost:9090"]

  - job_name: "node_exporter"
    static_configs:
      - targets: ["localhost:9100"]

    metric_relabel_configs:
      - source_labels: [__name__]
        action: keep
        regex: 'node_cpu_seconds_total|node_memory_MemAvailable_bytes|node_memory_MemTotal_bytes|node_network_receive_bytes_total|node_network_transmit_bytes_total|node_disk_read_bytes_total|node_disk_written_bytes_total|node_filesystem_size_bytes'

rules.yml

groups:
  - name: custom_metrics
    rules:
      # CPU usage percentage
      - record: node_cpu_usage_percentage
        expr: |
          (100 * sum(irate(node_cpu_seconds_total {mode!="idle"} [1m])) by (instance)) /
          sum(irate(node_cpu_seconds_total[1m])) by (instance)

      # Memory Usage Percentage
      - record: node_memory_usage_percentage
        expr: |
          100 * (1 - (sum by (instance) (node_memory_MemAvailable_bytes) / 
          sum by (instance) (node_memory_MemTotal_bytes)))

metrics to keep

node_cpu_seconds_total
node_memory_MemAvailable_bytes
node_memory_MemTotal_bytes
node_network_receive_bytes_total
node_network_transmit_bytes_total
node_disk_read_bytes_total
node_disk_written_bytes_total
node_filesystem_size_bytes

check all prometheus metrics

curl -s http://localhost:9090/api/v1/label/__name__/values

check specific metric

watch -n 1 curl -s 'http://localhost:9090/api/v1/query?query=node_cpu_usage_percent'

prometheus's People

Contributors

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