首页   快速返回

prometheus使用入门     所属分类 prometheus
https://prometheus.io/docs/introduction/first_steps/


Prometheus is a monitoring platform that collects metrics from monitored targets by scraping metrics HTTP endpoints on these targets. 

通过 HTTP端点 抓取 收集监控指标
target 
This guide will show you to how to install, configure and monitor our first resource with Prometheus. 

You'll also download and install an exporter, tools that expose time series data on hosts and services. 

Our first exporter will be Prometheus itself, which provides a wide variety of host-level metrics about memory usage, garbage collection, and more.

自己的监控指标, 主机级别的指标 内存使用 GC等 

The Prometheus server is a single binary called prometheus


配置文件  prometheus.yml


global:
  scrape_interval:     15s
  evaluation_interval: 15s

rule_files:
  # - "first.rules"
  # - "second.rules"

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
      
      
global, rule_files, and scrape_configs.

scrape_interval   controls how often Prometheus will scrape targets
抓取间隔 频率

evaluation_interval
how often Prometheus will evaluate rules. 
uses rules to create new time series and to generate alerts.
使用规则创建新的时间序列并生成警报。



rule_files   
specifies the location of any rules

scrape_configs
Prometheus also exposes data about itself as an HTTP endpoint it can scrape and monitor its own health. 
In the default configuration there is a single job, called prometheus, which scrapes the time series data exposed by the Prometheus server. 

Prometheus expects metrics to be available on targets on a path of /metrics. 

http://localhost:9090/metrics


The time series data returned will detail the state and performance of the Prometheus server.

https://prometheus.io/docs/prometheus/latest/configuration/configuration/


cd /Users/dugang/soft/prometheus/prometheus-2.8.1.darwin-amd64

./prometheus --config.file=prometheus.yml


Prometheus server 自己的监控指标和 http 端点


内置的 expression browser


promhttp_metric_handler_requests_total


promhttp_metric_handler_requests_total{code="200"}

count(promhttp_metric_handler_requests_total)


https://prometheus.io/docs/prometheus/latest/querying/basics/

http://localhost:9090/graph
 
 
graph the per-second HTTP request rate returning status code 200 happening in the self-scraped Prometheus:

rate(promhttp_metric_handler_requests_total{code="200"}[1m])
graph 和 console 可互相切换


# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 42
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0




experiment with the graph range parameters and other settings.

监控其他目标
Monitoring Linux or macOS host metrics using a node exporter 
https://prometheus.io/docs/guides/node-exporter

上一篇     下一篇
prometheus概述

linux内核版本与系统版本查看以及x86与x86_64的区别

prometheus FAQ 要点整理

使用node-exporter监控主机信息

prometheus数据模型

java异常处理12条建议