pinpoint 1.8.4告警

官方文档

1
https://naver.github.io/pinpoint/alarm.html

 修改  batch.properties文件,batch.enable设置为true.ip能连接的ip

1
2
3
4
5
#batch enable config
batch.enable=true
 
#batch server ip to execute batch
batch.server.ip=127.0.0.127
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * 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.util;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
 
/**
 * @author minwoo.jung
 */
public class BatchUtils {
 
    private final static Logger logger = LoggerFactory.getLogger(BatchUtils.class);
    public static boolean decisionBatchServer(String ip) {
        Enumeration<NetworkInterface> interfaces;
 
        try {
            interfaces = NetworkInterface.getNetworkInterfaces();
        } catch (SocketException e) {
            logger.error("not found network interface", e);
            return false;
        }
 
        if (interfaces == null) {
            return false;
        }
 
        while (interfaces.hasMoreElements()) {
            NetworkInterface network = interfaces.nextElement();
            Enumeration<InetAddress> inets = network.getInetAddresses();
 
            while (inets.hasMoreElements()) {
                InetAddress next = inets.nextElement();
 
                if (next instanceof Inet4Address) {
                    if (next.getHostAddress().equals(ip)) {
                        return true;
                    }
                }
            }
        }
 
        return false;
    }
}

BatchUtils类有对IP进行校验。

com.navercorp.pinpoint.web.config.ConfigProperties读取配置文件

com.navercorp.pinpoint.web.alarm.AlarmWriter 默认配置的EmptyMessageSender,需要自定义个发送对象需要继承AlarmMessageSender,修改AlarmWriter为自己定义对象

1
2
@Autowired(required = false)
private AlarmMessageSender alarmMessageSender = new AlarmMessageSenderImple();

  

新建AlarmMessageSenderImple

复制代码

package com.navercorp.pinpoint.web.alarm;

import com.google.gson.Gson;
import com.navercorp.pinpoint.web.alarm.checker.AlarmChecker;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AlarmMessageSenderImple implements AlarmMessageSender {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Override
public void sendSms(AlarmChecker checker, int sequenceCount) {

}

@Override
public void sendEmail(AlarmChecker checker, int sequenceCount) {
System.out.println(new Gson().toJson(checker.getEmailMessage()));
System.out.println(new Gson().toJson(checker.getRule()));
System.out.println(new Gson().toJson(checker.getUnit()));
System.out.println(new Gson().toJson(checker.getSmsMessage()));
System.out.println(new Gson().toJson(checker.getuserGroupId()));
System.out.println("sequenceCount:" + sequenceCount);
}
}

复制代码

执行结果就是这个根据需求自己写代码了

 

典型Springmvc+mabatis结构前后端分离模式

posted @   Jachs  阅读(401)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示
我拯救了全世界,全世界却抛弃了我。