[ELK] Nginx 监控
2017-08-03 12:49
246 查看
一、安装nginx 1.11.10
#yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
# cd/usr/local/src
#tar -zxvf nginx-1.11.10.tar.gz
# cdnginx-1.11.10
#./configure --prefix=/usr/local/nginx
# make&& make install
#/usr/local/nginx/sbin/nginx-t #测试
二、修改nginx日志格式
# vi/usr/local/nginx/conf/nginx.conf
三、启动nginx
#/usr/local/nginx/sbin/nginx
四、编写logstash conf文件
input {
file { # file插件
path =>"/var/log/nginx/access_json.log" #日志
type =>"nginx" #定义类型,在输出中可以用做if判断
start_position =>"beginning" #string,
one of ["beginning", "end"]。默认为end
codec => json #格式为json
}
}
output {
elasticsearch {
hosts =>["192.168.1.75:9200"] #定义输出ip:port
index =>"nginx-%{+YYYY.MM.dd}" #定义索引,这个在head/kopf/kibana可以方便查询
}
}
#yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
# cd/usr/local/src
#tar -zxvf nginx-1.11.10.tar.gz
# cdnginx-1.11.10
#./configure --prefix=/usr/local/nginx
# make&& make install
#/usr/local/nginx/sbin/nginx-t #测试
二、修改nginx日志格式
# vi/usr/local/nginx/conf/nginx.conf
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' log_format json '{"@timestamp":"$time_iso8601",' #修改为json格式 '"@version":"1",' '"client":"$remote_addr",' '"url":"$uri",' '"status":"$status",' '"domain":"$host",' '"host":"$server_addr",' '"size":$body_bytes_sent,' '"responsetime":$request_time,' '"referer":"$http_referer",' '"ua":"$http_user_agent"' '}'; # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; #这一行要注释 sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; access_log /var/log/nginx/access_json.log json; #log日志定义放在server{}中 location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } |
三、启动nginx
#/usr/local/nginx/sbin/nginx
四、编写logstash conf文件
input {
file { # file插件
path =>"/var/log/nginx/access_json.log" #日志
type =>"nginx" #定义类型,在输出中可以用做if判断
start_position =>"beginning" #string,
one of ["beginning", "end"]。默认为end
codec => json #格式为json
}
}
output {
elasticsearch {
hosts =>["192.168.1.75:9200"] #定义输出ip:port
index =>"nginx-%{+YYYY.MM.dd}" #定义索引,这个在head/kopf/kibana可以方便查询
}
}
相关文章推荐
- ELK监控日志nginx(集成Geoip)
- 用ELK监控Nginx
- ELK 日志系统搭建--监控nginx
- zabbix nginx error log监控
- Curl监控Nginx网站状态,如回应502信息即重启php-fpm
- FreeBSD安装配置Nginx和Nginx的监控
- Zabbix监控Nginx状态信息
- ELK6.2.2日志分析监控系统搭建和配置
- keepalived 非抢占模式 以及nginx状态监控
- lenny下Cacti连续监控Nginx运行状态
- ELK日志服务器的快速搭建并收集nginx日志 推荐
- nginx 日志和监控
- 在CentOS 7 64位操作系统环境下搭建LNMP(Linux+Nginx+MySQL+PHP)来运行Zabbix监控程序
- 如何监控 NGINX(第一篇)
- Zabbix监控nginx性能
- 简易nginx监控系统
- nginx监控脚本
- zabbix监控系统之监控nginx
- 如何使用 Datadog 监控 NGINX(第三篇)
- zabbix监控nginx模板