pinpoint2.0.2 定制开发--增加钉钉群通知、@到具体个人,解决手机号码无法输入BUG、删除客户端需要认证、查看数据日期范围扩大等。
一、增加钉钉群报警,并@到个人、带报警模块URL
/*
* Copyright 2018 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.web.alarm;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.navercorp.pinpoint.web.alarm.checker.AlarmChecker;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import org.apache.hadoop.hbase.shaded.org.apache.http.HttpResponse;
import org.apache.hadoop.hbase.shaded.org.apache.http.HttpStatus;
import org.apache.hadoop.hbase.shaded.org.apache.http.client.HttpClient;
import org.apache.hadoop.hbase.shaded.org.apache.http.client.methods.HttpPost;
import org.apache.hadoop.hbase.shaded.org.apache.http.entity.StringEntity;
import org.apache.hadoop.hbase.shaded.org.apache.http.impl.client.DefaultHttpClient;
import org.apache.hadoop.hbase.shaded.org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.StepExecution;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author minwoo.jung
*/
public class EmptySmsSender implements SmsSender {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public void sendSms(AlarmChecker checker, int sequenceCount, StepExecution stepExecution) {
Rule rule = checker.getRule();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String content = String.format("[Pinpoint-APM告警]\n告警应用:%s\n告警规则:%s\n告警详情:%s\n告警触发次数:%d次\n告警时间:%s\n @%s\n链接:http://*******/main/%s@%s/5m",
rule.getApplicationId(), rule.getCheckerName(),
checker.getEmailMessage(), sequenceCount, df.format(new Date()), rule.getNotes(),rule.getApplicationId(),rule.getServiceType());
this.dingTalk(content, rule.getNotes());
logger.info("++++++++++++++++++++++++++send content:{}", content);
}
/**
* 发送钉钉消息
*/
public void dingTalk(String content, String phone) {
try {
String WEBHOOK_TOKEN = "https://oapi.dingtalk.com/robot/send?access_token=***********";
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(WEBHOOK_TOKEN);
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
String textMsg = "{\n" +
" \"msgtype\": \"text\", \n" +
" \"text\": {\n" +
" \"content\": \"" + content + "\"\n" +
" }, \n" +
" \"at\": {\n" +
" \"atMobiles\": [\n" +
" \"" + phone + "\" \n" +
" ], \n" +
" \"isAtAll\": false\n" +
" }\n" +
"}";
StringEntity se = new StringEntity(textMsg, "utf-8");
httppost.setEntity(se);
HttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String result = EntityUtils.toString(response.getEntity(), "utf-8");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
二、增加查看数据范围

tis(10),里边是需要的天数。
三、客户端管理
在pinpoint-web里的配置里密码配置为空
四、手机号码无法输入
去除高亮的代码部分。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?