首页 > 其他分享 >liunx下prometheus页面设置用户名密码登陆

liunx下prometheus页面设置用户名密码登陆

时间:2024-06-12 16:23:18浏览次数:15  
标签:页面设置 prometheus liunx password root yml 2.24 localhost

前言  前两天公司漏洞通报prometheus未设置鉴权,漏洞详情如下图所示。

 

操作前须知

Prometheus于2.24版本(包括2.24)之后提供Basic Auth功能进行加密访问,在浏览器登录UI的时候需要输入用户密码,访问Prometheus api的时候也需要加上用户密码

1、 安装依赖

yum -y install  epel-release python3 python3-bcrypt

2、通过python脚本生产密码

[root@localhost home]# cat python_passwd.py
import getpass
import bcrypt

password = getpass.getpass("password: ")
hashed_password = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt())
print(hashed_password.decode())

3、运行python脚本生成密码

[root@localhost home]# python3 ./python_passwd.py

password: 交互输入密码

4、prometheus配置文件

[root@localhost prometheus-2.24.0.linux-amd64]# pwd
/home/prometheus-2.24.0.linux-amd64

[root@localhost prometheus-2.24.0.linux-amd64]# cat webconfig.yml
basic_auth_users:
admin: $2b$12$ic7SmeIcedgf8whWBhsiIugN7m4ZXCm5Om73mMShJ..Yc1lFmzIcq   
#admin是账号:后面是密码 明文是:NGM1YTM^3YzUxZDdlM
[root@localhost prometheus-2.24.0.linux-amd64]# cat prometheus.yml | egrep -v '^#|^$'
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).
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
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: 'localhost'
static_configs:
- targets: ['localhost:9100']

5、检测webconfig.yml是否可用

[root@localhost prometheus-2.24.0.linux-amd64]# ./promtool check web-config webconfig.yml
webconfig.yml SUCCESS

6、启动 prometheus

nohup ./prometheus --web.config.file=web.yml &

7、访问链接提示输入账号密码

http://ip:9090

 8、服务正常

 

标签:页面设置,prometheus,liunx,password,root,yml,2.24,localhost
From: https://www.cnblogs.com/zhang-xiao-shuang/p/18244186

相关文章

  • 【30天精通Prometheus:一站式监控实战指南】第16天:snmp_exporter从入门到实战:安装、配
    亲爱的读者们......
  • 基于prometheus实现SQL监控方案
    需求描述业务上经常会出现这样的问题:客户反馈某个业务今天查不到数据。怎么通过监控提前发现呢?我们的业务场景是这样:在mysql中,每小时、每天,会通过定时任务汇总统计车辆在道路上的作业情况(作业时间、里程、平均速度等)。经常出现,某一个客户某一类型数据没算(表中没有新增数据)。......
  • prometheus表达式常用公式
    1._over_time()下面的函数列表允许传入一个区间向量,它们会聚合每个时间序列的范围,并返回一个瞬时向量avg_over_time(range-vector):区间向量内每个度量指标的平均值。min_over_time(range-vector):区间向量内每个度量指标的最小值。max_over_time(range-vector):......
  • 深入解读Prometheus Adapter:云原生监控的核心组件
    本文详述了PrometheusAdapter的部署与配置,通过三个实践案例展示其在Kubernetes环境中的应用,帮助用户实现基于自定义指标的自动扩展和跨集群统一监控。关注作者,分享AI全维度知识。作者拥有10+年互联网服务架构、AI产品研发经验、团队管理经验,同济本复旦硕,复旦机器人智能实验室......
  • .netCore System.Drawing.Common 发布,在CentOS 运行报错,生成图片流时。会因为不支持在
    报错:System.PlatformNotSupportedException:System.Drawing.Commonisnotsupportedonnon-Windowsplatforms.Seehttps://aka.ms/systemdrawingnonwindowsformoreinformation. >System.PlatformNotSupportedException:System.Drawing.Commonisnotsupported......
  • Spring Boot 开发 -- 集成 Prometheus 进行高效监控
    引言随着微服务架构的流行,对服务的监控和管理变得尤为重要。Prometheus作为一个开源的监控和告警工具,以其强大的数据采集、存储和查询能力,受到了众多开发者的青睐。SpringBoot作为Java领域快速构建微服务的框架,与Prometheus的结合可以实现对SpringBoot应用的实时监控。本......
  • 一分钟部署prometheus&grafana全方面监控SpringBoot项目
    0x01创建目录找一个你喜欢的地方,创建项目根目录example:[root@demo-78~]#mkdir/data/prometheus0x02创建配置文件进入到项目根目录:[root@demo-78~]#cd/data/prometheus需要新建三个文件,分别是docker-compose.yml、prometheus.yml、node_down.yml,详细配置如下......
  • 使用prometheus监测MySQL主从同步状态方案
    说明:本文介绍如何使用prometheus、alertmanager监测MySQL主从,当从节点中断同步时,发送邮箱报警,并使用grafana将数据视图化。结构图如下:安装(1)安装应用首先,来安装prometheus、alertmanager和grafana,参考以下文章(都是我写的,嘿嘿):CentOS7安装prometheusCentOS7安装aler......
  • Docker 部署 Prometheus 监控系统
    介绍在现代应用开发中,监控是确保应用系统稳定性和性能的关键一环。Prometheus是一款强大而灵活的开源监控和警报工具,本文将指导你通过Docker快速部署Prometheus监控系统。步骤安装Docker确保你的系统上已经安装了Docker。你可以根据​​Docker官方文档​​安装D......
  • LIUNX 安装 rabbitmq
    在Linux上安装RabbitMQ主要包括以下步骤。这里以Ubuntu为例,其他Linux发行版可能会有些许不同。1.更新软件包索引在开始之前,确保系统的软件包索引是最新的:sudoaptupdate2.安装ErlangRabbitMQ依赖Erlang运行时环境。可以通过以下命令安装:sudoaptinst......