init project

master
710leo 5 years ago
commit 5f00489392

51
.gitignore vendored

@ -0,0 +1,51 @@
*.exe
*.exe~
*.dll
*.dylib
*.test
*.out
*.prof
*.log
*.o
*.a
*.so
*.sw[po]
*.tar.gz
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
_obj
_test
/log*
/bin
/out
/build
/dist
/etc/*.local.yml
/data*
.idea
.index
.vscode
.DS_Store
.cache-loader
/n9e-*
/src/modules/index/index
/src/modules/collector/collector
/src/modules/transfer/transfer
/src/modules/tsdb/tsdb
/src/modules/monapi/monapi
/web/node_modules
/web/.cache-loader

File diff suppressed because it is too large Load Diff

@ -0,0 +1,30 @@
<img src="https://s3-gz01.didistatic.com/n9e-pub/image/n9e-logo-bg-white.png" width="150" alt="Nightingale"/>
<br>
[中文简介](README_ZH.md)
Nightingale is a fork of Open-Falcon, and all the core modules have been greatly optimized. It integrates the best practices of DiDi. You can think of it as the next generation of Open-Falcon, and use directly in production environment.
## Documentation
Nightingale user manual: [https://n9e.didiyun.com/](https://n9e.didiyun.com/)
## Compile
```bash
mkdir -p $GOPATH/src/github.com/didi
cd $GOPATH/src/github.com/didi
git clone https://github.com/didi/nightingale.git
cd nightingale && ./control build
```
## Team
[ulricqin](https://github.com/ulricqin) [710leo](https://github.com/710leo) [jsers](https://github.com/jsers) [hujter](https://github.com/hujter) [n4mine](https://github.com/n4mine) [heli567](https://github.com/heli567)
## License
<img alt="Apache-2.0 license" src="https://s3-gz01.didistatic.com/n9e-pub/image/apache.jpeg" width="128">
Nightingale is available under the Apache-2.0 license. See the [LICENSE](LICENSE) file for more info.

@ -0,0 +1,30 @@
<img src="https://s3-gz01.didistatic.com/n9e-pub/image/n9e-logo-bg-white.png" width="150" alt="Nightingale"/>
<br>
[English Introduction](README.md)
Nightingale是一套衍生自Open-Falcon的互联网监控解决方案融入了部分滴滴生产环境的最佳实践灵活易用稳定可靠是一个生产环境直接可用的版本 :-)
## 文档
使用手册请参考:[夜莺使用手册](https://n9e.didiyun.com/)
## 编译
```bash
mkdir -p $GOPATH/src/github.com/didi
cd $GOPATH/src/github.com/didi
git clone https://github.com/didi/nightingale.git
cd nightingale && ./control build
```
## 团队
[ulricqin](https://github.com/ulricqin) [710leo](https://github.com/710leo) [jsers](https://github.com/jsers) [hujter](https://github.com/hujter) [n4mine](https://github.com/n4mine) [heli567](https://github.com/heli567)
## 协议
<img alt="Apache-2.0 license" src="https://s3-gz01.didistatic.com/n9e-pub/image/apache.jpeg" width="128">
Nightingale 基于 Apache-2.0 协议进行分发和使用,更多信息参见 [协议文件](LICENSE)。

@ -0,0 +1,206 @@
#!/bin/bash
CWD=$(cd $(dirname $0)/; pwd)
cd $CWD
usage()
{
echo $"Usage: $0 {start|stop|restart|status|build|pack} <module>"
exit 0
}
start_all()
{
# http: 5800
test -x n9e-monapi && start monapi
# http: 5810 ; rpc: 5811
test -x n9e-transfer && start transfer
# http: 5820 ; rpc: 5821
test -x n9e-tsdb && start tsdb
# http: 5830 ; rpc: 5831
test -x n9e-index && start index
# http: 5840 ; rpc: 5841
test -x n9e-judge && start judge
# http: 2058
test -x n9e-collector && start collector
}
start()
{
mod=$1
if [ "x${mod}" = "x" ]; then
usage
return
fi
if [ "x${mod}" = "xall" ]; then
start_all
return
fi
binfile=n9e-${mod}
if [ ! -f $binfile ]; then
echo "file[$binfile] not found"
exit 1
fi
if [ $(ps aux|grep -v grep|grep -v control|grep "$binfile" -c) -gt 0 ]; then
echo "${mod} already started"
return
fi
mkdir -p logs/$mod
nohup $CWD/$binfile &> logs/${mod}/stdout.log &
for((i=1;i<=15;i++)); do
if [ $(ps aux|grep -v grep|grep -v control|grep "$binfile" -c) -gt 0 ]; then
echo "${mod} started"
return
fi
sleep 0.2
done
echo "cannot start ${mod}"
exit 1
}
stop_all()
{
test -x n9e-monapi && stop monapi
test -x n9e-transfer && stop transfer
test -x n9e-tsdb && stop tsdb
test -x n9e-index && stop index
test -x n9e-judge && stop judge
test -x n9e-collector && stop collector
}
stop()
{
mod=$1
if [ "x${mod}" = "x" ]; then
usage
return
fi
if [ "x${mod}" = "xall" ]; then
stop_all
return
fi
binfile=n9e-${mod}
if [ $(ps aux|grep -v grep|grep -v control|grep "$binfile" -c) -eq 0 ]; then
echo "${mod} already stopped"
return
fi
ps aux|grep -v grep|grep -v control|grep "$binfile"|awk '{print $2}'|xargs kill
for((i=1;i<=15;i++)); do
if [ $(ps aux|grep -v grep|grep -v control|grep "$binfile" -c) -eq 0 ]; then
echo "${mod} stopped"
return
fi
sleep 0.2
done
echo "cannot stop $mod"
exit 1
}
restart()
{
mod=$1
if [ "x${mod}" = "x" ]; then
usage
return
fi
if [ "x${mod}" = "xall" ]; then
stop_all
start_all
return
fi
stop $mod
start $mod
status
}
status()
{
ps aux|grep -v grep|grep "n9e"
}
build_one()
{
mod=$1
go build -o n9e-${mod} --tags "md5" src/modules/${mod}/${mod}.go
}
build()
{
mod=$1
if [ "x${mod}" = "x" ]; then
build_one monapi
build_one transfer
build_one index
build_one judge
build_one collector
build_one tsdb
return
fi
build_one $mod
}
reload()
{
mod=$1
if [ "x${mod}" = "x" ]; then
echo "arg: <mod> is necessary"
return
fi
build_one $mod
restart $mod
}
pack()
{
v=$(date +%Y-%m-%d-%H-%M-%S)
tar zcvf n9e-$v.tar.gz control sql plugin pub etc/log etc/port etc/service etc/nginx.conf etc/mysql.yml etc/address.yml \
n9e-collector etc/collector.yml \
n9e-tsdb etc/tsdb.yml \
n9e-index etc/index.yml \
n9e-judge etc/judge.yml \
n9e-transfer etc/transfer.yml \
n9e-monapi etc/monapi.yml
}
case "$1" in
start)
start $2
;;
stop)
stop $2
;;
restart)
restart $2
;;
status)
status
;;
build)
build $2
;;
reload)
reload $2
;;
pack)
pack
;;
*)
usage
esac

File diff suppressed because it is too large Load Diff

@ -0,0 +1,34 @@
---
monapi:
http: 0.0.0.0:5800
addresses:
- 127.0.0.1
transfer:
http: 0.0.0.0:5810
rpc: 0.0.0.0:5811
addresses:
- 127.0.0.1
tsdb:
http: 0.0.0.0:5820
rpc: 0.0.0.0:5821
addresses:
- 127.0.0.1
index:
http: 0.0.0.0:5830
rpc: 0.0.0.0:5831
addresses:
- 127.0.0.1
judge:
http: 0.0.0.0:5840
rpc: 0.0.0.0:5841
addresses:
- 127.0.0.1
collector:
http: 0.0.0.0:2058

@ -0,0 +1,31 @@
# use shell if specify is blank
logger:
dir: logs/collector
level: WARNING
keepHours: 2
identity:
specify: ""
shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1
sys:
# timeout in ms
# interval in second
timeout: 1000
interval: 20
ifacePrefix:
- eth
- em
mountPoint: []
mountIgnorePrefix:
- /var/lib
ignoreMetrics:
- cpu.core.idle
- cpu.core.util
- cpu.core.sys
- cpu.core.user
- cpu.core.nice
- cpu.core.guest
- cpu.core.irq
- cpu.core.softirq
- cpu.core.iowait
- cpu.core.steal

@ -0,0 +1,7 @@
logger:
dir: logs/index
level: WARNING
keepHours: 2
identity:
specify: ""
shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1

@ -0,0 +1,22 @@
query:
connTimeout: 1000
callTimeout: 2000
indexCallTimeout: 2000
redis:
addrs:
- 127.0.0.1:6379
pass: ""
# timeout:
# conn: 500
# read: 3000
# write: 3000
identity:
specify: ""
shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1
logger:
dir: logs/judge
level: WARNING
keepHours: 2

@ -0,0 +1,12 @@
{
"name": "log.sys.oom",
"file_path": "/var/log/messages",
"time_format": "mmm dd HH:MM:SS",
"pattern": "Out of memory",
"interval": 10,
"tags": {},
"func": "cnt",
"degree": 6,
"unit": "次数",
"comment": "有进程oom了"
}

@ -0,0 +1,52 @@
---
salt: "PLACE_SALT"
logger:
dir: "logs/monapi"
level: "WARNING"
keepHours: 24
http:
secret: "PLACE_SECRET"
# for ldap authorization
ldap:
host: "ldap.example.org"
port: 389
baseDn: "dc=example,dc=org"
bindUser: "cn=manager,dc=example,dc=org"
bindPass: "*******"
# openldap: (&(uid=%s))
# AD: (&(sAMAccountName=%s))
authFilter: "(&(uid=%s))"
tls: false
startTLS: false
# notify support: voice, sms, mail, im
# if we have all of notice channel
# notify:
# p1: ["voice", "sms", "mail", "im"]
# p2: ["sms", "mail", "im"]
# p3: ["mail", "im"]
# if we only have mail channel
notify:
p1: ["mail"]
p2: ["mail"]
p3: ["mail"]
# addresses accessible using browsers
link:
stra: http://n9e.example.com/#/monitor/strategy/%v
event: http://n9e.example.com/#/monitor/history/his/%v
claim: http://n9e.example.com/#/monitor/history/cur/%v
# for alarm event and message queue
redis:
addr: "127.0.0.1:6379"
pass: ""
# in ms
# timeout:
# conn: 500
# read: 3000
# write: 3000

@ -0,0 +1,16 @@
---
uic:
addr: "root:1234@tcp(127.0.0.1:3306)/n9e_uic?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
max: 16
idle: 4
debug: false
mon:
addr: "root:1234@tcp(127.0.0.1:3306)/n9e_mon?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
max: 16
idle: 4
debug: false
hbs:
addr: "root:1234@tcp(127.0.0.1:3306)/n9e_hbs?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
max: 16
idle: 4
debug: false

@ -0,0 +1,89 @@
user nginx;
worker_processes auto;
worker_cpu_affinity auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
use epoll;
worker_connections 204800;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
proxy_connect_timeout 500ms;
proxy_send_timeout 1000ms;
proxy_read_timeout 3000ms;
proxy_buffers 64 8k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 64k;
proxy_redirect off;
proxy_next_upstream error invalid_header timeout http_502 http_504;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
upstream n9e.monapi {
server 127.0.0.1:5800;
keepalive 10;
}
upstream n9e.index {
server 127.0.0.1:5830;
keepalive 10;
}
upstream n9e.transfer {
server 127.0.0.1:5810;
keepalive 10;
}
server {
listen 80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /home/n9e/pub;
}
location /api/portal {
proxy_pass http://n9e.monapi;
}
location /api/index {
proxy_pass http://n9e.index;
}
location /api/transfer {
proxy_pass http://n9e.transfer;
}
}
}

@ -0,0 +1,20 @@
[Unit]
Description=Nightingale collector
After=network-online.target
Wants=network-online.target
[Service]
# modify when deploy in prod env
User=root
Group=root
Type=simple
ExecStart=/home/n9e/n9e-collector
WorkingDirectory=/home/n9e
Restart=always
RestartSec=1
StartLimitInterval=0
[Install]
WantedBy=multi-user.target

@ -0,0 +1,20 @@
[Unit]
Description=Nightingale index
After=network-online.target
Wants=network-online.target
[Service]
# modify when deploy in prod env
User=root
Group=root
Type=simple
ExecStart=/home/n9e/n9e-index
WorkingDirectory=/home/n9e
Restart=always
RestartSec=1
StartLimitInterval=0
[Install]
WantedBy=multi-user.target

@ -0,0 +1,20 @@
[Unit]
Description=Nightingale judge
After=network-online.target
Wants=network-online.target
[Service]
# modify when deploy in prod env
User=root
Group=root
Type=simple
ExecStart=/home/n9e/n9e-judge
WorkingDirectory=/home/n9e
Restart=always
RestartSec=1
StartLimitInterval=0
[Install]
WantedBy=multi-user.target

@ -0,0 +1,20 @@
[Unit]
Description=Nightingale monapi
After=network-online.target
Wants=network-online.target
[Service]
# modify when deploy in prod env
User=root
Group=root
Type=simple
ExecStart=/home/n9e/n9e-monapi
WorkingDirectory=/home/n9e
Restart=always
RestartSec=1
StartLimitInterval=0
[Install]
WantedBy=multi-user.target

@ -0,0 +1,20 @@
[Unit]
Description=Nightingale transfer
After=network-online.target
Wants=network-online.target
[Service]
# modify when deploy in prod env
User=root
Group=root
Type=simple
ExecStart=/home/n9e/n9e-transfer
WorkingDirectory=/home/n9e
Restart=always
RestartSec=1
StartLimitInterval=0
[Install]
WantedBy=multi-user.target

@ -0,0 +1,20 @@
[Unit]
Description=Nightingale tsdb
After=network-online.target
Wants=network-online.target
[Service]
# modify when deploy in prod env
User=root
Group=root
Type=simple
ExecStart=/home/n9e/n9e-tsdb
WorkingDirectory=/home/n9e
Restart=always
RestartSec=1
StartLimitInterval=0
[Install]
WantedBy=multi-user.target

@ -0,0 +1,11 @@
backend:
# in ms
# connTimeout: 1000
# callTimeout: 3000
cluster:
tsdb01: 127.0.0.1:5821
logger:
dir: logs/transfer
level: WARNING
keepHours: 2

@ -0,0 +1,8 @@
rrd:
storage: data/5821
cache:
keepMinutes: 120
logger:
dir: logs/tsdb
level: WARNING
keepHours: 2

@ -0,0 +1,30 @@
module github.com/didi/nightingale
go 1.12
require (
github.com/cespare/xxhash v1.1.0
github.com/codegangsta/negroni v1.0.0
github.com/dgryski/go-tsz v0.0.0-20180227144327-03b7d791f4fe
github.com/garyburd/redigo v1.6.0
github.com/gin-contrib/pprof v1.2.1
github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.5.0
github.com/go-sql-driver/mysql v1.4.1
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gorilla/mux v1.6.2
github.com/hpcloud/tail v1.0.0
github.com/json-iterator/go v1.1.9
github.com/mattn/go-isatty v0.0.12
github.com/open-falcon/rrdlite v0.0.0-20200214140804-bf5829f786ad
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72
github.com/spf13/viper v1.6.2
github.com/stretchr/testify v1.4.0
github.com/toolkits/pkg v1.1.1
github.com/ugorji/go/codec v1.1.7
github.com/unrolled/render v1.0.2
go.uber.org/automaxprocs v1.3.0 // indirect
gopkg.in/ldap.v3 v3.1.0
xorm.io/core v0.7.3
xorm.io/xorm v0.8.1
)

344
go.sum

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save