# prometheus **Repository Path**: mostbrain/prometheus ## Basic Information - **Project Name**: prometheus - **Description**: prometheus安装 - **Primary Language**: Unknown - **License**: WTFPL - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-01-18 - **Last Updated**: 2024-02-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # [prometheus教程](https://prometheus.io/docs/introduction/overview/) #### [下载](https://prometheus.io/download/) #### 解压与安装 ```` export VERSION=2.49.0 tar -zxvf prometheus-$VERSION.linux-amd64.tar.gz -C ~/software ```` #### 上传promethes.yml文档到$PROMETHEUS_HOME ```` # promethes.yml内容 # my global config global: # 默认情况下,每15s拉取一次目标采样点数据。 scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. # 每15秒评估一次规则。默认值为每1分钟。 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: # job名称会增加到拉取到的所有采样点上,同时还有一个instance目标服务的host:port标签也会增加到采样点上 - job_name: 'prometheus' # 覆盖global的采样点,拉取时间间隔5s scrape_interval: 5s static_configs: - targets: ['localhost:9090'] - job_name: 'linux' static_configs: - targets: ['localhost:9100'] # 多个用,分开 ```` #### 执行启动命令 ```` export PROMETHEUS_HOME=~/software/prometheus-$VERSION.linux-amd64 cd $PROMETHEUS_HOME ./prometheus --config.file=prometheus.yml ```` #### prometheus脚本部分参数说明 ```` # 指定配置文件 --config.file="prometheus.yml" # 默认指定监听地址端口,可修改端口 --web.listen-address="0.0.0.0:9090" # 最大连接数 --web.max-connections=512 # tsdb数据存储的目录,默认当前data/ --storage.tsdb.path="data/" # premetheus 存储数据的时间,默认保存15天 --storage.tsdb.retention=15d # 通过命令热加载无需重启 curl -XPOST 192.168.2.45:9090/-/reload --web.enable-lifecycle # 可以启用 TLS 或 身份验证 的配置文件的路径 --web.config.file="" 启动选项了解: ./prometheus --help ```` #### 配置开机自启(root) ```` vim /etc/rc.local ```` 写入 ```` export VERSION=2.49.0 export PROMETHEUS_HOME=~/software/prometheus-$VERSION.linux-amd64 su admin -c "cd $PROMETHEUS_HOME; nohup ./prometheus --config.file=prometheus.yml >>/dev/null &" ```` # [node_exporter教程](node_exporter.md) # [grafana教程](grafana.md)