• vigil监控以及webhook使用


    vigil 是基于rust 编写的轻量,高效,简洁的服务可用性服务,目前发布的版本已经支持webhook了(可以灵活扩展)
    我同时修改了,支持多个发送邮件,这样多种报警方式就都包含了,以下是使用demo

    环境准备

    wdbhook 使用benthos

    • docker-compose 文件
    version: "3"
    services: 
        webhook:
          image: jeffail/benthos
          volumes:
          - "./webhook.yaml:/benthos.yaml"
          ports:
          - "4195:4195"
        vigil:
          image: dalongrong/vigil:v1.12.1
          command: vigil -c /opt/config.cfg
          volumes: 
          - "./config.cfg:/opt/config.cfg"
          ports:
          - "8080:8080"
    • 配置说明
      webhook.yaml:
      输出到标准输出
     
    input:
      type: broker
      broker:
        inputs:
          - type: http_server
            http_server:
              path: /
            processors:
              - type: text
                text:
                  operator: prepend
                  value: "get message: "
    output:
      type: stdout

    vigil 配置:

    # Vigil
    # Microservices Status Page
    # Configuration file
    # Example: https://github.com/valeriansaliou/vigil/blob/master/config.cfg
    [server]
    log_level = "debug"
    inet = "0.0.0.0:8080"
    workers = 4
    reporter_token = "REPLACE_THIS_WITH_A_SECRET_KEY"
    [assets]
    path = "./res/assets/"
    [branding]
    page_title = "Crisp Status"
    page_url = "https://status.crisp.chat/"
    company_name = "Crisp IM SARL"
    icon_color = "#1972F5"
    icon_url = "https://valeriansaliou.github.io/vigil/images/crisp-icon.png"
    logo_color = "#1972F5"
    logo_url = "https://valeriansaliou.github.io/vigil/images/crisp-logo.svg"
    website_url = "https://crisp.chat/"
    support_url = "mailto:support@crisp.chat"
    custom_html = ""
    [metrics]
    poll_interval = 120
    poll_retry = 2
    poll_http_status_healthy_above = 200
    poll_http_status_healthy_below = 400
    poll_delay_dead = 30
    poll_delay_sick = 10
    push_delay_dead = 20
    push_system_cpu_sick_above = 0.90
    push_system_ram_sick_above = 0.90
    [plugins]
    [plugins.rabbitmq]
    api_url = "http://127.0.0.1:15672"
    auth_username = "rabbitmq-administrator"
    auth_password = "RABBITMQ_ADMIN_PASSWORD"
    virtualhost = "crisp"
    queue_ready_healthy_below = 500
    queue_nack_healthy_below = 100
    queue_ready_dead_above = 20000
    queue_nack_dead_above = 5000
    queue_loaded_retry_delay = 500
    [notify]
    reminder_interval = 300
    [notify.email]
    from = "status@crisp.chat"
    to = "status@crisp.chat,demo@crisp.chat"
    smtp_host = "localhost"
    smtp_port = 587
    smtp_username = "user-access"
    smtp_password = "user-password"
    smtp_encrypt = false
    [notify.twilio]
    to = [
      "+336xxxxxxx",
      "+337xxxxxxx"
    ]
    service_sid = "service-sid"
    account_sid = "account-sid"
    auth_token = "auth-token"
    reminders_only = true
    [notify.slack]
    hook_url = "https://hooks.slack.com/services/xxxx"
    mention_channel = true
    [notify.pushover]
    app_token = "xxxx"
    user_keys = ["xxxx"]
    [notify.xmpp]
    from = "vigil@valeriansaliou.name"
    to = "valerian@valeriansaliou.name"
    xmpp_password = "xmpp-password"
    [notify.webhook]
    hook_url = "http://webhook:4195/"
    [probe]
    [[probe.service]]
    id = "web"
    label = "Web nodes"
    http_body_healthy_match=".+"
    [[probe.service.node]]
    id = "core"
    label = "Core main load balancer"
    mode = "poll"
    replicas = [
      "tcp://edge-1.pool.net.crisp.chat:80",
      "tcp://edge-2.pool.net.crisp.chat:80"
    ]
    [[probe.service.node]]
    id = "help"
    label = "Core help load balancer"
    mode = "poll"
    replicas = ["tcp://help-1.pool.net.crisp.chat:80","http://192.168.11.1"]
    [[probe.service.node]]
    id = "api"
    label = "Access to API service"
    mode = "poll"
    replicas = ["https://api.crisp.chat/v1/_system/health"]
    [[probe.service.node]]
    id = "status"
    label = "Access to status page"
    mode = "poll"
    replicas = ["https://status.crisp.chat/robots.txt"]
    http_body_healthy_match = "User-agent:.*"
    [[probe.service]]
    id = "relay"
    label = "Relay nodes"
    [[probe.service.node]]
    id = "socket-client"
    label = "Visitor realtime sockets"
    mode = "push"
    rabbitmq_queue = "client"

    启动&&测试

    • 启动
    docker-compose up -d
    • 查看webhook log
    docker-compose logs -f webhook
    • 效果
      UI:

    webhook log

    说明

    关于vigil 的配置,可以参考官方文档,这里就没有详细介绍,使用还是很简单的,同时v1.12.1 多人邮件的docker 镜像也已经push dockerhub 了

    参考资料

    https://github.com/rongfengliang/vigil-webhook-learning
    https://github.com/rongfengliang/vigil-multi-docker
    https://github.com/servo/rust-smallvec/issues/187

  • 相关阅读:
    Toolkit-常用函数库
    webpack 4版本以上 并行编译 thread-loader
    json格式数据下载
    npm 并行执行 concurrently
    WebAssembly assemblyscript
    npm outdated npm prune
    require import 引入区别
    C#数组的微软官方文档(链接)
    在C#中,override的成员仍然是virtual的
    SQL Server的DECIMAL类型,进行算术运算后会有精度变化
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12144115.html
Copyright © 2020-2023  润新知