码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • proemtheus TSL加密认证


    参考:二、Prometheus TLS加密认证和基于 basic_auth 用户名密码访问_李在奋斗的博客-CSDN博客_prometheus 密码

    上次写了一个通过nginx反向代理实现Prometheus

    prometheppromethues设置安全认证_无情的搬砖机器的博客-CSDN博客下面总结一下,Prometheus自带的安全认证方式:

    一、prometheus

    1、安装密码工具 yum -y install httpd-tools

    生成的密钥先拷贝下来,后面需要写道配置文件中

    2、生成密码:htpasswd -nBC 12 '' | tr -d ':\n'

    3、启用TSL,准备证书

    openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -keyout prometheus.key -out prometheus.crt -subj "/C=CN/ST=Beijing/L=Guangzhou/O=Ctyun/CN=localhost"

    4、设置配置文件 

    1. mkdir config
    2. mv prometheus.yml prometheus.crt prometheus.key config
    1. [root@evm-test prometheus]# ll
    2. total 203044
    3. drwxr-xr-x 2 root root 90 Jun 28 04:41 config
    4. drwxr-xr-x 2 3434 3434 38 Jun 20 13:27 console_libraries
    5. drwxr-xr-x 2 3434 3434 173 Jun 20 13:27 consoles
    6. drwxr-xr-x 9 root root 240 Jun 28 03:00 data
    7. -rw-r--r-- 1 3434 3434 11357 Jun 20 13:27 LICENSE
    8. -rw-r--r-- 1 3434 3434 3773 Jun 20 13:27 NOTICE
    9. -rwxr-xr-x 1 3434 3434 108069824 Jun 20 13:24 prometheus
    10. -rwxr-xr-x 1 3434 3434 99826736 Jun 20 13:26 promtool
    11. [root@evm-c7j1a8ape0h3uq7dl640 prometheus]# ll
    touch config.yml
    1. [root@evm-test prometheus]# ll config/
    2. total 16
    3. -rw-r--r-- 1 root root 162 Jun 28 03:34 config.yml
    4. -rw-r--r-- 1 root root 1277 Jun 28 02:22 prometheus.crt
    5. -rw-r--r-- 1 root root 1704 Jun 28 02:22 prometheus.key
    6. -rw-r--r-- 1 3434 3434 1097 Jun 28 03:26 prometheus.yml

    5、编辑配置文件

    vim prometheus.yml 此处的password为自己设置的密码如:123456

     vim config.yml admin后面是htpasswd -nBC 12 '' | tr -d ':\n'生成的加密信息

     6、配置system服务

     vi /usr/lib/systemd/system/prometheus.service

    1. [Unit]
    2. Description=https://prometheus.io
    3. [Service]
    4. Restart=on-failure
    5. ExecStart=/data/opt/prometheus/prometheus --config.file=/data/opt/prometheus/c
    6. onfig/prometheus.yml --web.config.file=/data/opt/prometheus/config/config.yml --
    7. web.listen-address=:18091 --web.enable-lifecycle
    8. [Install]
    9. WantedBy=multi-user.target

     7、启动:systemctl start prometheus,查看日志:journal -f -u prometheus

    二、pushgateway

    1、生成密码:htpasswd -nBC 12 '' | tr -d ':\n'

    2、vi config.yml

    1. basic_auth_users:
    2. admin: *****生成加密的密码粘贴在这****

    3、配置system服务

    vi /usr/lib/systemd/system/pushgateway.service

    1. [Unit]
    2. Description=pushgateway
    3. After=network.target
    4. [Service]
    5. ExecStart=/data/opt/pushgateway/pushgateway --web.listen-address=:19091 --web.con
    6. fig.file=/data/opt/pushgateway/config.yml
    7. Restart=on-failure
    8. [Install]
    9. WantedBy=multi-user.target

    4、systemctl start pushgateway

    总结:其实如果环境要求不是很高,Prometheus可以不设置TLS,因为设置了安全证书这些访问的是https请求,java代码修改起来还要适配 

  • 相关阅读:
    java版直播商城平台规划及常见的营销模式 电商源码/小程序/三级分销+商城免费搭建
    简易入手《SOM神经网络》的本质与原理
    监控办公室电脑用什么软件?
    BI零售数据分析:以自身视角展开分析
    iNFTnews | NFT在门票领域会有哪些作用?
    辰视冯良炳博士将于ITES机器视觉与机器人创新应用大讲台开讲
    数值法求解最优控制问题(一)——梯度法
    C基础语法4 —— 函数、结构体
    【算法竞赛入门练习题】统计一个输入的字符串中出现某子串的个数 以及 求一个字符串中的最大等值子串
    浮点数机制学习
  • 原文地址:https://blog.csdn.net/Li_haiyu/article/details/125500148
  • 最新文章
  • 【JVM】编译执行与解释执行的区别是什么?JVM 使用哪种方式?
    用 Hashids 优雅解决 C 端自增 ID 暴露问题
    V8引擎 精品漫游指南--Ignition篇(上) 指令 栈帧 槽位 调用约定 内存布局 基础内容
    LLVM Pass快速入门(四):代码插桩
    milkup:桌面端 markdown AI续写和即时渲染
    基于项目工程构建SBOM(软件物料清单)的研究
    鸿蒙应用开发UI基础第二节:鸿蒙应用程序框架核心解析与实操
    .NET 中如何快速实现 List 集合去重?
    扣子Coze实战:从0到1打造抖音+小红书热点监控智能体
    浅谈数据访问层
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号