今日室友询问相关机器人的事情,本来对于机器人还是有一些了解的,至少是明白一些简单的原理,包括微信公众号,qq群的只能机器人,以及钉钉的机器人。 ...
前面已经介绍了机器人的事情,今天直接贴一下代码。 using System; using System.Collections.Generic;...
# 安装prometheus-webhook-dingtalk插件 #下载 wget https://github.com/timonwong/prometheus-webhook-dingtalk/releases.../download/v1.4.0/prometheus-webhook-dingtalk-1.4.0.linux-amd64.tar.gz #解压 tar -zxf prometheus-webhook-dingtalk.../prometheus-webhook-dingtalk # 进入目录 cd /opt/apps/dingding/prometheus-webhook-dingtalk # 创建启动服务文件 #prometheus-webhook-dingtalk.service...ExecStart=/opt/apps/dingding/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk --config.file=/...opt/apps/dingding/prometheus-webhook-dingtalk/config.yml [Install] WantedBy=default.target 将prometheus-webhook-dingtalk.service
kube-dingtalk 简介 kube-dingtalk 是Kubernetes事件监视服务。连续失败后,通过钉钉机器人播报。...kube-dingtalk 项目地址 https://github.com/yangpeng14/kube-dingtalk Build Docker镜像 FROM node:10-alpine #...Don't run as root user ENV user kube-dingtalk RUN echo "http://mirrors.aliyun.com/alpine/v3.7/main/"..."] --- apiVersion: v1 kind: ServiceAccount metadata: name: kube-dingtalk namespace: kube-system -...serviceAccountName: kube-dingtalk containers: - name: kube-dingtalk image: kube-dingtalk
如果要求不高的话,我们还可以使用国内第三方的告警webhook(例如 钉钉dingtalk、贝洽bearychat) 这里我就以钉钉为例: github上有开源的项目,可以直接使用 地址: https...://github.com/timonwong/prometheus-webhook-dingtalk 下载binary包:prometheus-webhook-dingtalk-0.3.0.linux-amd64....tar.gz tar xf prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz -C /usr/local/ cd /usr/local/prometheus-webhook-dingtalk.../prometheus-webhook-dingtalk --ding.profile="ops_dingding=https://oapi.dingtalk.com/robot/sendaccess_token...的服务器地址}:8060/dingtalk/ops_dingding/send' send_resolved: true route: group_by: ['cluster','alertname
[root@cn-hongkong webhook-dingtalk]# cat webhook-dingtalk.yaml apiVersion: apps/v1beta2 kind: Deployment...metadata: labels: app: webhook-dingtalk name: webhook-dingtalk namespace: monitoring #需要和...- image: billy98/webhook-dingtalk:latest name: webhook-dingtalk args: - "https...://oapi.dingtalk.com/robot/send?.../dingtalk/send/ send_resolved: true 四、查看告警信息 image.png
(data): parameter = get_timestamp_sign() dingtalk_url = url + '×tamp=' + str(parameter['...: extensions/v1beta1 kind: Deployment metadata: labels: app: webhook-dingtalk name: webhook-dingtalk...- image: registry.cn-shenzhen.aliyuncs.com/xxxxx/webhook-dingtalk:latest name: webhook-dingtalk...# args: # - "https://oapi.dingtalk.com/robot/send?...type: ClusterIP EOF 启动webhook kubectl apply prometheus-webhook-dingtalk.yaml -n kube-system
' receivers: - name: 'dingtalk_webhook' webhook_configs: - url: 'http://localhost:8060/dingtalk.../prometheus-webhook-dingtalk-1.4.0.linux-amd64.tar.gz tar -xvf prometheus-webhook-dingtalk-1.4.0.linux-amd64.../system/webhook-dingtalk.service [Unit] Description=prometheus-webhook-dingtalk Documentation=https:/...=prometheus ExecStart=/usr/local/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk --config.file...systemctl restart webhook-dingtalk && systemctl enable webhook-dingtalk 6,prometheus-webhook-dingtalk
在OriginBot上创建一个文件dingtalk_runtime.py, 内容如下: """ 用于钉钉单聊机器人收发消息 """ from dingtalk_stream import AckMessage...DingtalkMsgHandler(dingtalk_stream.ChatbotHandler): def __init__(self): super(dingtalk_stream.ChatbotHandler...( os.getenv("DINGTALK_CLIENTID"), os.getenv("DINGTALK_CLIENTSECRET"), ) client...= dingtalk_stream.DingTalkStreamClient(credential) client.register_callback_handler( dingtalk_stream.chatbot.ChatbotMessage.TOPIC...( os.getenv("DINGTALK_CLIENTID"), os.getenv("DINGTALK_CLIENTSECRET"), ) client
前言 开放平台地址 https://open-dev.dingtalk.com/ 开发模式分为三种 企业内部开发 企业内部使用 第三方企业应用 可上架市场 需要成为产品方案服务商 第三方个人应用 不能上架市场.../document/resourcedownload/local-development-tools-for-microapplications 1)执行以下命令,安装DingTalk-Design-CLI...npm i dingtalk-design-cli@0.20.4 -g 2)执行以下命令,查看是否已经成功安装DingTalk-Design-CLI。...document/tutorial/dingtalk-logon-free-third-party-websites?...git clone https://github.com/open-dingtalk/pierced.git 开启 cd .
='https://oapi.dingtalk.com/robot/send?...JENKINS_JOB_BUILD_LOG_URL="http://ops.dev.xxxx.com/view/testarch/job/${JOB_NAME}/${BUILD_NUMBER}/console" DINGTALK_TEXT...发送钉钉消息通知函数 ################################################################# function SEND_MESSAGE_TO_DINGTALK..." } # 发送钉钉消息 ################################################################# SEND_MESSAGE_TO_DINGTALK..."${DINGTALK_WEBHOOK_URL}" "${DINGTALK_TITLE}" "${DINGTALK_TEXT}" 复制代码 说明: curl ops.dev.xxxx.com/view
当然是在群里添加钉钉自定义机器人 添加时最重要的是 webhook地址(发送消息的请求链接信息)、自定义关键词(发送消息内容必须包含关键词才能发送) 具体可以查看官方的介绍文档 https://open.dingtalk.com...return: ''' #获取Jenkins项目名称 JOB_NAME = basedir2.split("/")[-1] #获取Webhook的token dingtalk_Webhook...= ReadConfig().get_config(file_name=Get_project_path('test_case_config'), section='ENV', option='dingtalk_Webhook...access_token={dingtalk_Webhook}" # 输入上面生成的Webhook地址 headers = { 'Content-Type': 'application..._metadata['BUILD_TAG'] send_dingtalk_message(BUILD_TAG) 第三步:验证钉钉发送的报告是否准确
AlertManager Dingtalk 简介 用于接收AlertManager服务通知并通过钉钉机器人报警 prometheus-operator 安装请参考往期文章 Prometheus Operator...项目地址 https://github.com/yangpeng14/alertmanager-dingtalk-hook 主要代码 import os import json import requests...Service 资源对象:dingtalk-hook.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: name: dingtalk-hook...: containers: - name: dingtalk-hook image: yangpeng2468/alertmanager-dingtalk-hook...dingtalk-hook" created service "dingtalk-hook" created $ kubectl get pods -n kube-ops NAME
else BUILD_STATUS="无法获取" fi fi # 机器人 webhook 地址(上文添加钉钉机器人结束时复制的webhook地址) DINGTALK_WEBHOOK_URL...='https://oapi.dingtalk.com/robot/send?...发送钉钉消息通知函数 ################################################################# function SEND_MESSAGE_TO_DINGTALK..." } # 发送钉钉消息 ################################################################# SEND_MESSAGE_TO_DINGTALK..."${DINGTALK_WEBHOOK_URL}" "${DINGTALK_TITLE}" "${DINGTALK_TEXT}" 说明: curl http://ops.dev.xxxx.com/view
webhook_configs: - send_resolved: true url: http://dingtalk-webhook:8060/dingtalk/guiji/send...labels: app: dingtalk-webhook spec: selector: matchLabels: app: dingtalk-webhook...: - name: dingtalk-webhook image: harbor.zsf.com/public/prometheus-webhook-dingtalk...=https://oapi.dingtalk.com/robot/send?...- name: dingtalk-webhook-confing configMap: name: dingtalk-webhook-config
建议自己起成容易识别的,比如 xxx-project-dingtalk-robot-token 关于Kind凭证类型,有如下几种: Username with password | 用户名和密码 Docker...pipeline中使用凭证 withCredentials // 通过 credentialsId 取出对应凭证,然后赋值给名为'my_dingtalk_token'(自己起)的变量 // 根据变量在其他...step中使用 withCredentials([string(credentialsId: 'dingding-robot-token', variable: 'my_dingtalk_token')...]) { // 注意:构建记录中只会输出 **** echo "${my_dingtalk_token}" } 比如钉钉讨论组建立机器人后会提供给你webhook的地址https://oapi.dingtalk.com...插件 dingTalk accessToken: "${env.ding_robot_token}", imageUrl: '', jenkinsUrl: '', message:
/prometheus-webhook-dingtalk-2.0.0.linux-amd64 /usr/local/prometheus-webhook-dingtalk # 3.配置config.yml.../prometheus-webhook-dingtalk \ --config.file='/usr/local/prometheus-webhook-dingtalk/config.yml...prometheus-webhook-dingtalk.service systemctl start prometheus-webhook-dingtalk.service # 7.确认开启了 [...root@mgr2 prometheus-webhook-dingtalk]# ps -aux|grep prometheus-webhook-dingtalk prometh+ 23162 0.0...Ssl 15:23 0:00 /usr/local/prometheus-webhook-dingtalk/prometheus-webhook-dingtalk --config.file=/usr
例如: 钉钉的跳转协议是 dingtalk://具体什么内容由钉钉自主规定 ,如果是普通的 url 链接用户点击就会跳转到指定网页,而 URL Scheme 链接点击后就会跳转到相应的 app 界面....dingtalk://snowdreams1006.tech/ 这样的链接就能实现自动跳转到钉钉 app 中,既然已经解决了如何打开 app 的问题,那么接下来的事情就是什么时候访问链接的问题了....脚本文件并将运行结果写入到 dingtalk.log 文件 30 08,17 * * * sudo ~/reminder/dingtalk.sh >> ~/reminder/dingtalk.log...url=dingtalk://snowdreams1006.tech" ?...核心重点 浏览器打开类似于 dingtalk://snowdreams1006.tech/ 这样的带有 dingtalk:// 协议的自定义链接即可实现打开钉钉 app 操作.
出现如下内容: 机器人名称:kubernetes 接受群组:钉钉报警测试 消息推送:开启 webhook:https://oapi.dingtalk.com/robot/send?...安装钉钉的webhook插件,在k8s的master1节点操作 tar zxvf prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz cd prometheus-webhook-dingtalk.../prometheus-webhook-dingtalk --web.listen-address="0.0.0.0:8060" --ding.profile="cluster1=https://oapi.dingtalk.com...profiles: map[cluster1:https://oapi.dingtalk.com/robot/send?...: 169.254.25.10 Name: prometheus-webhook-dingtalk.monitor Address 1: 10.233.6.147 prometheus-webhook-dingtalk.monitor.svc.cluster.local
源码已上传GitHub: https://github.com/shirayner/DingTalk_Demo 一、本节要点 1.免登授权的流程 (1)签名校验 (2)获取code,并传到后台 (3... var _config =<%=com.ray.dingtalk.auth.AuthHelper.getConfig(request...; import com.ray.dingtalk.config.Env; /** * HTTP请求封装,建议直接使用sdk的API */ public class HttpHelper {...; import com.ray.dingtalk.util.HttpHelper; /**@desc : * * @author: shirayner * @date : 2017年9...; import com.ray.dingtalk.config.Env; import com.ray.dingtalk.service.contact.UserService; /**身份认证Servlet
领取专属 10元无门槛券
手把手带您无忧上云