Elasticsearch, Nginx monitoring	
with	Prometheus	and	Grafana
2016/08/18
Wataru Yukawa(@wyukawa)
Prometheus	London	meetup
Who	am	I?
• Data	Engineer	at	LINE
• LINE	makes	a	messaging	application	of	the	
same	name,	in	addition	to	other	related	
services
• It	is	the	most	popular	messaging	platform	in	
Japan
• I	like	Premier	League
Agenda
• browser	log	collection	system
• monitor	Elasticsearch/Nginx
browser log collection system
• Frontend	engineer	develops	JavaScript	but	it’s	
difficult	to	debug	because	there	are	many	kind	
of	browsers/devices.
• So	we	create	browser	log	collection	system	
like	Google	Analytics by using web beacon
• Nginx	logs	are	sent	to	ES	by	fluentd
• Fluentd is	an	OSS	log	collector	like	logstash,	
flume written	in	ruby.
What	middleware	should	be	
monitored?
• Nginx
• Elasticsearch
• Fluentd
– I	will	talk	in	PromCon	2016
Nginx	monitoring
• Use	ngx_http_stub_status_module
#	monitoring
location	/___nginx_status	{
stub_status	on;
allow	127.0.0.1;
deny	all;
}
$	curl	-s	http://localhost/___nginx_status
Active	connections:	2
server	accepts	handled	requests
301042	301042	4242850
Reading:	0	Writing:	1	Waiting:	1
lifecycle	of	connection
https://www.datadoghq.com/blog/how-to-monitor-nginx/
Nginx	monitoring
• Use	nginx_exporter
– nginx_exporter uses
ngx_http_stub_status_module	result
#	HELP	nginx_connections_current	Number	of	connections	currently	processed	by	nginx
#	TYPE	nginx_connections_current	gauge
nginx_connections_current{state="active"}	2
nginx_connections_current{state="reading"}	0
nginx_connections_current{state="waiting"}	1
nginx_connections_current{state="writing"}	1
#	HELP	nginx_connections_processed_total	Number	of	connections	processed	by	nginx
#	TYPE	nginx_connections_processed_total	counter
nginx_connections_processed_total{stage="accepted"}	300966
nginx_connections_processed_total{stage="any"}	4.241939e+06
nginx_connections_processed_total{stage="handled"}	300966
nginx	dashboard
request	connection
irate(nginx_connections_processed_total{...,stage="any"}[1m])
Elasticsearch monitoring
• Use	elasticsearch_exporter
• Use	Marvel
Elasticsearch dashboard
java	heap
https://github.com/elastic/elasticsearch/issues/18635
My	feeling
• Prometheus’s	query	is	really	powerful	
especially	when	metric	type	is	counter
• We	can	use	rate/irate	function.
• nginx_exporter and elasticsearch_exporter are
convienient
– easy	to	setup
• Prometheus	and	Grafana are	a	perfect	
combination
References
• https://github.com/discordianfish/nginx_expo
rter
• https://github.com/ewr/elasticsearch_exporte
r

Prometheus london