当前位置:网站首页>prometheus-tls加密
prometheus-tls加密
2022-07-30 05:49:00 【大新新大浩浩】
文章目录
前言
记录一下prometheus-tls加密的开启
一、tls加密的引入
在basic_auth加密的基础上加上tls加密,密码密钥双保险。
二、使用步骤
使用basic-auth的基础环境上进行试验,基础环境的搭建具体可以参考basic_auth的配置文章
1.生成密钥文件
安装工具包并生成加密后密码
openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -keyout prom-test.key -out prom-test.crt -subj "/C=CN/ST=Beijing/L=Beijing/O=Moelove.info/CN=localhost"
2.将tls密钥文件写入config.yml文件内
准备配置文件,新增tls配置
cat > ./config.yml<<eof
basic_auth_users:
# 当前设置的用户名为admin, 可以设置多个
admin: $2y$12$mMnPuKlOQ97ff4NjDsQTMukAtRS/ILpjxjEQrCN0vefs0CBLe/hi6
tls_server_config: # TLS加密
cert_file: prom-test.crt
key_file: prom-test.key
配置之后将key、crt文件拷贝至config.yml文件相同目录
4.修改prometheus配置
修改配置,增加basic_auth配置
scrape_configs:
- job_name: 'prometheus'
basic_auth:
username: admin
password: 123456
#新增tls配置
scheme: https
tls_config:
ca_file: prom-test.crt #crt文件名
insecure_skip_verify: true # 跳过不安全认证
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、key、crt文件传递到/etc/prometheus/目录即可
prometheus:
image: prometheus:1
volumes:
- type: bind
source: ./prometheus/prom-test.crt
target: /etc/prometheus/prom-test.crt
read_only: true
- type: bind
source: ./prometheus/prom-test.key
target: /etc/prometheus/prom-test.key
read_only: true
- type: bind
source: ./xxx/xxx/config.yml
target: /etc/prometheus/config.yml
read_only: true
六.访问测试
6.1 测试http协议
使用http协议访问
当使用http协议访问9090时,会提示Client sent an HTTP request to an HTTPS server.
6.2 测试https协议
使用https协议访问
当使用https协议访问9090时,会出现登录弹窗
输入账号密码登录之后检查target
本机器target正常
七.对接granafa
数据源配置处修改http-url,新增勾选"TLS Client Auth"、“Skip TLS Verify”
7.1 配置Basic Auth Details
修改http-url,将http协议修改为https协议

7.2 TLS/SSL Auth Details
填写ServerName,将生成的crt、key文件内密钥信息填写入Client Cert、Client Key文本框内

7.3 测试查看配置可用性

总结
tls使用相较basic_auth多了一个密钥的配置,使用上没有差异
参考
二、Prometheus TLS加密认证和基于 basic_auth 用户名密码访问:link
边栏推荐
- Build an intelligent network security management and control system for digital government
- Azide-SS-biotin|CAS:1620523-64-9|生物素-二硫键-叠氮可降解 (cleavable) 的 ADC linke
- Mastering JESD204B (2) – Debugging of AD6676
- MySQL common commands and mysqldump backup
- DADPS-生物素-炔基_CAS:2241685-22-1试剂反应原理
- 【动态规划】LeetCode刷题清单及思路记录
- npm安装nodejs环境配置
- 单向链表的操作(带头结点)
- Linux(centos7)下安装MySQL
- 为数字政府构建智能化网络安全管控体系
猜你喜欢

SQL并列排序问题

Graph analysis like NetworkX with GraphScope

陕西Biotin-LC_CAS:72040-64-3_N-生物素氨基己酸供应商价格

图扑数字孪生北京故宫,推进旅游业元宇宙进程

图计算101:图计算的类型、语言与系统

测试开发工程师成长日记016 - 关于提测的那些事

多线程进阶(CountDownLatch,死锁,线程安全集合类)

The Force Plan Microservices | Centralized Configuration Center Config Asymmetric Encryption and Security Management

Graph Computing 101: Types, Languages, and Systems of Graph Computing

单片机第一步
随机推荐
爬楼梯C语言
04-加壳和脱壳
不依赖框架的文件下载
Rapidly develop GraphScope graph analysis applications
图扑数字孪生煤矿开采系统,打造采煤“硬实力”
How to import matlab data into modelsim simulation
How to save modelsim simulation data as a file
多线程基础(概念,创建,中断)
Unity Shader 标准光照模型——漫反射
【动态规划】LeetCode刷题清单及思路记录
Alamofire source code analysis - POST request
如何将modelsim仿真数据存成文件
04-packing and unpacking
ParseException line 8:13 mismatched input ‘(‘ expecting ) near ‘int‘ in create table statement
软件测试开发:发送第一封测试报告邮件
Biotin-PEG4-DADPS-Picolyl-azide(CAS:2599839-59-3)生物素试剂
Application of graph computing in network security analysis
网络协议04 - 物理层和数据链路层
测试开发工程师成长日记003 - 接口自动化框架搭建
Mastering JESD204B (3) – Debugging of AD6676