[ELK] Nginx 监控
来源:互联网 发布:淘宝网上开网店流程 编辑:程序博客网 时间:2024/05/21 04:44
一、安装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
#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 监控
- 用ELK监控Nginx
- ELK 日志系统搭建--监控nginx
- ELK日志监控
- [ELK] File 文件监控
- [ELK] Syslog 监控
- elk监控tomcat日志
- ELK -分析nginx 日志
- elk之nginx
- elk ,django+uWSGI+Nginx
- ELK日志监控系统搭建
- ELK日志监控系统搭建
- ELK日志监控系统搭建
- 【Nginx】监控
- 用ELK监控系统请求和错误
- ELK Stack 日志分析监控平台
- ELK实战-Logstash:监控日志文件
- ELK Stack 日志分析监控平台
- 从一个n位数中选出m位按顺序组成新数并使其最大 || Erasing and Winning UVA
- Unity3D白皮书(一)模型导入设置
- android判断一个Activity是否处于栈顶
- ssm jsp引入Bootstrap
- MusicBee 歌词插件(基于QQ音乐API)
- [ELK] Nginx 监控
- 抽象类和接口
- 8_1 C语言 | 编译原理
- 多态 & 深入探索C++模型
- Unity5.3.3 webgl 注意
- java 冒泡排序程序
- 宏和函数的区别(C语言)
- 排序算法---归并排序
- Kaggle竞赛记录