01 初识Prometheus -安装prometheus

Prometheus是一个开放性的监控解决方案,用户可以非常方便的安装和使用Prometheus并且能够非常方便的对其进行扩展。为了能够更加直观的了解Prometheus Server,接下来我们将在本地部署并运行一个Prometheus Server实例,通过Node Exporter采集当前主机的系统资源使用情况。 并通过Grafana创建一个简单的可视化仪表盘

 

下载 prometheus

https://prometheus.io/download/找到最新版本的Prometheus Sevrer软件包

我选择了 prometheus-2.27.1.linux-amd64.tar.gz

安装prometheus

>tar -xzf prometheus-2.27.1.linux-amd64.tar.gz
>mv prometheus-2.27.1.linux-amd64   prometheus-2.27.1
>cd prometheus-2.27.1 

解压后当前目录会包含默认的Prometheus配置文件promethes.yml: 

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

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_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=` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

Promtheus作为一个时间序列数据库,其采集的数据会以文件的形似存储在本地中,默认的存储路径为data/,因此我们需要先手动创建该目录:

> cd prometheus-2.27.1
> mkdir -p data

用户也可以通过参数--storage.tsdb.path="/xx/data11/"修改本地数据存储的路径 

启动 Promtheus
 

启动prometheus服务,其会默认加载当前路径下的prometheus.yaml文件

nohup  ./prometheus --storage.tsdb.path="/data/prometheus/prometheus-2.27.1/data/" &

访问Promtheus

http://ip :9090/graph

Promtheus 安全参考 https://blog.csdn.net/zhuchunyan_aijia/article/details/117997630

 

界面上遇到报错: 

Prometheus报 Warning: Error fetching server time: Detected 1518 seconds time difference between your browser and the server.

解决:同步一下 时间  https://blog.csdn.net/zhuchunyan_aijia/article/details/113844755

 

 

你可能感兴趣的:(prometheus)