Merge branch 'master' into feature/docker
This commit is contained in:
commit
8709136ec1
|
@ -4,7 +4,7 @@ logger:
|
||||||
keepHours: 2
|
keepHours: 2
|
||||||
identity:
|
identity:
|
||||||
specify: ""
|
specify: ""
|
||||||
shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1
|
shell: ifconfig `route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|awk -F ':' '{print $NF}'|head -n 1
|
||||||
sys:
|
sys:
|
||||||
# timeout in ms
|
# timeout in ms
|
||||||
# interval in second
|
# interval in second
|
||||||
|
|
|
@ -4,4 +4,4 @@ logger:
|
||||||
keepHours: 2
|
keepHours: 2
|
||||||
identity:
|
identity:
|
||||||
specify: ""
|
specify: ""
|
||||||
shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1
|
shell: ifconfig `route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|awk -F ':' '{print $NF}'|head -n 1
|
||||||
|
|
|
@ -14,7 +14,7 @@ redis:
|
||||||
|
|
||||||
identity:
|
identity:
|
||||||
specify: ""
|
specify: ""
|
||||||
shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1
|
shell: ifconfig `route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|awk -F ':' '{print $NF}'|head -n 1
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
dir: logs/judge
|
dir: logs/judge
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
n9e-collector
|
|
@ -1 +0,0 @@
|
||||||
sshd
|
|
|
@ -0,0 +1 @@
|
||||||
|
n9e-monapi
|
|
@ -0,0 +1 @@
|
||||||
|
n9e-transfer
|
|
@ -0,0 +1 @@
|
||||||
|
n9e-tsdb
|
|
@ -0,0 +1 @@
|
||||||
|
n9e-index
|
|
@ -0,0 +1 @@
|
||||||
|
n9e-judge
|
|
@ -62,16 +62,16 @@ func Parse(conf string) error {
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"timeout": 1000,
|
"timeout": 1000,
|
||||||
"interval": 10, //采集策略更新时间
|
"interval": 10, //采集策略更新时间
|
||||||
"portPath": "/home/n9e/etc/port",
|
"portPath": "./etc/port",
|
||||||
"procPath": "/home/n9e/etc/proc",
|
"procPath": "./etc/proc",
|
||||||
"logPath": "/home/n9e/etc/log",
|
"logPath": "./etc/log",
|
||||||
"api": "/api/portal/collects/",
|
"api": "/api/portal/collects/",
|
||||||
})
|
})
|
||||||
|
|
||||||
viper.SetDefault("sys", map[string]interface{}{
|
viper.SetDefault("sys", map[string]interface{}{
|
||||||
"timeout": 1000, //请求超时时间
|
"timeout": 1000, //请求超时时间
|
||||||
"interval": 10, //基础指标上报周期
|
"interval": 10, //基础指标上报周期
|
||||||
"plugin": "/home/n9e/plugin",
|
"plugin": "./plugin",
|
||||||
})
|
})
|
||||||
|
|
||||||
err = viper.Unmarshal(&Config)
|
err = viper.Unmarshal(&Config)
|
||||||
|
|
|
@ -30,8 +30,9 @@ func (t *TagkvIndex) GetTagkv() []*TagPair {
|
||||||
t.RLock()
|
t.RLock()
|
||||||
defer t.RUnlock()
|
defer t.RUnlock()
|
||||||
tagkvs := []*TagPair{}
|
tagkvs := []*TagPair{}
|
||||||
var vs []string
|
|
||||||
for k, vm := range t.Tagkv {
|
for k, vm := range t.Tagkv {
|
||||||
|
var vs []string
|
||||||
for v, _ := range vm {
|
for v, _ := range vm {
|
||||||
vs = append(vs, v)
|
vs = append(vs, v)
|
||||||
}
|
}
|
||||||
|
@ -50,8 +51,8 @@ func (t *TagkvIndex) GetTagkvMap() map[string][]string {
|
||||||
defer t.RUnlock()
|
defer t.RUnlock()
|
||||||
tagkvs := make(map[string][]string)
|
tagkvs := make(map[string][]string)
|
||||||
|
|
||||||
var vs []string
|
|
||||||
for k, vm := range t.Tagkv {
|
for k, vm := range t.Tagkv {
|
||||||
|
var vs []string
|
||||||
for v, _ := range vm {
|
for v, _ := range vm {
|
||||||
vs = append(vs, v)
|
vs = append(vs, v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,9 +93,8 @@ func GetTagPairs(c *gin.Context) {
|
||||||
|
|
||||||
resp := []*IndexTagkvResp{}
|
resp := []*IndexTagkvResp{}
|
||||||
|
|
||||||
tagkvFilter := make(map[string]map[string]struct{})
|
|
||||||
|
|
||||||
for _, metric := range recv.Metrics {
|
for _, metric := range recv.Metrics {
|
||||||
|
tagkvFilter := make(map[string]map[string]struct{})
|
||||||
tagkvs := []*cache.TagPair{}
|
tagkvs := []*cache.TagPair{}
|
||||||
|
|
||||||
for _, endpoint := range recv.Endpoints {
|
for _, endpoint := range recv.Endpoints {
|
||||||
|
@ -107,6 +106,7 @@ func GetTagPairs(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tagkvMap := metricIndex.TagkvMap.GetTagkvMap()
|
tagkvMap := metricIndex.TagkvMap.GetTagkvMap()
|
||||||
|
|
||||||
for tagk, tagvs := range tagkvMap {
|
for tagk, tagvs := range tagkvMap {
|
||||||
tagvFilter, exists := tagkvFilter[tagk]
|
tagvFilter, exists := tagkvFilter[tagk]
|
||||||
if !exists {
|
if !exists {
|
||||||
|
|
|
@ -58,7 +58,7 @@ func consume(event *model.Event) {
|
||||||
SetEventStatus(event, model.STATUS_UPGRADE)
|
SetEventStatus(event, model.STATUS_UPGRADE)
|
||||||
|
|
||||||
if needNotify {
|
if needNotify {
|
||||||
if event.EventType == config.ALERT && NeedCallback(event.Sid) {
|
if NeedCallback(event.Sid) {
|
||||||
if err := PushCallbackEvent(event); err != nil {
|
if err := PushCallbackEvent(event); err != nil {
|
||||||
logger.Errorf("push event to callback queue failed, callbackEvent: %+v", event)
|
logger.Errorf("push event to callback queue failed, callbackEvent: %+v", event)
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func consume(event *model.Event) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.EventType == config.ALERT && NeedCallback(event.Sid) {
|
if NeedCallback(event.Sid) {
|
||||||
if err := PushCallbackEvent(event); err != nil {
|
if err := PushCallbackEvent(event); err != nil {
|
||||||
logger.Errorf("push event to callback queue failed, callbackEvent: %+v", event)
|
logger.Errorf("push event to callback queue failed, callbackEvent: %+v", event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ func Config(r *gin.Engine) {
|
||||||
sys.GET("/alive-judges", judges)
|
sys.GET("/alive-judges", judges)
|
||||||
|
|
||||||
sys.POST("/push", PushData)
|
sys.POST("/push", PushData)
|
||||||
sys.POST("/data", QueryDataForJudge)
|
sys.POST("/data", QueryData)
|
||||||
sys.POST("/data/ui", QueryDataForUI)
|
sys.POST("/data/ui", QueryDataForUI)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,17 @@ package stats
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
|
"github.com/didi/nightingale/src/toolkits/address"
|
||||||
|
|
||||||
|
"github.com/toolkits/pkg/file"
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
|
"github.com/toolkits/pkg/runner"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -16,8 +21,14 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(prefix string, addr ...string) {
|
func Init(prefix string, addr ...string) {
|
||||||
if len(addr) > 0 {
|
if len(addr) > 0 && addr[0] != "" {
|
||||||
|
//如果配置了 addr,使用 addr 参数
|
||||||
PushUrl = addr[0]
|
PushUrl = addr[0]
|
||||||
|
|
||||||
|
} else if file.IsExist(path.Join(runner.Cwd, "etc", "address.yml")) {
|
||||||
|
//address.yml 存在,则使用配置文件的地址
|
||||||
|
port := address.GetHTTPPort("collector")
|
||||||
|
PushUrl = fmt.Sprintf("http://127.0.0.1:%d/api/collector/push", port)
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter = NewCounter(prefix)
|
Counter = NewCounter(prefix)
|
||||||
|
|
Loading…
Reference in New Issue