当前位置:网站首页>prometheus-basic_auth加密配置
prometheus-basic_auth加密配置
2022-07-30 05:49:00 【大新新大浩浩】
文章目录
前言
记录一下prometheus-basic_auth加密的开启
一、basic_auth加密的引入
平常使用prom都是没有加密的安全措施的,有一些节点直接暴漏在公网上了,不安全。现在使用basic_auth加密,可以加个密码,安全一些。
二、使用步骤
1.生成basic_auth密钥
安装工具包并生成加密后密码
#安装工具包
yum install -y httpd-tools
#生成加密密码
htpasswd -nBC 12 '' | tr -d ':\n'
New password: # 这里设置密码为123456,实际使用请按照自己的集群需求定义密码
Re-type new password:
#生成的密码信息
$2y$12$mMnPuKlOQ97ff4NjDsQTMukAtRS/ILpjxjEQrCN0vefs0CBLe/hi6
2.将密钥文件写入config.yml文件内
准备配置文件
cat > ./config.yml<<eof
basic_auth_users:
# 当前设置的用户名为admin, 可以设置多个
admin: $2y$12$mMnPuKlOQ97ff4NjDsQTMukAtRS/ILpjxjEQrCN0vefs0CBLe/hi6
3.查看prometheus相关参数
查看prometheus配置项
prometheus --help
--web.config.file="" [EXPERIMENTAL] Path to configuration file that can enable TLS or authentication.
在运行时增加- -web.config.file配置即可启用加密
4.修改prometheus配置
修改配置,增加basic_auth配置
scrape_configs:
- job_name: 'prometheus'
basic_auth:
username: admin
password: 123456
static_configs:
- targets: ['prometheus:9090']
5.启动服务
5.1 service模式
修改/usr/lib/systemd/system/prometheus.service文件,在ExecStart后面追加–web.config.file=/xx/xx/xx/config.yml
例:
cat /usr/lib/systemd/system/prometheus.service
[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --web.config.file=/usr/local/prometheus/config.yml
[Install]
WantedBy=multi-user.target
5.2 docker模式
修改镜像,在服务启动脚本命令内增加–web.config.file配置,
例:
CMD [ "--config.file=/etc/prometheus/prometheus.yml", \
"--storage.tsdb.path=/prometheus", \
"--web.console.libraries=/usr/share/prometheus/console_libraries", \
"--web.console.templates=/usr/share/prometheus/consoles", \
"--web.config.file=/etc/prometheus/config.yml" ]
镜像制作完毕之后,在启动容器时,将config.yml传递到/etc/prometheus/config.yml位置即可
prometheus:
image: prometheus:1
volumes:
- type: bind
source: ./xxx/xxx/config.yml
target: /etc/prometheus/config.yml
read_only: true
六.访问测试

测试正常
总结
basic_auth能起到简单的保护作用,比使用tls密钥使用更方便,在一些特定场景有奇效
参考
二、Prometheus TLS加密认证和基于 basic_auth 用户名密码访问:link
边栏推荐
猜你喜欢

GNNLab: A Novel GNN System Based on Spatial Sharing Ideas

基于STM32F103的消防系统之驱动电机风扇

PC DBCO-PEG3-Biotin|PC-生物素-PEG3-DBCO可用于使用无铜点击化学

多线程进阶(锁策略,自旋+CAS,Synchronized,JUC,信号量)

how to use xilinx's FFT ip

Biotin-Dadps-azide|CAS:1260247-50-4|生物素-DADPS-叠氮

DADPS Biotin Azide( CAS:1260247-50-4生物素基团和叠氮基团的 PEG 衍生物

Biotin-NHS LC(72040-63-2)生物素接头|站点特定探针

IO进程线程->标准IO->day1

04-packing and unpacking
随机推荐
图计算在网络安全分析中的应用
Unity Shader 空间坐标系
Cas 80750-24-9,去硫代生物素 N-羟基琥珀酰亚胺,淡黄色固体
02-Use of Cycript
从 Vertex 到 Subgraph 再到 PIE: 并行图计算编程模型概览
Desthiobiotin-PEG4-Acid|脱硫生物素-PEG4-酸| 供应商和制造商
From installation to compilation: 10 minutes to teach you to use and develop GraphScope locally
Biotin-NHS LC(72040-63-2)生物素接头|站点特定探针
测试开发工程师成长日记015 - 最强20道测试面试题
Selenium01
彻底删除openstack中镜像的记录
图扑数字孪生煤矿开采系统,打造采煤“硬实力”
GadgetInspector principle analysis
Test Development Engineer Growth Diary 008 - Talking About Some Bugs/Use Case Management Platform/Collaboration Platform
PC DBCO-PEG3-Biotin|PC-生物素-PEG3-DBCO可用于使用无铜点击化学
【Untitled】
Jenkins一些常见问题
多线程基础(多线程内存,安全,通信,线程池和阻塞队列)
Alamofire源码分析 - POST请求
JSP自定义标签