Created
September 10, 2018 06:48
-
-
Save prat0318/4c6a806957e7f023175f9021cda175fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
data: | |
default.conf: |- | |
client_body_buffer_size 10M; | |
client_max_body_size 10M; | |
lua_shared_dict prometheus_metrics 50M; | |
lua_package_path "/opt/nginx-lua-prometheus/?.lua"; | |
init_by_lua ' | |
prometheus = require("prometheus").init("prometheus_metrics") | |
metric_requests = prometheus:counter( | |
"nginx_http_requests_total", "Number of HTTP requests", {"status"}) | |
metric_requests_controller = prometheus:counter( | |
"nginx_http_requests_controller", "Number of HTTP requests", {"status", "controller"}) | |
metric_latency = prometheus:histogram( | |
"nginx_http_request_duration_seconds", "HTTP request latency", {}) | |
metric_connections = prometheus:gauge( | |
"nginx_http_connections", "Number of HTTP connections", {"state"}) | |
'; | |
server { | |
listen 80; | |
server_name localhost; | |
#charset koi8-r; | |
#access_log /var/log/nginx/access.log main buffer=1k; | |
access_log off; | |
error_log /var/log/nginx/error.log notice; | |
log_by_lua ' | |
local backend = ngx.var.http_backend | |
if (backend == nil or backend == "") then | |
backend = "default" | |
end | |
metric_requests:inc(1, {ngx.var.status}) | |
metric_requests_controller:inc(1, {ngx.var.status, backend}) | |
metric_latency:observe(tonumber(ngx.var.request_time), {}) | |
'; | |
location / { | |
proxy_pass http://dis-ingestion.metrics.svc.cluster.local:9090; | |
} | |
} | |
# Server for prometheus scraper. | |
server { | |
listen 9145; | |
access_log off; | |
location /metrics { | |
content_by_lua ' | |
metric_connections:set(ngx.var.connections_reading, {"reading"}) | |
metric_connections:set(ngx.var.connections_waiting, {"waiting"}) | |
metric_connections:set(ngx.var.connections_writing, {"writing"}) | |
prometheus:collect() | |
'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment