lua_shared_dict prometheus_metrics 10M;
lua_package_path	"/etc/nginx/lua/?.lua";
init_by_lua '
	prometheus = require("prometheus").init("prometheus_metrics")
	metric_requests = prometheus:counter("nginx_http_requests_total", "Number of HTTP requests", {"host", "status", "method"})
	metric_latency = prometheus:histogram("nginx_http_request_duration_seconds", "HTTP request latency", {"host"})
	metric_connections = prometheus:gauge("nginx_http_connections", "Number of HTTP connections", {"state"})
';
log_by_lua '
	local host = ngx.var.host:gsub("^www.", "")
	metric_requests:inc(1, {host, ngx.var.status, ngx.var.request_method})
	metric_latency:observe(ngx.now() - ngx.req.start_time(), {host})
';
