0%

promethrus记录

记录一些关键问题点,不是部署文档,不是部署文档。

数据采集类型

  • counter

  • gauge

查询语法

函数使用

AlertManager

报警组件使用,

alertmanager 高可用

alertmanager 高可用模式 基于gossip机制同步告警状态,

nginx 反向代理

prometheus 官方推荐的登录验证方式为 basic auth 我们可以借助强大的nginx来实现。 把数据接口加上验证,这样监控数据就不会随意被内网的同事们看到了。。

basic auth 配置

使用htpasswd生成用户名密码

“””
htpasswd -c /usr/local/nginx/conf/.htpasswd user1
“””

nginx配置文件

“””

server {
    listen       8081;
    server_name  localhost;


    location / {
        auth_basic           "Prometheus";
        auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
        autoindex on;
        proxy_pass        http://127.0.0.1:6789/;
    }
...
}

“””

prometheus启动命令调整为

“””
/usr/local/prometheus/prometheus –config.file=/usr/local/prometheus/prometheus.yml –log.level=info –web.enable-admin-api –web.listen-address=127.0.0.1:6789
“””