ingress-nginx-helm/user-guide/monitoring/index.html
2024-11-04 22:22:14 +00:00

180 lines
No EOL
59 KiB
HTML

<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link href=https://kubernetes.github.io/ingress-nginx/user-guide/monitoring/ rel=canonical><link href=../miscellaneous/ rel=prev><link href=../multiple-ingress/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.5.3, mkdocs-material-9.4.5"><title>Prometheus and Grafana installation - Ingress-Nginx Controller</title><link rel=stylesheet href=../../assets/stylesheets/main.6a10b989.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.356b1318.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style><link rel=stylesheet href=../../extra.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=teal data-md-color-accent=green> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#monitoring class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class="md-header md-header--shadow md-header--lifted" data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="Ingress-Nginx Controller" class="md-header__button md-logo" aria-label="Ingress-Nginx Controller" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> Ingress-Nginx Controller </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Prometheus and Grafana installation </span> </div> </div> </div> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg> </label> <div class=md-search data-md-component=search role=dialog> <label class=md-search__overlay for=__search></label> <div class=md-search__inner role=search> <form class=md-search__form name=search> <input type=text class=md-search__input name=query aria-label=Search placeholder=Search autocapitalize=off autocorrect=off autocomplete=off spellcheck=false data-md-component=search-query required> <label class="md-search__icon md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg> </label> <nav class=md-search__options aria-label=Search> <button type=reset class="md-search__icon md-icon" title=Clear aria-label=Clear tabindex=-1> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg> </button> </nav> </form> <div class=md-search__output> <div class=md-search__scrollwrap data-md-scrollfix> <div class=md-search-result data-md-component=search-result> <div class=md-search-result__meta> Initializing search </div> <ol class=md-search-result__list role=presentation></ol> </div> </div> </div> </div> </div> <div class=md-header__source> <a href=https://github.com/kubernetes/ingress-nginx title="Go to repository" class=md-source data-md-component=source> <div class="md-source__icon md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg> </div> <div class=md-source__repository> kubernetes/ingress-nginx </div> </a> </div> </nav> <nav class=md-tabs aria-label=Tabs data-md-component=tabs> <div class=md-grid> <ul class=md-tabs__list> <li class=md-tabs__item> <a href=../.. class=md-tabs__link> Welcome </a> </li> <li class=md-tabs__item> <a href=../../deploy/ class=md-tabs__link> Deployment </a> </li> <li class="md-tabs__item md-tabs__item--active"> <a href=../nginx-configuration/ class=md-tabs__link> User Guide </a> </li> <li class=md-tabs__item> <a href=../../examples/ class=md-tabs__link> Examples </a> </li> <li class=md-tabs__item> <a href=../../developer-guide/getting-started/ class=md-tabs__link> Developer Guide </a> </li> <li class=md-tabs__item> <a href=../../faq/ class=md-tabs__link> FAQ </a> </li> </ul> </div> </nav> </header> <div class=md-container data-md-component=container> <main class=md-main data-md-component=main> <div class="md-main__inner md-grid"> <div class="md-sidebar md-sidebar--primary" data-md-component=sidebar data-md-type=navigation> <div class=md-sidebar__scrollwrap> <div class=md-sidebar__inner> <nav class="md-nav md-nav--primary md-nav--lifted" aria-label=Navigation data-md-level=0> <label class=md-nav__title for=__drawer> <a href=../.. title="Ingress-Nginx Controller" class="md-nav__button md-logo" aria-label="Ingress-Nginx Controller" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"/></svg> </a> Ingress-Nginx Controller </label> <div class=md-nav__source> <a href=https://github.com/kubernetes/ingress-nginx title="Go to repository" class=md-source data-md-component=source> <div class="md-source__icon md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg> </div> <div class=md-source__repository> kubernetes/ingress-nginx </div> </a> </div> <ul class=md-nav__list data-md-scrollfix> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_1> <label class=md-nav__link for=__nav_1 id=__nav_1_label tabindex> <span class=md-ellipsis> Welcome </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_1_label aria-expanded=false> <label class=md-nav__title for=__nav_1> <span class="md-nav__icon md-icon"></span> Welcome </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../.. class=md-nav__link> <span class=md-ellipsis> Welcome </span> </a> </li> <li class=md-nav__item> <a href=../../how-it-works/ class=md-nav__link> <span class=md-ellipsis> How it works </span> </a> </li> <li class=md-nav__item> <a href=../../troubleshooting/ class=md-nav__link> <span class=md-ellipsis> Troubleshooting </span> </a> </li> <li class=md-nav__item> <a href=../../kubectl-plugin/ class=md-nav__link> <span class=md-ellipsis> kubectl plugin </span> </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_2> <label class=md-nav__link for=__nav_2 id=__nav_2_label tabindex> <span class=md-ellipsis> Deployment </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_2_label aria-expanded=false> <label class=md-nav__title for=__nav_2> <span class="md-nav__icon md-icon"></span> Deployment </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../deploy/ class=md-nav__link> <span class=md-ellipsis> Installation Guide </span> </a> </li> <li class=md-nav__item> <a href=../../deploy/baremetal/ class=md-nav__link> <span class=md-ellipsis> Bare-metal considerations </span> </a> </li> <li class=md-nav__item> <a href=../../deploy/rbac/ class=md-nav__link> <span class=md-ellipsis> Role Based Access Control (RBAC) </span> </a> </li> <li class=md-nav__item> <a href=../../deploy/upgrade/ class=md-nav__link> <span class=md-ellipsis> Upgrade </span> </a> </li> <li class=md-nav__item> <a href=../../deploy/hardening-guide/ class=md-nav__link> <span class=md-ellipsis> Hardening guide </span> </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_3 checked> <label class=md-nav__link for=__nav_3 id=__nav_3_label tabindex> <span class=md-ellipsis> User Guide </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_3_label aria-expanded=true> <label class=md-nav__title for=__nav_3> <span class="md-nav__icon md-icon"></span> User Guide </label> <ul class=md-nav__list data-md-scrollfix> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_3_1> <label class=md-nav__link for=__nav_3_1 id=__nav_3_1_label tabindex> <span class=md-ellipsis> NGINX Configuration </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=2 aria-labelledby=__nav_3_1_label aria-expanded=false> <label class=md-nav__title for=__nav_3_1> <span class="md-nav__icon md-icon"></span> NGINX Configuration </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../nginx-configuration/ class=md-nav__link> <span class=md-ellipsis> Introduction </span> </a> </li> <li class=md-nav__item> <a href=../basic-usage/ class=md-nav__link> <span class=md-ellipsis> Basic usage </span> </a> </li> <li class=md-nav__item> <a href=../nginx-configuration/annotations/ class=md-nav__link> <span class=md-ellipsis> Annotations </span> </a> </li> <li class=md-nav__item> <a href=../nginx-configuration/annotations-risk/ class=md-nav__link> <span class=md-ellipsis> Annotations Risks </span> </a> </li> <li class=md-nav__item> <a href=../nginx-configuration/configmap/ class=md-nav__link> <span class=md-ellipsis> ConfigMap </span> </a> </li> <li class=md-nav__item> <a href=../nginx-configuration/custom-template/ class=md-nav__link> <span class=md-ellipsis> Custom NGINX template </span> </a> </li> <li class=md-nav__item> <a href=../nginx-configuration/log-format/ class=md-nav__link> <span class=md-ellipsis> Log format </span> </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../cli-arguments/ class=md-nav__link> <span class=md-ellipsis> Command line arguments </span> </a> </li> <li class=md-nav__item> <a href=../custom-errors/ class=md-nav__link> <span class=md-ellipsis> Custom errors </span> </a> </li> <li class=md-nav__item> <a href=../default-backend/ class=md-nav__link> <span class=md-ellipsis> Default backend </span> </a> </li> <li class=md-nav__item> <a href=../exposing-tcp-udp-services/ class=md-nav__link> <span class=md-ellipsis> Exposing TCP and UDP services </span> </a> </li> <li class=md-nav__item> <a href=../fcgi-services/ class=md-nav__link> <span class=md-ellipsis> Exposing FCGI services </span> </a> </li> <li class=md-nav__item> <a href=../ingress-path-matching/ class=md-nav__link> <span class=md-ellipsis> Regular expressions in paths </span> </a> </li> <li class=md-nav__item> <a href=../external-articles/ class=md-nav__link> <span class=md-ellipsis> External Articles </span> </a> </li> <li class=md-nav__item> <a href=../miscellaneous/ class=md-nav__link> <span class=md-ellipsis> Miscellaneous </span> </a> </li> <li class="md-nav__item md-nav__item--active"> <input class="md-nav__toggle md-toggle" type=checkbox id=__toc> <label class="md-nav__link md-nav__link--active" for=__toc> <span class=md-ellipsis> Prometheus and Grafana installation </span> <span class="md-nav__icon md-icon"></span> </label> <a href=./ class="md-nav__link md-nav__link--active"> <span class=md-ellipsis> Prometheus and Grafana installation </span> </a> <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> <label class=md-nav__title for=__toc> <span class="md-nav__icon md-icon"></span> Table of contents </label> <ul class=md-nav__list data-md-component=toc data-md-scrollfix> <li class=md-nav__item> <a href=#prometheus-and-grafana-installation-using-pod-annotations class=md-nav__link> Prometheus and Grafana installation using Pod Annotations </a> <nav class=md-nav aria-label="Prometheus and Grafana installation using Pod Annotations"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#before-you-begin class=md-nav__link> Before You Begin </a> </li> <li class=md-nav__item> <a href=#deploy-and-configure-prometheus-server class=md-nav__link> Deploy and configure Prometheus Server </a> <nav class=md-nav aria-label="Deploy and configure Prometheus Server"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#prometheus-dashboard class=md-nav__link> Prometheus Dashboard </a> </li> <li class=md-nav__item> <a href=#grafana class=md-nav__link> Grafana </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#caveats class=md-nav__link> Caveats </a> <nav class=md-nav aria-label=Caveats> <ul class=md-nav__list> <li class=md-nav__item> <a href=#wildcard-ingresses class=md-nav__link> Wildcard ingresses </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#grafana-dashboard-using-ingress-resource class=md-nav__link> Grafana dashboard using ingress resource </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#prometheus-and-grafana-installation-using-service-monitors class=md-nav__link> Prometheus and Grafana installation using Service Monitors </a> <nav class=md-nav aria-label="Prometheus and Grafana installation using Service Monitors"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#verify-ingress-nginx-controller-is-installed class=md-nav__link> Verify Ingress-Nginx Controller is installed </a> </li> <li class=md-nav__item> <a href=#verify-prometheus-is-installed class=md-nav__link> Verify Prometheus is installed </a> </li> <li class=md-nav__item> <a href=#re-configure-ingress-nginx-controller class=md-nav__link> Re-configure Ingress-Nginx Controller </a> </li> <li class=md-nav__item> <a href=#configure-prometheus class=md-nav__link> Configure Prometheus </a> </li> <li class=md-nav__item> <a href=#connect-and-view-prometheus-dashboard class=md-nav__link> Connect and view Prometheus dashboard </a> </li> <li class=md-nav__item> <a href=#connect-and-view-grafana-dashboard class=md-nav__link> Connect and view Grafana dashboard </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#exposed-metrics class=md-nav__link> Exposed metrics </a> <nav class=md-nav aria-label="Exposed metrics"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#request-metrics class=md-nav__link> Request metrics </a> </li> <li class=md-nav__item> <a href=#nginx-process-metrics class=md-nav__link> Nginx process metrics </a> </li> <li class=md-nav__item> <a href=#controller-metrics class=md-nav__link> Controller metrics </a> </li> <li class=md-nav__item> <a href=#admission-metrics class=md-nav__link> Admission metrics </a> </li> <li class=md-nav__item> <a href=#histogram-buckets class=md-nav__link> Histogram buckets </a> </li> </ul> </nav> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../multiple-ingress/ class=md-nav__link> <span class=md-ellipsis> Multiple Ingress controllers </span> </a> </li> <li class=md-nav__item> <a href=../tls/ class=md-nav__link> <span class=md-ellipsis> TLS/HTTPS </span> </a> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_3_13> <label class=md-nav__link for=__nav_3_13 id=__nav_3_13_label tabindex> <span class=md-ellipsis> Third party addons </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=2 aria-labelledby=__nav_3_13_label aria-expanded=false> <label class=md-nav__title for=__nav_3_13> <span class="md-nav__icon md-icon"></span> Third party addons </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../third-party-addons/modsecurity/ class=md-nav__link> <span class=md-ellipsis> ModSecurity Web Application Firewall </span> </a> </li> <li class=md-nav__item> <a href=../third-party-addons/opentelemetry/ class=md-nav__link> <span class=md-ellipsis> OpenTelemetry </span> </a> </li> </ul> </nav> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_4> <label class=md-nav__link for=__nav_4 id=__nav_4_label tabindex> <span class=md-ellipsis> Examples </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_4_label aria-expanded=false> <label class=md-nav__title for=__nav_4> <span class="md-nav__icon md-icon"></span> Examples </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../examples/ class=md-nav__link> <span class=md-ellipsis> Introduction </span> </a> </li> <li class=md-nav__item> <a href=../../examples/PREREQUISITES/ class=md-nav__link> <span class=md-ellipsis> Prerequisites </span> </a> </li> <li class=md-nav__item> <a href=../../examples/affinity/cookie/ class=md-nav__link> <span class=md-ellipsis> Sticky Sessions </span> </a> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_4_4> <label class=md-nav__link for=__nav_4_4 id=__nav_4_4_label tabindex> <span class=md-ellipsis> Auth </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=2 aria-labelledby=__nav_4_4_label aria-expanded=false> <label class=md-nav__title for=__nav_4_4> <span class="md-nav__icon md-icon"></span> Auth </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../examples/auth/basic/ class=md-nav__link> <span class=md-ellipsis> Basic Authentication </span> </a> </li> <li class=md-nav__item> <a href=../../examples/auth/client-certs/ class=md-nav__link> <span class=md-ellipsis> Client Certificate Authentication </span> </a> </li> <li class=md-nav__item> <a href=../../examples/auth/external-auth/ class=md-nav__link> <span class=md-ellipsis> External Basic Authentication </span> </a> </li> <li class=md-nav__item> <a href=../../examples/auth/oauth-external-auth/ class=md-nav__link> <span class=md-ellipsis> External OAUTH Authentication </span> </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_4_5> <label class=md-nav__link for=__nav_4_5 id=__nav_4_5_label tabindex> <span class=md-ellipsis> Customization </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=2 aria-labelledby=__nav_4_5_label aria-expanded=false> <label class=md-nav__title for=__nav_4_5> <span class="md-nav__icon md-icon"></span> Customization </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../examples/customization/configuration-snippets/ class=md-nav__link> <span class=md-ellipsis> Configuration Snippets </span> </a> </li> <li class=md-nav__item> <a href=../../examples/customization/custom-configuration/ class=md-nav__link> <span class=md-ellipsis> Custom Configuration </span> </a> </li> <li class=md-nav__item> <a href=../../examples/customization/custom-errors/ class=md-nav__link> <span class=md-ellipsis> Custom Errors </span> </a> </li> <li class=md-nav__item> <a href=../../examples/customization/custom-headers/ class=md-nav__link> <span class=md-ellipsis> Custom Headers </span> </a> </li> <li class=md-nav__item> <a href=../../examples/customization/external-auth-headers/ class=md-nav__link> <span class=md-ellipsis> External authentication </span> </a> </li> <li class=md-nav__item> <a href=../../examples/customization/ssl-dh-param/ class=md-nav__link> <span class=md-ellipsis> Custom DH parameters for perfect forward secrecy </span> </a> </li> <li class=md-nav__item> <a href=../../examples/customization/sysctl/ class=md-nav__link> <span class=md-ellipsis> Sysctl tuning </span> </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../../examples/docker-registry/ class=md-nav__link> <span class=md-ellipsis> Docker registry </span> </a> </li> <li class=md-nav__item> <a href=../../examples/grpc/ class=md-nav__link> <span class=md-ellipsis> gRPC </span> </a> </li> <li class=md-nav__item> <a href=../../examples/multi-tls/ class=md-nav__link> <span class=md-ellipsis> Multi TLS certificate termination </span> </a> </li> <li class=md-nav__item> <a href=../../examples/rewrite/ class=md-nav__link> <span class=md-ellipsis> Rewrite </span> </a> </li> <li class=md-nav__item> <a href=../../examples/static-ip/ class=md-nav__link> <span class=md-ellipsis> Static IPs </span> </a> </li> <li class=md-nav__item> <a href=../../examples/tls-termination/ class=md-nav__link> <span class=md-ellipsis> TLS termination </span> </a> </li> <li class=md-nav__item> <a href=../../examples/openpolicyagent/ class=md-nav__link> <span class=md-ellipsis> Open Policy Agent rules </span> </a> </li> <li class=md-nav__item> <a href=../../examples/canary/ class=md-nav__link> <span class=md-ellipsis> Canary Deployments </span> </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_5> <label class=md-nav__link for=__nav_5 id=__nav_5_label tabindex> <span class=md-ellipsis> Developer Guide </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_5_label aria-expanded=false> <label class=md-nav__title for=__nav_5> <span class="md-nav__icon md-icon"></span> Developer Guide </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../developer-guide/getting-started/ class=md-nav__link> <span class=md-ellipsis> Getting Started </span> </a> </li> <li class=md-nav__item> <a href=../../developer-guide/code-overview/ class=md-nav__link> <span class=md-ellipsis> Code Overview </span> </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../../faq/ class=md-nav__link> <span class=md-ellipsis> FAQ </span> </a> </li> </ul> </nav> </div> </div> </div> <div class="md-sidebar md-sidebar--secondary" data-md-component=sidebar data-md-type=toc> <div class=md-sidebar__scrollwrap> <div class=md-sidebar__inner> <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> <label class=md-nav__title for=__toc> <span class="md-nav__icon md-icon"></span> Table of contents </label> <ul class=md-nav__list data-md-component=toc data-md-scrollfix> <li class=md-nav__item> <a href=#prometheus-and-grafana-installation-using-pod-annotations class=md-nav__link> Prometheus and Grafana installation using Pod Annotations </a> <nav class=md-nav aria-label="Prometheus and Grafana installation using Pod Annotations"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#before-you-begin class=md-nav__link> Before You Begin </a> </li> <li class=md-nav__item> <a href=#deploy-and-configure-prometheus-server class=md-nav__link> Deploy and configure Prometheus Server </a> <nav class=md-nav aria-label="Deploy and configure Prometheus Server"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#prometheus-dashboard class=md-nav__link> Prometheus Dashboard </a> </li> <li class=md-nav__item> <a href=#grafana class=md-nav__link> Grafana </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#caveats class=md-nav__link> Caveats </a> <nav class=md-nav aria-label=Caveats> <ul class=md-nav__list> <li class=md-nav__item> <a href=#wildcard-ingresses class=md-nav__link> Wildcard ingresses </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#grafana-dashboard-using-ingress-resource class=md-nav__link> Grafana dashboard using ingress resource </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#prometheus-and-grafana-installation-using-service-monitors class=md-nav__link> Prometheus and Grafana installation using Service Monitors </a> <nav class=md-nav aria-label="Prometheus and Grafana installation using Service Monitors"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#verify-ingress-nginx-controller-is-installed class=md-nav__link> Verify Ingress-Nginx Controller is installed </a> </li> <li class=md-nav__item> <a href=#verify-prometheus-is-installed class=md-nav__link> Verify Prometheus is installed </a> </li> <li class=md-nav__item> <a href=#re-configure-ingress-nginx-controller class=md-nav__link> Re-configure Ingress-Nginx Controller </a> </li> <li class=md-nav__item> <a href=#configure-prometheus class=md-nav__link> Configure Prometheus </a> </li> <li class=md-nav__item> <a href=#connect-and-view-prometheus-dashboard class=md-nav__link> Connect and view Prometheus dashboard </a> </li> <li class=md-nav__item> <a href=#connect-and-view-grafana-dashboard class=md-nav__link> Connect and view Grafana dashboard </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#exposed-metrics class=md-nav__link> Exposed metrics </a> <nav class=md-nav aria-label="Exposed metrics"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#request-metrics class=md-nav__link> Request metrics </a> </li> <li class=md-nav__item> <a href=#nginx-process-metrics class=md-nav__link> Nginx process metrics </a> </li> <li class=md-nav__item> <a href=#controller-metrics class=md-nav__link> Controller metrics </a> </li> <li class=md-nav__item> <a href=#admission-metrics class=md-nav__link> Admission metrics </a> </li> <li class=md-nav__item> <a href=#histogram-buckets class=md-nav__link> Histogram buckets </a> </li> </ul> </nav> </li> </ul> </nav> </div> </div> </div> <div class=md-content data-md-component=content> <article class="md-content__inner md-typeset"> <h1 id=monitoring>Monitoring<a class=headerlink href=#monitoring title="Permanent link"></a></h1> <p>Two different methods to install and configure Prometheus and Grafana are described in this doc. * Prometheus and Grafana installation using Pod Annotations. This installs Prometheus and Grafana in the same namespace as NGINX Ingress * Prometheus and Grafana installation using Service Monitors. This installs Prometheus and Grafana in two different namespaces. This is the preferred method, and helm charts supports this by default.</p> <h2 id=prometheus-and-grafana-installation-using-pod-annotations>Prometheus and Grafana installation using Pod Annotations<a class=headerlink href=#prometheus-and-grafana-installation-using-pod-annotations title="Permanent link"></a></h2> <p>This tutorial will show you how to install <a href=https://prometheus.io/ >Prometheus</a> and <a href=https://grafana.com/ >Grafana</a> for scraping the metrics of the Ingress-Nginx Controller.</p> <div class="admonition important"> <p class=admonition-title>Important</p> <p>This example uses <code>emptyDir</code> volumes for Prometheus and Grafana. This means once the pod gets terminated you will lose all the data.</p> </div> <h3 id=before-you-begin>Before You Begin<a class=headerlink href=#before-you-begin title="Permanent link"></a></h3> <ul> <li> <p>The Ingress-Nginx Controller should already be deployed according to the deployment instructions <a href=../../deploy/ >here</a>.</p> </li> <li> <p>The controller should be configured for exporting metrics. This requires 3 configurations to the controller. These configurations are :</p> </li> <li>controller.metrics.enabled=true</li> <li>controller.podAnnotations."prometheus.io/scrape"="true"</li> <li> <p>controller.podAnnotations."prometheus.io/port"="10254"</p> </li> <li> <p>The easiest way to configure the controller for metrics is via helm upgrade. Assuming you have installed the ingress-nginx controller as a helm release named ingress-nginx, then you can simply type the command shown below : <div class=highlight><pre><span></span><code>helm upgrade ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx \
--set controller.metrics.enabled=true \
--set-string controller.podAnnotations.&quot;prometheus\.io/scrape&quot;=&quot;true&quot; \
--set-string controller.podAnnotations.&quot;prometheus\.io/port&quot;=&quot;10254&quot;
</code></pre></div></p> </li> <li>You can validate that the controller is configured for metrics by looking at the values of the installed release, like this: <div class=highlight><pre><span></span><code>helm get values ingress-nginx --namespace ingress-nginx
</code></pre></div></li> <li>You should be able to see the values shown below: <div class=highlight><pre><span></span><code>..
controller:
metrics:
enabled: true
podAnnotations:
prometheus.io/port: &quot;10254&quot;
prometheus.io/scrape: &quot;true&quot;
..
</code></pre></div></li> <li>If you are <strong>not using helm</strong>, you will have to edit your manifests like this:<ul> <li>Service manifest: <div class=highlight><pre><span></span><code>apiVersion: v1
kind: Service
..
spec:
ports:
- name: prometheus
port: 10254
targetPort: prometheus
..
</code></pre></div></li> <li>Deployment manifest: <div class=highlight><pre><span></span><code>apiVersion: v1
kind: Deployment
..
spec:
template:
metadata:
annotations:
prometheus.io/scrape: &quot;true&quot;
prometheus.io/port: &quot;10254&quot;
spec:
containers:
- name: controller
ports:
- name: prometheus
containerPort: 10254
..
</code></pre></div></li> </ul> </li> </ul> <h3 id=deploy-and-configure-prometheus-server>Deploy and configure Prometheus Server<a class=headerlink href=#deploy-and-configure-prometheus-server title="Permanent link"></a></h3> <p>Note that the kustomize bases used in this tutorial are stored in the <a href=https://github.com/kubernetes/ingress-nginx/tree/main/deploy>deploy</a> folder of the GitHub repository <a href=https://github.com/kubernetes/ingress-nginx>kubernetes/ingress-nginx</a>.</p> <ul> <li> <p>The Prometheus server must be configured so that it can discover endpoints of services. If a Prometheus server is already running in the cluster and if it is configured in a way that it can find the ingress controller pods, no extra configuration is needed.</p> </li> <li> <p>If there is no existing Prometheus server running, the rest of this tutorial will guide you through the steps needed to deploy a properly configured Prometheus server.</p> </li> <li> <p>Running the following command deploys prometheus in Kubernetes:</p> </li> </ul> <div class=highlight><pre><span></span><code>kubectl apply --kustomize github.com/kubernetes/ingress-nginx/deploy/prometheus/
</code></pre></div> <h4 id=prometheus-dashboard>Prometheus Dashboard<a class=headerlink href=#prometheus-dashboard title="Permanent link"></a></h4> <ul> <li>Open Prometheus dashboard in a web browser:</li> </ul> <div class=highlight><pre><span></span><code><span class=go>kubectl get svc -n ingress-nginx</span>
<span class=go>NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE</span>
<span class=go>default-http-backend ClusterIP 10.103.59.201 &lt;none&gt; 80/TCP 3d</span>
<span class=go>ingress-nginx NodePort 10.97.44.72 &lt;none&gt; 80:30100/TCP,443:30154/TCP,10254:32049/TCP 5h</span>
<span class=go>prometheus-server NodePort 10.98.233.86 &lt;none&gt; 9090:32630/TCP 1m</span>
</code></pre></div> <ul> <li>Obtain the IP address of the nodes in the running cluster:</li> </ul> <div class=highlight><pre><span></span><code><span class=go>kubectl get nodes -o wide</span>
</code></pre></div> <ul> <li>In some cases where the node only have internal IP addresses we need to execute:</li> </ul> <div class=highlight><pre><span></span><code>kubectl get nodes --selector=kubernetes.io/role!=master -o jsonpath={.items[*].status.addresses[?\(@.type==\&quot;InternalIP\&quot;\)].address}
10.192.0.2 10.192.0.3 10.192.0.4
</code></pre></div> <ul> <li> <p>Open your browser and visit the following URL: <em>http://{node IP address}:{prometheus-svc-nodeport}</em> to load the Prometheus Dashboard.</p> </li> <li> <p>According to the above example, this URL will be http://10.192.0.3:32630</p> </li> </ul> <p><img alt="Prometheus Dashboard" src=../../images/prometheus-dashboard.png></p> <h4 id=grafana>Grafana<a class=headerlink href=#grafana title="Permanent link"></a></h4> <ul> <li>Install grafana using the below command <div class=highlight><pre><span></span><code>kubectl apply --kustomize github.com/kubernetes/ingress-nginx/deploy/grafana/
</code></pre></div></li> <li> <p>Look at the services <div class=highlight><pre><span></span><code>kubectl get svc -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default-http-backend ClusterIP 10.103.59.201 &lt;none&gt; 80/TCP 3d
ingress-nginx NodePort 10.97.44.72 &lt;none&gt; 80:30100/TCP,443:30154/TCP,10254:32049/TCP 5h
prometheus-server NodePort 10.98.233.86 &lt;none&gt; 9090:32630/TCP 10m
grafana NodePort 10.98.233.87 &lt;none&gt; 3000:31086/TCP 10m
</code></pre></div></p> </li> <li> <p>Open your browser and visit the following URL: <em>http://{node IP address}:{grafana-svc-nodeport}</em> to load the Grafana Dashboard. According to the above example, this URL will be http://10.192.0.3:31086</p> </li> </ul> <p>The username and password is <code>admin</code></p> <ul> <li> <p>After the login you can import the Grafana dashboard from <a href=https://github.com/kubernetes/ingress-nginx/tree/main/deploy/grafana/dashboards>official dashboards</a>, by following steps given below :</p> <ul> <li>Navigate to lefthand panel of grafana</li> <li>Hover on the gearwheel icon for Configuration and click "Data Sources"</li> <li>Click "Add data source"</li> <li>Select "Prometheus"</li> <li>Enter the details (note: I used http://CLUSTER_IP_PROMETHEUS_SVC:9090)</li> <li>Left menu (hover over +) -&gt; Dashboard</li> <li>Click "Import"</li> <li>Enter the copy pasted json from https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/grafana/dashboards/nginx.json</li> <li>Click Import JSON</li> <li>Select the Prometheus data source</li> <li>Click "Import"</li> </ul> </li> </ul> <p><img alt="Grafana Dashboard" src=../../images/grafana.png></p> <h3 id=caveats>Caveats<a class=headerlink href=#caveats title="Permanent link"></a></h3> <h4 id=wildcard-ingresses>Wildcard ingresses<a class=headerlink href=#wildcard-ingresses title="Permanent link"></a></h4> <ul> <li>By default request metrics are labeled with the hostname. When you have a wildcard domain ingress, then there will be no metrics for that ingress (to prevent the metrics from exploding in cardinality). To get metrics in this case you have two options:<ul> <li>Run the ingress controller with <code>--metrics-per-host=false</code>. You will lose labeling by hostname, but still have labeling by ingress.</li> <li>Run the ingress controller with <code>--metrics-per-undefined-host=true --metrics-per-host=true</code>. You will get labeling by hostname even if the hostname is not explicitly defined on an ingress. Be warned that cardinality could explode due to many hostnames and CPU usage could also increase.</li> </ul> </li> </ul> <h3 id=grafana-dashboard-using-ingress-resource>Grafana dashboard using ingress resource<a class=headerlink href=#grafana-dashboard-using-ingress-resource title="Permanent link"></a></h3> <ul> <li>If you want to expose the dashboard for grafana using an ingress resource, then you can :<ul> <li>change the service type of the prometheus-server service and the grafana service to "ClusterIP" like this : <div class=highlight><pre><span></span><code>kubectl -n ingress-nginx edit svc grafana
</code></pre></div></li> <li>This will open the currently deployed service grafana in the default editor configured in your shell (vi/nvim/nano/other)</li> <li>scroll down to line 34 that looks like "type: NodePort"</li> <li>change it to look like "type: ClusterIP". Save and exit.</li> <li>create an ingress resource with backend as "grafana" and port as "3000"</li> </ul> </li> <li>Similarly, you can edit the service "prometheus-server" and add an ingress resource.</li> </ul> <h2 id=prometheus-and-grafana-installation-using-service-monitors>Prometheus and Grafana installation using Service Monitors<a class=headerlink href=#prometheus-and-grafana-installation-using-service-monitors title="Permanent link"></a></h2> <p>This document assumes you're using helm and using the kube-prometheus-stack package to install Prometheus and Grafana.</p> <h3 id=verify-ingress-nginx-controller-is-installed>Verify Ingress-Nginx Controller is installed<a class=headerlink href=#verify-ingress-nginx-controller-is-installed title="Permanent link"></a></h3> <ul> <li> <p>The Ingress-Nginx Controller should already be deployed according to the deployment instructions <a href=../../deploy/ >here</a>.</p> </li> <li> <p>To check if Ingress controller is deployed, <div class=highlight><pre><span></span><code>kubectl get pods -n ingress-nginx
</code></pre></div></p> </li> <li>The result should look something like: <code>NAME READY STATUS RESTARTS AGE ingress-nginx-controller-7c489dc7b7-ccrf6 1/1 Running 0 19h</code></li> </ul> <h3 id=verify-prometheus-is-installed>Verify Prometheus is installed<a class=headerlink href=#verify-prometheus-is-installed title="Permanent link"></a></h3> <ul> <li>To check if Prometheus is already deployed, run the following command:</li> </ul> <p><div class=highlight><pre><span></span><code>helm ls -A
</code></pre></div> <div class=highlight><pre><span></span><code>NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
ingress-nginx ingress-nginx 10 2022-01-20 18:08:55.267373 -0800 PST deployed ingress-nginx-4.0.16 1.1.1
prometheus prometheus 1 2022-01-20 16:07:25.086828 -0800 PST deployed kube-prometheus-stack-30.1.0 0.53.1
</code></pre></div> - Notice that prometheus is installed in a differenet namespace than ingress-nginx</p> <ul> <li>If prometheus is not installed, then you can install from <a href=https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack>here</a></li> </ul> <h3 id=re-configure-ingress-nginx-controller>Re-configure Ingress-Nginx Controller<a class=headerlink href=#re-configure-ingress-nginx-controller title="Permanent link"></a></h3> <ul> <li>The Ingress NGINX controller needs to be reconfigured for exporting metrics. This requires 3 additional configurations to the controller. These configurations are : <div class=highlight><pre><span></span><code>controller.metrics.enabled=true
controller.metrics.serviceMonitor.enabled=true
controller.metrics.serviceMonitor.additionalLabels.release=&quot;prometheus&quot;
</code></pre></div></li> <li>The easiest way of doing this is to helm upgrade <div class=highlight><pre><span></span><code>helm upgrade ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx \
--set controller.metrics.enabled=true \
--set controller.metrics.serviceMonitor.enabled=true \
--set controller.metrics.serviceMonitor.additionalLabels.release=&quot;prometheus&quot;
</code></pre></div></li> <li> <p>Here <code>controller.metrics.serviceMonitor.additionalLabels.release="prometheus"</code> should match the name of the helm release of the <code>kube-prometheus-stack</code></p> </li> <li> <p>You can validate that the controller has been successfully reconfigured to export metrics by looking at the values of the installed release, like this: <div class=highlight><pre><span></span><code>helm get values ingress-nginx --namespace ingress-nginx
</code></pre></div> <div class=highlight><pre><span></span><code>controller:
metrics:
enabled: true
serviceMonitor:
additionalLabels:
release: prometheus
enabled: true
</code></pre></div></p> </li> </ul> <h3 id=configure-prometheus>Configure Prometheus<a class=headerlink href=#configure-prometheus title="Permanent link"></a></h3> <ul> <li>Since Prometheus is running in a different namespace and not in the ingress-nginx namespace, it would not be able to discover ServiceMonitors in other namespaces when installed. Reconfigure your kube-prometheus-stack Helm installation to set <code>serviceMonitorSelectorNilUsesHelmValues</code> flag to false. By default, Prometheus only discovers PodMonitors within its own namespace. This should be disabled by setting <code>podMonitorSelectorNilUsesHelmValues</code> to false</li> <li>The configurations required are: <div class=highlight><pre><span></span><code>prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false
prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false
</code></pre></div></li> <li>The easiest way of doing this is to use <code>helm upgrade ...</code> <div class=highlight><pre><span></span><code>helm upgrade prometheus prometheus-community/kube-prometheus-stack \
--namespace prometheus \
--set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false \
--set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false
</code></pre></div></li> <li>You can validate that Prometheus has been reconfigured by looking at the values of the installed release, like this: <div class=highlight><pre><span></span><code>helm get values prometheus --namespace prometheus
</code></pre></div></li> <li>You should be able to see the values shown below: <div class=highlight><pre><span></span><code>prometheus:
prometheusSpec:
podMonitorSelectorNilUsesHelmValues: false
serviceMonitorSelectorNilUsesHelmValues: false
</code></pre></div></li> </ul> <h3 id=connect-and-view-prometheus-dashboard>Connect and view Prometheus dashboard<a class=headerlink href=#connect-and-view-prometheus-dashboard title="Permanent link"></a></h3> <ul> <li>Port forward to Prometheus service. Find out the name of the prometheus service by using the following command: <div class=highlight><pre><span></span><code>kubectl get svc -n prometheus
</code></pre></div></li> </ul> <p>The result of this command would look like: <div class=highlight><pre><span></span><code>NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
alertmanager-operated ClusterIP None &lt;none&gt; 9093/TCP,9094/TCP,9094/UDP 7h46m
prometheus-grafana ClusterIP 10.106.28.162 &lt;none&gt; 80/TCP 7h46m
prometheus-kube-prometheus-alertmanager ClusterIP 10.108.125.245 &lt;none&gt; 9093/TCP 7h46m
prometheus-kube-prometheus-operator ClusterIP 10.110.220.1 &lt;none&gt; 443/TCP 7h46m
prometheus-kube-prometheus-prometheus ClusterIP 10.102.72.134 &lt;none&gt; 9090/TCP 7h46m
prometheus-kube-state-metrics ClusterIP 10.104.231.181 &lt;none&gt; 8080/TCP 7h46m
prometheus-operated ClusterIP None &lt;none&gt; 9090/TCP 7h46m
prometheus-prometheus-node-exporter ClusterIP 10.96.247.128 &lt;none&gt; 9100/TCP 7h46m
</code></pre></div> prometheus-kube-prometheus-prometheus is the service we want to port forward to. We can do so using the following command: <div class=highlight><pre><span></span><code>kubectl port-forward svc/prometheus-kube-prometheus-prometheus -n prometheus 9090:9090
</code></pre></div> When you run the above command, you should see something like: <div class=highlight><pre><span></span><code>Forwarding from 127.0.0.1:9090 -&gt; 9090
Forwarding from [::1]:9090 -&gt; 9090
</code></pre></div> - Open your browser and visit the following URL http://localhost:{port-forwarded-port} according to the above example it would be, http://localhost:9090</p> <p><img alt="Prometheus Dashboard" src=../../images/prometheus-dashboard1.png></p> <h3 id=connect-and-view-grafana-dashboard>Connect and view Grafana dashboard<a class=headerlink href=#connect-and-view-grafana-dashboard title="Permanent link"></a></h3> <ul> <li>Port forward to Grafana service. Find out the name of the Grafana service by using the following command: <div class=highlight><pre><span></span><code>kubectl get svc -n prometheus
</code></pre></div></li> </ul> <p>The result of this command would look like: <div class=highlight><pre><span></span><code>NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
alertmanager-operated ClusterIP None &lt;none&gt; 9093/TCP,9094/TCP,9094/UDP 7h46m
prometheus-grafana ClusterIP 10.106.28.162 &lt;none&gt; 80/TCP 7h46m
prometheus-kube-prometheus-alertmanager ClusterIP 10.108.125.245 &lt;none&gt; 9093/TCP 7h46m
prometheus-kube-prometheus-operator ClusterIP 10.110.220.1 &lt;none&gt; 443/TCP 7h46m
prometheus-kube-prometheus-prometheus ClusterIP 10.102.72.134 &lt;none&gt; 9090/TCP 7h46m
prometheus-kube-state-metrics ClusterIP 10.104.231.181 &lt;none&gt; 8080/TCP 7h46m
prometheus-operated ClusterIP None &lt;none&gt; 9090/TCP 7h46m
prometheus-prometheus-node-exporter ClusterIP 10.96.247.128 &lt;none&gt; 9100/TCP 7h46m
</code></pre></div> prometheus-grafana is the service we want to port forward to. We can do so using the following command: <div class=highlight><pre><span></span><code>kubectl port-forward svc/prometheus-grafana 3000:80 -n prometheus
</code></pre></div> When you run the above command, you should see something like: <div class=highlight><pre><span></span><code>Forwarding from 127.0.0.1:3000 -&gt; 3000
Forwarding from [::1]:3000 -&gt; 3000
</code></pre></div> - Open your browser and visit the following URL http://localhost:{port-forwarded-port} according to the above example it would be, http://localhost:3000 The default username/ password is admin/prom-operator - After the login you can import the Grafana dashboard from <a href=https://github.com/kubernetes/ingress-nginx/tree/main/deploy/grafana/dashboards>official dashboards</a>, by following steps given below :</p> <ul> <li>Navigate to lefthand panel of grafana</li> <li>Hover on the gearwheel icon for Configuration and click "Data Sources"</li> <li>Click "Add data source"</li> <li>Select "Prometheus"</li> <li>Enter the details (note: I used http://10.102.72.134:9090 which is the CLUSTER-IP for Prometheus service)</li> <li>Left menu (hover over +) -&gt; Dashboard</li> <li>Click "Import"</li> <li>Enter the copy pasted json from https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/grafana/dashboards/nginx.json</li> <li>Click Import JSON</li> <li>Select the Prometheus data source</li> <li>Click "Import"</li> </ul> <p><img alt="Grafana Dashboard" src=../../images/grafana-dashboard1.png></p> <h2 id=exposed-metrics>Exposed metrics<a class=headerlink href=#exposed-metrics title="Permanent link"></a></h2> <p>Prometheus metrics are exposed on port 10254.</p> <h3 id=request-metrics>Request metrics<a class=headerlink href=#request-metrics title="Permanent link"></a></h3> <ul> <li> <p><code>nginx_ingress_controller_request_duration_seconds</code> Histogram\ The request processing (time elapsed between the first bytes were read from the client and the log write after the last bytes were sent to the client) time in seconds (affected by client speed).\ nginx var: <code>request_time</code></p> </li> <li> <p><code>nginx_ingress_controller_response_duration_seconds</code> Histogram\ The time spent on receiving the response from the upstream server in seconds (affected by client speed when the response is bigger than proxy buffers).\ Note: can be up to several millis bigger than the <code>nginx_ingress_controller_request_duration_seconds</code> because of the different measuring method. nginx var: <code>upstream_response_time</code></p> </li> <li> <p><code>nginx_ingress_controller_header_duration_seconds</code> Histogram\ The time spent on receiving first header from the upstream server\ nginx var: <code>upstream_header_time</code></p> </li> <li> <p><code>nginx_ingress_controller_connect_duration_seconds</code> Histogram\ The time spent on establishing a connection with the upstream server\ nginx var: <code>upstream_connect_time</code></p> </li> <li> <p><code>nginx_ingress_controller_response_size</code> Histogram\ The response length (including request line, header, and request body)\ nginx var: <code>bytes_sent</code></p> </li> <li> <p><code>nginx_ingress_controller_request_size</code> Histogram\ The request length (including request line, header, and request body)\ nginx var: <code>request_length</code></p> </li> <li> <p><code>nginx_ingress_controller_requests</code> Counter\ The total number of client requests</p> </li> <li> <p><code>nginx_ingress_controller_bytes_sent</code> Histogram\ The number of bytes sent to a client. <strong>Deprecated</strong>, use <code>nginx_ingress_controller_response_size</code>\ nginx var: <code>bytes_sent</code></p> </li> </ul> <div class=highlight><pre><span></span><code># HELP nginx_ingress_controller_bytes_sent The number of bytes sent to a client. DEPRECATED! Use nginx_ingress_controller_response_size
# TYPE nginx_ingress_controller_bytes_sent histogram
# HELP nginx_ingress_controller_connect_duration_seconds The time spent on establishing a connection with the upstream server
# TYPE nginx_ingress_controller_connect_duration_seconds nginx_ingress_controller_connect_duration_seconds
* HELP nginx_ingress_controller_header_duration_seconds The time spent on receiving first header from the upstream server
# TYPE nginx_ingress_controller_header_duration_seconds histogram
# HELP nginx_ingress_controller_request_duration_seconds The request processing time in milliseconds
# TYPE nginx_ingress_controller_request_duration_seconds histogram
# HELP nginx_ingress_controller_request_size The request length (including request line, header, and request body)
# TYPE nginx_ingress_controller_request_size histogram
# HELP nginx_ingress_controller_requests The total number of client requests.
# TYPE nginx_ingress_controller_requests counter
# HELP nginx_ingress_controller_response_duration_seconds The time spent on receiving the response from the upstream server
# TYPE nginx_ingress_controller_response_duration_seconds histogram
# HELP nginx_ingress_controller_response_size The response length (including request line, header, and request body)
# TYPE nginx_ingress_controller_response_size histogram
</code></pre></div> <h3 id=nginx-process-metrics>Nginx process metrics<a class=headerlink href=#nginx-process-metrics title="Permanent link"></a></h3> <div class=highlight><pre><span></span><code># HELP nginx_ingress_controller_nginx_process_connections current number of client connections with state {active, reading, writing, waiting}
# TYPE nginx_ingress_controller_nginx_process_connections gauge
# HELP nginx_ingress_controller_nginx_process_connections_total total number of connections with state {accepted, handled}
# TYPE nginx_ingress_controller_nginx_process_connections_total counter
# HELP nginx_ingress_controller_nginx_process_cpu_seconds_total Cpu usage in seconds
# TYPE nginx_ingress_controller_nginx_process_cpu_seconds_total counter
# HELP nginx_ingress_controller_nginx_process_num_procs number of processes
# TYPE nginx_ingress_controller_nginx_process_num_procs gauge
# HELP nginx_ingress_controller_nginx_process_oldest_start_time_seconds start time in seconds since 1970/01/01
# TYPE nginx_ingress_controller_nginx_process_oldest_start_time_seconds gauge
# HELP nginx_ingress_controller_nginx_process_read_bytes_total number of bytes read
# TYPE nginx_ingress_controller_nginx_process_read_bytes_total counter
# HELP nginx_ingress_controller_nginx_process_requests_total total number of client requests
# TYPE nginx_ingress_controller_nginx_process_requests_total counter
# HELP nginx_ingress_controller_nginx_process_resident_memory_bytes number of bytes of memory in use
# TYPE nginx_ingress_controller_nginx_process_resident_memory_bytes gauge
# HELP nginx_ingress_controller_nginx_process_virtual_memory_bytes number of bytes of memory in use
# TYPE nginx_ingress_controller_nginx_process_virtual_memory_bytes gauge
# HELP nginx_ingress_controller_nginx_process_write_bytes_total number of bytes written
# TYPE nginx_ingress_controller_nginx_process_write_bytes_total counter
</code></pre></div> <h3 id=controller-metrics>Controller metrics<a class=headerlink href=#controller-metrics title="Permanent link"></a></h3> <div class=highlight><pre><span></span><code># HELP nginx_ingress_controller_build_info A metric with a constant &#39;1&#39; labeled with information about the build.
# TYPE nginx_ingress_controller_build_info gauge
# HELP nginx_ingress_controller_check_success Cumulative number of Ingress controller syntax check operations
# TYPE nginx_ingress_controller_check_success counter
# HELP nginx_ingress_controller_config_hash Running configuration hash actually running
# TYPE nginx_ingress_controller_config_hash gauge
# HELP nginx_ingress_controller_config_last_reload_successful Whether the last configuration reload attempt was successful
# TYPE nginx_ingress_controller_config_last_reload_successful gauge
# HELP nginx_ingress_controller_config_last_reload_successful_timestamp_seconds Timestamp of the last successful configuration reload.
# TYPE nginx_ingress_controller_config_last_reload_successful_timestamp_seconds gauge
# HELP nginx_ingress_controller_ssl_certificate_info Hold all labels associated to a certificate
# TYPE nginx_ingress_controller_ssl_certificate_info gauge
# HELP nginx_ingress_controller_success Cumulative number of Ingress controller reload operations
# TYPE nginx_ingress_controller_success counter
# HELP nginx_ingress_controller_orphan_ingress Gauge reporting status of ingress orphanity, 1 indicates orphaned ingress. &#39;namespace&#39; is the string used to identify namespace of ingress, &#39;ingress&#39; for ingress name and &#39;type&#39; for &#39;no-service&#39; or &#39;no-endpoint&#39; of orphanity
# TYPE nginx_ingress_controller_orphan_ingress gauge
</code></pre></div> <h3 id=admission-metrics>Admission metrics<a class=headerlink href=#admission-metrics title="Permanent link"></a></h3> <div class=highlight><pre><span></span><code># HELP nginx_ingress_controller_admission_config_size The size of the tested configuration
# TYPE nginx_ingress_controller_admission_config_size gauge
# HELP nginx_ingress_controller_admission_render_duration The processing duration of ingresses rendering by the admission controller (float seconds)
# TYPE nginx_ingress_controller_admission_render_duration gauge
# HELP nginx_ingress_controller_admission_render_ingresses The length of ingresses rendered by the admission controller
# TYPE nginx_ingress_controller_admission_render_ingresses gauge
# HELP nginx_ingress_controller_admission_roundtrip_duration The complete duration of the admission controller at the time to process a new event (float seconds)
# TYPE nginx_ingress_controller_admission_roundtrip_duration gauge
# HELP nginx_ingress_controller_admission_tested_duration The processing duration of the admission controller tests (float seconds)
# TYPE nginx_ingress_controller_admission_tested_duration gauge
# HELP nginx_ingress_controller_admission_tested_ingresses The length of ingresses processed by the admission controller
# TYPE nginx_ingress_controller_admission_tested_ingresses gauge
</code></pre></div> <h3 id=histogram-buckets>Histogram buckets<a class=headerlink href=#histogram-buckets title="Permanent link"></a></h3> <p>You can configure buckets for histogram metrics using these command line options (here are their default values): * <code>--time-buckets=[0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]</code> * <code>--length-buckets=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]</code> * <code>--size-buckets=[10, 100, 1000, 10000, 100000, 1e+06, 1e+07]</code></p> </article> </div> </div> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> Made with <a href=https://squidfunk.github.io/mkdocs-material/ target=_blank rel=noopener> Material for MkDocs </a> </div> </div> </div> </footer> </div> <div class=md-dialog data-md-component=dialog> <div class="md-dialog__inner md-typeset"></div> </div> <script id=__config type=application/json>{"base": "../..", "features": ["navigation.tabs", "navigation.tabs.sticky", "navigation.instant", "navigation.sections"], "search": "../../assets/javascripts/workers/search.f886a092.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script> <script src=../../assets/javascripts/bundle.aecac24b.min.js></script> </body> </html>