页面“Alertmanager”与“V2ray”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
=*  my email =
+
新的翻墙神器
@126.com
+
=时间=
  
授权密码
+
<pre>
=telegram=
+
tzselect
通过 prome
 
  
这个有空看一下
+
echo "export TZ='Asia/Shanghai'"  >> /etc/profile 
https://github.com/metalmatze/alertmanager-bot
+
  source /etc/profile
==* 创建 tg  机器和 报警组==
 
  
===** 创建机器 ===
 
  
====*** 202011 创建bot的例子====
+
#记得一定要改时间 不然 超过 90S就连不上了
<pre>
+
  date -s 22:06:00
#2020
+
hwclock --systohc
evan lai, [29.10.20 16:50]
 
/start
 
  
BotFather, [29.10.20 16:50]
+
#将当前时间和日期写入BIOS,避免重启后失效 2020用了这种 有效果
I can help you create and manage Telegram bots. If you're new to the Bot API, please see the manual (https://core.telegram.org/bots).
+
hwclock -w
  
You can control me by sending these commands:
+
VMess 协议的认证基于时间,一定要保证服务器和客户端的系统时间相差要在90秒以内。
  
/newbot - create a new bot
+
</pre>
/mybots - edit your bots [beta]
 
  
Edit Bots
+
=开启BBR=
/setname - change a bot's name
+
BBR是由Google开发的一套算法,Linux内核从4.9版开始集成BBR算法。由于是Linux内核自带的模块,安全性、稳定性怎么也比各种破解版的ServerSpeed要好。
/setdescription - change bot description
 
/setabouttext - change bot about info
 
/setuserpic - change bot profile photo
 
/setcommands - change the list of commands
 
/deletebot - delete a bot
 
  
Bot Settings
 
/token - generate authorization token
 
/revoke - revoke bot access token
 
/setinline - toggle inline mode (https://core.telegram.org/bots/inline)
 
/setinlinegeo - toggle inline location requests (https://core.telegram.org/bots/inline#location-based-results)
 
/setinlinefeedback - change inline feedback (https://core.telegram.org/bots/inline#collecting-feedback) settings
 
/setjoingroups - can your bot be added to groups?
 
/setprivacy - toggle privacy mode (https://core.telegram.org/bots#privacy-mode) in groups
 
  
Games
+
网路颠簸,应该不少人遇到过下载国外服务器上的文件速度慢甚至完全没速度的情况。
/mygames - edit your games (https://core.telegram.org/bots/games) [beta]
 
/newgame - create a new game (https://core.telegram.org/bots/games)
 
/listgames - get a list of your games
 
/editgame - edit a game
 
/deletegame - delete an existing game
 
  
BotFather, [29.10.20 16:50]
+
BBR就是Google开发出的一款针对网络情况不好进行加速的相关算法,简单的说,BBR算法能减少丢包,在拥堵的情况下给各种连接加速。
Alright, a new bot. How are we going to call it? Please choose a name for your bot.
 
  
evan lai, [29.10.20 16:50]
+
对于国外的服务器,不管是上网还是做网站,如果能支持,我都建议开启BBR,大多数情况下能提高下载速度,提高用户体验。
/newbot
 
  
evan lai, [29.10.20 16:51]
+
由于Debian 9默认的内核版本就是4.9.x,我们不需要像别的系统需要更换内核,直接就能开启BBR算法。
evan_alert_bot
+
==开启BBR==
 +
<pre>
 +
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
 +
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
 +
sysctl -p
 +
</pre>
  
BotFather, [29.10.20 16:51]
+
==验证 ==
Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.
+
<pre>
 +
root@v01:~# sysctl net.ipv4.tcp_available_congestion_control
 +
net.ipv4.tcp_available_congestion_control = reno cubic bbr
  
evan lai, [29.10.20 16:51]
+
root@v01:~# sysctl net.ipv4.tcp_congestion_control
evan_alert_bot
+
net.ipv4.tcp_congestion_control = bbr
  
BotFather, [29.10.20 16:51]
+
如果输出的结果中,都有BBR则代表开启成功。
Done! Congratulations on your new bot. You will find it at t.me/evan_alert_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
+
</pre>
  
Use this token to access the HTTP API:
+
=第三方 =
1363904888:AAGeUIoxxRMlxk9zHUa2MTRi1My9HDBP69w
+
<pre>
Keep your token secure and store it safely, it can be used by anyone to control your bot.
+
wget  https://git.io/v2ray.sh
 +
bash v2ray.sh
  
For a description of the Bot API, see this page: https://core.telegram.org/bots/api
 
 
</pre>
 
</pre>
  
====有用的信息 ====
+
=官方脚本安装=
 +
==server ==
 
<pre>
 
<pre>
 +
apt install curl unzip daemon -y
 +
 +
#bash <(curl -L -s https://install.direct/go.sh)
 +
 +
 +
wget https://install.direct/go.sh
 +
bash go.sh
  
 +
systemctl  start  v2ray
  
evan lai, [10.05.20 21:55]
+
Note: 我这次把 server  client port 全开为80 哈哈 有空再扩ktcp
lxtx_prom_alert_bot
 
  
BotFather, [10.05.20 21:55]
 
Done! Congratulations on your new bot. You will find it at t.me/lxtx_prom_alert_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
 
  
Use this token to access the HTTP API:
 
1157710367:AAFD9YLsjdQ_t7botbVLa4xxWrOc9LVHNYc
 
Keep your token secure and store it safely, it can be used by anyone to control your bot.
 
  
For a description of the Bot API, see this page: https://core.telegram.org/bots/api
+
记得开防火墙 Inbound Rules 10086
  
 +
NOTE:
 +
PORT:21385
 +
UUID:da7147e9-66dd-4417-b26f-9b95eeda6332
 +
Created symlink /etc/systemd/system/multi-user.target.wants/v2ray.service → /etc/systemd/system/v2ray.service.
  
使用API/bottoken/API方法getMe获取自己的id
+
在上面的提示中,有一行 "PORT:21385" 代表着端口号为 40827,还有一行 "UUID:da7147e9-66dd-4417-b26f-9b95eeda6332" 代表着 id 为 da7147e9-66dd-4417-b26f-9b95eeda6332。这两个都是随机生成的,不用担心跟别人撞上了。
  
  
curl https://api.telegram.org/bot1157710367:AAFD9YLsjdQ_t7xxxxxLa4imWrOV9LVHNYc/getMe
+
在首次安装完成之后,V2Ray 不会自动启动,需要手动运行上述启动命令。而在已经运行 V2Ray 的 VPS 上再次执行安装脚本,安装脚本会自动停止 V2Ray 进程,升级 V2Ray 程序,然后自动运行 V2Ray。在升级过程中,配置文件不会被修改。
  
 +
对于安装脚本,还有更多用法,在此不多说了,可以执行 bash go.sh -h 看帮助
  
#前面有bot字母
 
sns:~# curl https://api.telegram.org/bot1157710367:AAFD9YLsjdQ_xxxxotbVLa4imWrOV9LVHNYc/getMe
 
{"ok":true,"result":{"id":1157710367,"is_bot":true,"first_name":"prom_alert_bot","username":"lxtx_prom_alert_bot","can_join_groups":true,"can_read_all_group_messages":false,"supports_inline_queries":false}}
 
  
</pre>
+
vi /etc/v2ray/config.json
 +
{
 +
  "inbounds": [
 +
    {
 +
      "port": 16823,
 +
      "protocol": "vmess", 
 +
      "settings": {
 +
        "clients": [
 +
          {
 +
            "id": "b831381d-6324-4d53-ad4f-8cda48b30811", 
 +
            "alterId": 64
 +
          }
 +
        ]
 +
      }
 +
    }
 +
  ],
 +
  "outbounds": [
 +
    {
 +
      "protocol": "freedom", 
 +
      "settings": {}
 +
    }
 +
  ]
 +
}
  
=== 创建组===
 
<pre>
 
获取群ID
 
  
在Telegram新建group,然后添加成员刚创建的机器人 (prom_alert_bot) ,调用API方法getUPdates获取群ID
 
  
curl https://api.telegram.org/bot1157710367:AAFD9YLsjdQ_t7botbVLa4imWrOV9LVHNYc/getUpdates
 
{"ok":true,"result":[{"update_id":367831744,
 
"message":{"message_id":1,"from":{"id":796717144,"is_bot":false,"first_name":"evan","last_name":"lai","username":"linuxsa"},"chat":{"id":-470646458,"title":"alerm","type":"group","all_members_are_administrators":true},"date":1597202656,"new_chat_participant":{"id":1157710367,"is_bot":true,"first_name":"prom_alert_bot","username":"lxtx_prom_alert_bot"},"new_chat_member":{"id":1157710367,"is_bot":true,"first_name":"prom_alert_bot","username":"lxtx_prom_alert_bot"},"new_chat_members":[{"id":1157710367,"is_bot":true,"first_name":"prom_alert_bot","username":"lxtx_prom_alert_bot"}]}}]}
 
 
</pre>
 
</pre>
  
==telegram webhook ==
+
==client==
=== 1.先把 webhook 跑起来 ===
+
===linux(debian)===
 +
 
 +
client  配置请见  http://blog.linuxchina.net/2020/08/11/v2ray/
 
<pre>
 
<pre>
 +
先下载回来 go.sh脚本
 +
 +
使用地址为 127.0.0.1:1080 的 SOCKS 代理下载并安装最新版本:./go.sh -p socks5://127.0.0.1:1080
 +
安装本地的 v1.13 版本:./go.sh --version v4.20 --local /path/to/v2ray.zip
  
 +
#我的72机器是可以FQ的 这个不成功 下载是还是要FQ
 +
./go.sh -p socks5://192.168.88.72:1080
  
git clone https://github.com/evan886/alertmanager-webhook-telegram-python.git
+
#用这个 成功的
cd  alertmanager-webhook-telegram-python/docker
+
#要先下载 zip文件 https://github.com/v2ray/v2ray-core/releases
docker build -t alertmanager-webhook-telegram:1.0 .
+
wget -c https://github.com/v2ray/v2ray-core/releases/download/v4.20.0/v2ray-linux-64.zip
docker run -d --name telegram-bot \
+
/home/evan/ssh/go.sh --version v4.20 --local v2ray-linux-64.zip
-e "bottoken=1157710367:AxxxxxxQ_t7botbVLa4imWrOV9LVHNYc" \
 
-e "chatid=4706458" \
 
-e "username=evan" \
 
-e "password=evanLxx123" \
 
-p 9119:9119 alertmanager-webhook-telegram:1.0
 
</pre>
 
  
==== 配置 ====
+
输出如下 
<pre>
+
PORT:28112
cat alertmanager/config.yml
+
UUID:6176a4f4-c000-4066-b637-d99016b80f32
 +
Created symlink /etc/systemd/system/multi-user.target.wants/v2ray.service → /etc/systemd/system/v2ray.service.
 +
V2Ray local is installed.
  
# 定义路由树信息,这个路由可以接收到所有的告警,还可以继续配置路由,比如project: zhidaoAPP(prometheus 告警规则中自定义的lable)发给谁,project: baoxian的发给谁
 
route:
 
  group_by: ['alertname'] # 报警分组依据
 
  group_wait: 10s        # 最初即第一次等待多久时间发送一组警报的通知
 
  group_interval: 60s    # 在发送新警报前的等待时间
 
  repeat_interval: 1h    # 发送重复警报的周期 对于email配置中,此项不可以设置过低,否则将会由于邮件发送太多频繁,被smtp服务器拒绝
 
  receiver: 'telegram-webhook'      # 发送警报的接收者的名称,以下receivers name的名称
 
  
# 定义警报接收者信息
+
mykali
receivers:
+
sudo apt install v2ray
  - name: 'telegram-webhook'
+
#其实关键就是 alterId 和id
    webhook_configs:
 
    - url: http://evan:[email protected]:9119/alert
 
  
</pre>
 
  
=== 结果查看===
+
vi /etc/v2ray/config.json
正常来说 这时候 你的TG 组就有信息了 ,没的话 就停止一个node export  收不到就有问题喽
 
  
== trouble==
+
{
起不来 老报错 level=error ts=2019-08-26T05:52:52.19072198Z caller=main.go:337 msg="Loading configuration file failed" file=/usr/local/prometheus/alertmanager/alertmanager.yml err="yaml: unmarshal errors:\n line 12: field receivers not found in type config.plain"   解决办法 用了聪的办法 - url: 'http://用户:密码@172.24.103.122:9119/alert'
+
  "inbounds": [
 +
    {
 +
      "port": 1080,
 +
      "protocol": "socks",
 +
      "sniffing": {
 +
        "enabled": true,
 +
        "destOverride": ["http", "tls"]
 +
      },
 +
      "settings": {
 +
        "auth": "noauth"  
 +
      }
 +
    }
 +
  ],
 +
  "outbounds": [
 +
    {
 +
      "protocol": "vmess",
 +
      "settings": {
 +
        "vnext": [
 +
          {
 +
            "address": "你的服务器IP",
 +
            "port": 16823,  
 +
            "users": [
 +
              {
 +
                "id": "b831381d-6324-4d53-ad4f-8cda48b30811", 
 +
                "alterId": 64
 +
              }
 +
            ]
 +
          }
 +
        ]
 +
      }
 +
    }
 +
  ]
 +
}
  
== bot  see also==
 
https://prometheus.io/docs/alerting/latest/configuration/
 
  
https://core.telegram.org/bots
 
  
[https://techsoftcenter.com/how-to-create-a-telegram-bot-id-chat-id/ How to Create a Telegram Bot ID/Chat ID]
 
  
[https://toolbox.kali-linuxtr.net/prometheus-alertmanager-telegram-bot.tool Prometheus Alertmanager Telegram Bot]
 
  
[https://www.cnblogs.com/KillBugMe/p/13140226.html 创建telegram 机器人 并发送消息]
+
</pre>
  
[https://www.teleme.io/articles/create_your_own_telegram_bot?hl=zh-hans 如何创建我自己的电报机器人(Telegram Bot)]
+
===freebsd===
  
[https://nova.moe/manage-host-alert-on-telegram-with-grafana/ 在 Telegram 中管理主机监控和警报信息]
+
<pre>
 +
pkg install v2ray
  
https://github.com/inCaller/prometheus_bot
+
/usr/local/etc/rc.d/v2ray onestart
  
https://github.com/metalmatze/alertmanager-bot
+
sysrc  'v2ray_enable=YES'
  
[https://blog.csdn.net/weixin_34242331/article/details/91875514  基于prometheus + grafana + mysql + Telegram 监控告警]
+
#指定运行
 +
/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
  
https://my.oschina.net/54188zz/blog/3030618
 
  
[https://yunlzheng.gitbook.io/prometheus-book/parti-prometheus-ji-chu/alert/prometheus-alert-rule 自定义Prometheus告警规则]
 
  
[https://www.linux.org.ru/forum/general/14894302 prometheus alertmanager telegram ]
+
配置文件在这里哦  和 linux下的 /etc/v2ray 不一样
 +
/usr/local/etc/v2ray  
  
[https://www.cnblogs.com/wangxu01/articles/11654836.html 部署Alertmanager实现邮件/钉钉/微信报警]
 
  
[https://www.cnblogs.com/xiaobaozi-95/p/10740511.html prometheus告警插件-alertmanager]
 
  
  
  
[https://github.com/metalmatze/alertmanager-bot This is the Alertmanager bot for Prometheus that notifies you on alerts.]
 
  
 +
</pre>
  
 +
====trouble on freebsd====
 +
<pre>
 +
连接到 www.google.com 时发生错误。PR_END_OF_FILE_ERROR  原来是我原来的ss定时任务在跑      不是系统时间不准
  
https://github.com/metalmatze/alertmanager-bot
+
在kali 上没问题,在freebsd上不能上,可能是时间问题  要改服务器时间么
 +
</pre>
  
 +
===android===
  
[https://www.cnblogs.com/longcnblogs/p/9620733.html  Prometheus 和 Alertmanager实战配置]
+
==== v2rayNG====
 +
https://github.com/2dust/v2rayNG/releases/tag/1.3.3
 +
v2rayNG_1.3.3_arm64-v8a.apk
  
== 微信==
+
使用右上角 添加 -->手动输入 Vmess
 +
然后v2ray--> 查看 V2Ray 配置
 +
[https://wiki.kache.moe/2019/11/11/Andoird-V2RayNG/ Android - V2RayNG 使用教程]
  
[https://blog.csdn.net/knight_zhou/article/details/106937276  Prometheus 微信告警注意事项]
+
[https://ssrvps.org/archives/2035 V2Ray 安卓手机客户端下载、安装及使用教程]
=webhook=
 
  
 +
==== BifrostV====
 +
https://apkpure.com/cn/bifrostv/com.github.dawndiy.bifrostv/download?from=details
  
[https://blog.csdn.net/shida_csdn/article/details/81980021  prometheus alertmanager webhook 配置教程]
+
[https://www.jianshu.com/p/fdecbbf18e31 v2ray安装及mac/android下client设置]
  
[https://blog.csdn.net/bluuusea/article/details/104619235  prometheus+alertmanager+webhook实现自定义监控报警系统]
+
[https://github.com/v2ray/v2ray-core/releases 二进制包下载]
  
=* intro =
 
告警能力在Prometheus的架构中被划分为两个部分,在Prometheus Server中定义告警规则以及产生告警,Alertmanager组件则用于处理这些由Prometheus产生的告警。Alertmanager即Prometheus体系中告警的统一处理中心。
 
Alertmanager提供了多种内置第三方告警通知方式,同时还提供了对Webhook通知的支持,通过Webhook用户可以完成对告警更多个性化的扩展。
 
  
=* ins=
+
[https://guide.v2fly.org/prep/install.html#%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%AE%89%E8%A3%85 客户端安装]
==** using docker or docker-composer==
 
  
用自带的 compose
 
  
https://hub.docker.com/r/prom/alertmanager/dockerfile
+
https://guide.v2fly.org/basics/vmess.html#%E5%8E%9F%E7%90%86%E7%AE%80%E6%9E%90 成功的教程
*** docker only
 
  docker pull prom/alertmanager
 
  docker run --name alertmanager  -d -p 9093:9093  -v /path/to/config.yml:/etc/alertmanager/conf/config.yml prom/alertmanager
 
  
  
 +
[https://blog.csdn.net/wowoto/article/details/5557810 date命令修改系统时间 freebsd 系统]
 +
===mac===
 +
https://github.com/yanue/V2rayU/releases
  
 +
=ins docker=
 +
<pre>
 +
apt update #on vps
 +
apt install docker.io docker-compose -y
 +
sudo usermod -aG docker $USER
  
=* conf =
+
</pre>
 +
=docker ins=
 
<pre>
 
<pre>
rules
+
mkdir -p /etc/v2ray
 +
docker pull v2ray/official
  
 +
待 V2Ray 的 Docker 镜像拉取完成后就可以进入下一个部署阶段. 在此之前,你需要在 /etc 目录下新建一个文件夹 v2ray, 并把你的配置写好后命名为 config.json 放入 v2ray 文件夹内. 待配置文件准备就绪后键入以下命令进行部署,部署前请记下配置文件中你所设置的端口号,在部署时需要将其映射到宿主机上. 否则将无法访问. 此处假设设定的端口号为8888,需要映射到宿主机的8888端口上. 则命令为:
  
vim node-up.rules
+
</pre>
groups:
+
==config==
- name: node-up
+
<pre>
  rules:
+
cat >/etc/v2ray/config.json<<-EOF
  - alert: node-up
+
{
     expr: up{job="node-exporter"} == 0
+
    "log": {
     for: 15s
+
        "access": "/etc/v2ray/access.log",
     labels:
+
        "error": "/etc/v2ray/error.log",
      severity: 1
+
        "loglevel": "warning"
      team: node
+
    },
     annotations:
+
    "inbound": {
      summary: "{{ $labels.instance }} 已停止运行超过 15s!"
+
        "port": 443,
 +
        "protocol": "vmess",
 +
        "settings": {
 +
            "clients": [
 +
                {
 +
                    "id": "0576505d-a88f-8ff2-58d4-e65132504e09",
 +
                    "level": 1,
 +
                    "alterId": 64
 +
                }
 +
            ]
 +
        }
 +
    },
 +
     "outbound": {
 +
        "protocol": "freedom",
 +
        "settings": {}
 +
     },
 +
    "inboundDetour": [],
 +
     "outboundDetour": [
 +
        {
 +
            "protocol": "blackhole",
 +
            "settings": {},
 +
            "tag": "blocked"
 +
        }
 +
     ],
 +
    "routing": {
 +
        "strategy": "rules",
 +
        "settings": {
 +
            "rules": [
 +
                {
 +
                    "type": "field",
 +
                    "ip": [
 +
                        "0.0.0.0/8",
 +
                        "10.0.0.0/8",
 +
                        "100.64.0.0/10",
 +
                        "127.0.0.0/8",
 +
                        "169.254.0.0/16",
 +
                        "172.16.0.0/12",
 +
                        "192.0.0.0/24",
 +
                        "192.0.2.0/24",
 +
                        "192.168.0.0/16",
 +
                        "198.18.0.0/15",
 +
                        "198.51.100.0/24",
 +
                        "203.0.113.0/24",
 +
                        "::1/128",
 +
                        "fc00::/7",
 +
                        "fe80::/10"
 +
                    ],
 +
                    "outboundTag": "blocked"
 +
                }
 +
            ]
 +
        }
 +
    }
 +
}
 +
EOF
  
说明一下:该 rules 目的是监测 node 是否存活,expr 为 PromQL 表达式验证特定节点 job="node-exporter" 是否活着,for 表示报警状态为 Pending 后等待 15s 变成 Firing 状态,一旦变成 Firing 状态则将报警发送到 AlertManager,labels 和 annotations 对该 alert 添加更多的标识说明信息,所有添加的标签注解信息,以及 prometheus.yml 中该 job 已添加 label 都会自动添加到邮件内容中,更多关于 rule 详细配置可以参考
+
#sudo docker pull v2ray/official
 +
#sudo docker run --restart=always -d --name v2ray -v /etc/v2ray:/etc/v2ray -p 443:443 v2ray/official  v2ray -config=/etc/v2ray/config.json
  
#告警解除
 
  
 
</pre>
 
</pre>
 +
==run==
 +
<pre>
 +
docker run -d --name v2ray -v /etc/v2ray:/etc/v2ray -p 8888:8888 v2ray/official  v2ray -config=/etc/v2ray/config.json
 +
 +
键入以上命令后,命令行会出现一串字符,代表容器部署成功,可以立即通过客户端连接并开始使用了. 如果还不放心,键入以下命令来查看容器的运行状态:
 +
 +
参考这个
 +
 +
https://toutyrater.github.io/app/docker-deploy-v2ray.html
 +
  
=* 自定义告警规则=
 
==** CPU load 自定义告警规则==
 
<pre>
 
  - alert: high_load-85per
 
    expr: (100-(avg(irate(node_cpu_seconds_total{mode="idle"}[5m]))by (job)) * 100)  > 80
 
    #expr: sum(avg without (cpu)(irate(node_cpu{mode!='idle'}[5m]))) by (instance) > 0.81
 
    #expr: node_load1 > 0.2
 
    for: 10m
 
    labels:
 
      severity: page
 
    annotations:
 
      summary: "Instance {{ $labels.instance }} under high load"
 
      description: "{{ $labels.instance }} of job {{ $labels.job }} is under high load more than  12 minutes."
 
  
FIRING 才会 send email
 
</pre>
 
==** 内存自定义告警规则==
 
<pre>#rules file 注意空格在前面哦
 
- alert: hostMemUsageAlert
 
    expr: ((node_memory_MemTotal_bytes -(node_memory_MemFree_bytes+node_memory_Buffers_bytes+node_memory_Cached_bytes) )/node_memory_MemTotal_bytes ) * 100 > 90
 
    #expr: (node_memory_MemTotal - node_memory_MemAvailable)/node_memory_MemTotal > 0.85
 
    for: 1m
 
    labels:
 
      severity: page
 
    annotations:
 
      summary: "Instance {{ $labels.instance }} MEM usgae high"
 
      description: "{{ $labels.instance }} MEM usage above 85% (current value: {{ $value }})"
 
  
  
</pre>
+
Docker
成功的自定义报警规则 2020
 
https://www.shared-code.com/article/84
 
  
这个成功的 上面的不成功
+
V2Ray 提供了两个预编译的 Docker image:
  
((node_memory_MemTotal_bytes -(node_memory_MemFree_bytes+node_memory_Buffers_bytes+node_memory_Cached_bytes) )/node_memory_MemTotal_bytes ) * 100 > 90
+
    v2ray/official: 包含最新发布的版本,每周跟随新版本更新;
 +
    v2ray/dev: 包含由最新的代码编译而成的程序文件,随代码库更新;
  
[https://www.shared-code.com/article/84  常用prometheus告警规则模板(三]
+
两个 image 的文件结构相同:
  
 +
    /etc/v2ray/config.json: 配置文件
 +
    /usr/bin/v2ray/v2ray: V2Ray 主程序
 +
    /usr/bin/v2ray/v2ctl: V2Ray 辅助工具
 +
    /usr/bin/v2ray/geoip.dat: IP 数据文件
 +
    /usr/bin/v2ray/geosite.dat: 域名数据文件
  
[https://www.bookstack.cn/read/prometheus-book/alert-prometheus-alert-rule.md 自定义Prometheus告警规则]
 
  
==** 磁盘自定义告警==
 
<pre>
 
- alert: LowDiskSpaceNodeFilesystemUsage
 
    expr: 100 - (node_filesystem_free_bytes{mountpoint="/",fstype=~"ext4|xfs"} / node_filesystem_size_bytes{fstype=~"ext4|xfs"} * 100) > 80
 
    for: 1m
 
    labels:
 
      severity: warning
 
    annotations:
 
      summary: "Instance {{ $labels.instance  }} :{{ $labels.mountpoint }} 分区使用率过高"
 
      description: "{{ $labels.instance  }} : {{ $labels.job  }} :{{ $labels.mountpoint  }} 这个分区使用大于百分之80% (当前值:{{ $value }})"
 
 
</pre>
 
</pre>
  
=see also=
 
新环境可能还要分组一下什么的
 
  
[https://blog.csdn.net/y_xiao_/article/details/50818451?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.add_param_isCf&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.add_param_isCf  Prometheus监控 - Alertmanager报警模块]
+
https://www.v2ray.com/chapter_00/install.html
 +
 
 +
 
 +
 
 +
https://hub.docker.com/r/v2ray/official/dockerfile
  
[https://my.oschina.net/OutOfMemory/blog/4706596 Prometheus监控告警浅析]
+
=troubleshooting=
 +
==客户端电脑 时间太快了==
 +
<pre>
 +
载入页面时与 accounts.google.com 的连接中断。
  
[https://www.cnblogs.com/winstom/p/11940570.html Alertmanager 部署配置]
+
    由于不能验证所收到的数据是否可信,无法显示您想要查看的页面
  
[https://blog.51cto.com/lookingdream/2504572 Prometheus监控node_exporter的告警规则]
+
解决  见 开头  date -s 22:06:00
 +
</pre>
  
  
[https://juejin.im/post/6844903880778579976 Prometheus学习系列(三十九)之报警模板例子 ]
+
=see also=
 +
 
 +
[https://guide.v2fly.org/#%E5%A3%B0%E6%98%8E 新 V2Ray 白话文指南good]
  
https://prometheus.io/docs/alerting/alertmanager/
 
  
[https://www.jianshu.com/p/239b145e2acc Prometheus Alertmanager报警组件]
+
[https://maojun.xyz/Docker-deploys-v2ray.html docker部署V2ray]
  
[https://blog.csdn.net/qq_25178661/article/details/86690729 good-prometheus + AlertManager 实现对多node节点CPU和内存信息的监控]
+
[https://github.com/Alvin9999/new-pac/wiki/%E8%87%AA%E5%BB%BAv2ray%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%95%99%E7%A8%8B 自建v2ray服务器教程]
  
[https://blog.csdn.net/kozazyh/article/details/80636512  prometheus-常用的监控告警规则]
+
[https://toutyrater.github.io/app/docker-deploy-v2ray.html docker-deploy-v2ray.html]
  
[https://blog.51cto.com/jerrymin/2333824  Prometheus配合Alertmanager报警系统]
 
  
[https://www.cnblogs.com/longcnblogs/p/9620733.html Prometheus 和 Alertmanager实战配置]
+
[https://linux265.com/news/3826.html 如何在 CentOS 7 上安装 V2Ray 代理软件]
  
[https://www.kancloud.cn/huyipow/prometheus/527563 alertmanager报警规则详解]
 
  
 +
[[Shadowsocks安装与配置]]
  
[https://blog.csdn.net/wang725/article/details/94174331  prometheus - 监控磁盘]
+
[https://zshttp.com/1310.html V2Ray完全使用教程]
  
[https://blog.csdn.net/mnasd/article/details/86694412  Prometheus自定义监控部署]
+
https://github.com/v2ray/v2ray-core
  
[https://www.ctolib.com/docs/sfile/prometheus-book/alert/prometheus-alert-rule.html 自定义Prometheus告警规则]
+
https://www.v2ray.com/chapter_00/start.html 新手上路
  
[https://blog.csdn.net/weixin_33827731/article/details/92947113?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase  监控指标以及prometheus规则-不断完善中]
+
https://toutyrater.github.io/ V2Ray 配置指南
  
[https://www.cnblogs.com/xiangsikai/p/11290000.html Prometheus 编写告警规则案例]
+
[https://menyifan.com/2018/03/24/docker_instance/ Docker托管v2ray和ss实例 ]
  
[https://www.jianshu.com/p/1f05476ebcee 使用prometheus自定义监控]
+
[https://www.linodovultr.com/post/debian-9-config-bbr.html Debian 9 系统开启BBR]
  
[https://blog.csdn.net/chubi7812/article/details/100612951?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase  prometheus通过node_exporter抓取的数据准确计算磁盘使用率]
+
[https://www.i5seo.com/v2ray-client-installation.html v2ray 服务器安装和 v2ray 客户端安装]
  
=k8s =
 
  
[https://www.qikqiak.com/post/alertmanager-of-prometheus-in-practice/ Prometheus报警AlertManager实战]
+
[[category:ops]]
[[category:ops]] [[category:container]] [[category:prom]]
 

2020年12月10日 (四) 11:40的版本

新的翻墙神器

时间

tzselect

echo "export TZ='Asia/Shanghai'"  >> /etc/profile  
 source /etc/profile


#记得一定要改时间 不然 超过 90S就连不上了 
  date -s 22:06:00
 hwclock --systohc

#将当前时间和日期写入BIOS,避免重启后失效 2020用了这种 有效果
hwclock -w

VMess 协议的认证基于时间,一定要保证服务器和客户端的系统时间相差要在90秒以内。

开启BBR

BBR是由Google开发的一套算法,Linux内核从4.9版开始集成BBR算法。由于是Linux内核自带的模块,安全性、稳定性怎么也比各种破解版的ServerSpeed要好。


网路颠簸,应该不少人遇到过下载国外服务器上的文件速度慢甚至完全没速度的情况。

BBR就是Google开发出的一款针对网络情况不好进行加速的相关算法,简单的说,BBR算法能减少丢包,在拥堵的情况下给各种连接加速。

对于国外的服务器,不管是上网还是做网站,如果能支持,我都建议开启BBR,大多数情况下能提高下载速度,提高用户体验。

由于Debian 9默认的内核版本就是4.9.x,我们不需要像别的系统需要更换内核,直接就能开启BBR算法。

开启BBR

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p

验证

root@v01:~# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = reno cubic bbr

root@v01:~# sysctl net.ipv4.tcp_congestion_control
net.ipv4.tcp_congestion_control = bbr

如果输出的结果中,都有BBR则代表开启成功。

第三方

 wget   https://git.io/v2ray.sh
bash v2ray.sh

官方脚本安装

server

apt install curl unzip daemon -y

#bash <(curl -L -s https://install.direct/go.sh)


wget https://install.direct/go.sh
bash go.sh

 systemctl  start  v2ray

Note: 我这次把 server  client port 全开为80 哈哈 有空再扩ktcp



记得开防火墙 Inbound Rules 10086

NOTE:
PORT:21385
UUID:da7147e9-66dd-4417-b26f-9b95eeda6332
Created symlink /etc/systemd/system/multi-user.target.wants/v2ray.service → /etc/systemd/system/v2ray.service.

在上面的提示中,有一行 "PORT:21385" 代表着端口号为 40827,还有一行 "UUID:da7147e9-66dd-4417-b26f-9b95eeda6332" 代表着 id 为 da7147e9-66dd-4417-b26f-9b95eeda6332。这两个都是随机生成的,不用担心跟别人撞上了。


在首次安装完成之后,V2Ray 不会自动启动,需要手动运行上述启动命令。而在已经运行 V2Ray 的 VPS 上再次执行安装脚本,安装脚本会自动停止 V2Ray 进程,升级 V2Ray 程序,然后自动运行 V2Ray。在升级过程中,配置文件不会被修改。

对于安装脚本,还有更多用法,在此不多说了,可以执行 bash go.sh -h 看帮助


vi /etc/v2ray/config.json
{
  "inbounds": [
    {
      "port": 16823, 
      "protocol": "vmess",   
      "settings": {
        "clients": [
          {
            "id": "b831381d-6324-4d53-ad4f-8cda48b30811",  
            "alterId": 64
          }
        ]
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",  
      "settings": {}
    }
  ]
}



client

linux(debian)

client 配置请见 http://blog.linuxchina.net/2020/08/11/v2ray/

 先下载回来 go.sh脚本

使用地址为 127.0.0.1:1080 的 SOCKS 代理下载并安装最新版本:./go.sh -p socks5://127.0.0.1:1080
安装本地的 v1.13 版本:./go.sh --version v4.20 --local /path/to/v2ray.zip

#我的72机器是可以FQ的 这个不成功 下载是还是要FQ
 ./go.sh -p socks5://192.168.88.72:1080

#用这个 成功的
#要先下载 zip文件 https://github.com/v2ray/v2ray-core/releases
wget -c https://github.com/v2ray/v2ray-core/releases/download/v4.20.0/v2ray-linux-64.zip
/home/evan/ssh/go.sh --version v4.20 --local v2ray-linux-64.zip

输出如下  
PORT:28112
UUID:6176a4f4-c000-4066-b637-d99016b80f32
Created symlink /etc/systemd/system/multi-user.target.wants/v2ray.service → /etc/systemd/system/v2ray.service.
V2Ray local is installed.


mykali 
sudo apt install v2ray
#其实关键就是 alterId 和id


vi /etc/v2ray/config.json

{
  "inbounds": [
    {
      "port": 1080, 
      "protocol": "socks", 
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth"  
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess", 
      "settings": {
        "vnext": [
          {
            "address": "你的服务器IP", 
            "port": 16823,  
            "users": [
              {
                "id": "b831381d-6324-4d53-ad4f-8cda48b30811",  
                "alterId": 64 
              }
            ]
          }
        ]
      }
    }
  ]
}





freebsd

pkg install v2ray

/usr/local/etc/rc.d/v2ray onestart

sysrc  'v2ray_enable=YES'

#指定运行
/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json



配置文件在这里哦  和 linux下的 /etc/v2ray 不一样
/usr/local/etc/v2ray  






trouble on freebsd

连接到 www.google.com 时发生错误。PR_END_OF_FILE_ERROR   原来是我原来的ss定时任务在跑      不是系统时间不准

在kali 上没问题,在freebsd上不能上,可能是时间问题  要改服务器时间么 

android

v2rayNG

https://github.com/2dust/v2rayNG/releases/tag/1.3.3 v2rayNG_1.3.3_arm64-v8a.apk

使用右上角 添加 -->手动输入 Vmess

然后v2ray--> 查看 V2Ray 配置

Android - V2RayNG 使用教程

V2Ray 安卓手机客户端下载、安装及使用教程

BifrostV

https://apkpure.com/cn/bifrostv/com.github.dawndiy.bifrostv/download?from=details

v2ray安装及mac/android下client设置

二进制包下载


客户端安装


https://guide.v2fly.org/basics/vmess.html#%E5%8E%9F%E7%90%86%E7%AE%80%E6%9E%90 成功的教程


date命令修改系统时间 freebsd 系统

mac

https://github.com/yanue/V2rayU/releases

ins docker

apt update #on vps 
apt install docker.io docker-compose -y
sudo usermod -aG docker $USER 

docker ins

mkdir -p /etc/v2ray
docker pull v2ray/official

待 V2Ray 的 Docker 镜像拉取完成后就可以进入下一个部署阶段. 在此之前,你需要在 /etc 目录下新建一个文件夹 v2ray, 并把你的配置写好后命名为 config.json 放入 v2ray 文件夹内. 待配置文件准备就绪后键入以下命令进行部署,部署前请记下配置文件中你所设置的端口号,在部署时需要将其映射到宿主机上. 否则将无法访问. 此处假设设定的端口号为8888,需要映射到宿主机的8888端口上. 则命令为:

config

cat >/etc/v2ray/config.json<<-EOF
{
    "log": {
        "access": "/etc/v2ray/access.log",
        "error": "/etc/v2ray/error.log",
        "loglevel": "warning"
    },
    "inbound": {
        "port": 443,
        "protocol": "vmess",
        "settings": {
            "clients": [
                {
                    "id": "0576505d-a88f-8ff2-58d4-e65132504e09",
                    "level": 1,
                    "alterId": 64
                }
            ]
        }
    },
    "outbound": {
        "protocol": "freedom",
        "settings": {}
    },
    "inboundDetour": [],
    "outboundDetour": [
        {
            "protocol": "blackhole",
            "settings": {},
            "tag": "blocked"
        }
    ],
    "routing": {
        "strategy": "rules",
        "settings": {
            "rules": [
                {
                    "type": "field",
                    "ip": [
                        "0.0.0.0/8",
                        "10.0.0.0/8",
                        "100.64.0.0/10",
                        "127.0.0.0/8",
                        "169.254.0.0/16",
                        "172.16.0.0/12",
                        "192.0.0.0/24",
                        "192.0.2.0/24",
                        "192.168.0.0/16",
                        "198.18.0.0/15",
                        "198.51.100.0/24",
                        "203.0.113.0/24",
                        "::1/128",
                        "fc00::/7",
                        "fe80::/10"
                    ],
                    "outboundTag": "blocked"
                }
            ]
        }
    }
}
EOF

#sudo docker pull v2ray/official
#sudo docker run --restart=always -d --name v2ray -v /etc/v2ray:/etc/v2ray -p 443:443 v2ray/official  v2ray -config=/etc/v2ray/config.json


run

 docker run -d --name v2ray -v /etc/v2ray:/etc/v2ray -p 8888:8888 v2ray/official  v2ray -config=/etc/v2ray/config.json

键入以上命令后,命令行会出现一串字符,代表容器部署成功,可以立即通过客户端连接并开始使用了. 如果还不放心,键入以下命令来查看容器的运行状态:

参考这个 

https://toutyrater.github.io/app/docker-deploy-v2ray.html





Docker

V2Ray 提供了两个预编译的 Docker image:

    v2ray/official: 包含最新发布的版本,每周跟随新版本更新;
    v2ray/dev: 包含由最新的代码编译而成的程序文件,随代码库更新;

两个 image 的文件结构相同:

    /etc/v2ray/config.json: 配置文件
    /usr/bin/v2ray/v2ray: V2Ray 主程序
    /usr/bin/v2ray/v2ctl: V2Ray 辅助工具
    /usr/bin/v2ray/geoip.dat: IP 数据文件
    /usr/bin/v2ray/geosite.dat: 域名数据文件



https://www.v2ray.com/chapter_00/install.html


https://hub.docker.com/r/v2ray/official/dockerfile

troubleshooting

客户端电脑 时间太快了

载入页面时与 accounts.google.com 的连接中断。

    由于不能验证所收到的数据是否可信,无法显示您想要查看的页面

解决  见 开头  date -s 22:06:00 


see also

新 V2Ray 白话文指南good


docker部署V2ray

自建v2ray服务器教程

docker-deploy-v2ray.html


如何在 CentOS 7 上安装 V2Ray 代理软件


Shadowsocks安装与配置

V2Ray完全使用教程

https://github.com/v2ray/v2ray-core

https://www.v2ray.com/chapter_00/start.html 新手上路

https://toutyrater.github.io/ V2Ray 配置指南

Docker托管v2ray和ss实例

Debian 9 系统开启BBR

v2ray 服务器安装和 v2ray 客户端安装