github.com/projectcontour/contour@v1.28.2/site/content/docs/main/guides/prometheus.md (about) 1 --- 2 title: Collecting Metrics with Prometheus 3 --- 4 5 <div id="toc" class="navigation"></div> 6 7 Contour and Envoy expose metrics that can be scraped with Prometheus. By 8 default, annotations to gather them are in all the `deployment` yamls and they 9 should work out of the box with most configurations. 10 11 ## Envoy Metrics 12 13 Envoy typically [exposes metrics](https://www.envoyproxy.io/docs/envoy/v1.15.0/configuration/http/http_conn_man/stats#config-http-conn-man-stats) through an endpoint on its admin interface. To 14 avoid exposing the entire admin interface to Prometheus (and other workloads in 15 the cluster), Contour configures a static listener that sends traffic to the 16 stats endpoint and nowhere else. 17 18 Envoy supports Prometheus-compatible `/stats/prometheus` endpoint for metrics on 19 port `8002`. 20 21 ## Contour Metrics 22 23 Contour exposes a Prometheus-compatible `/metrics` endpoint that defaults to listening on port 8000. This can be configured by using the `--http-address` and `--http-port` flags for the `serve` command. 24 25 **Note:** the `Service` deployment manifest when installing Contour must be updated to represent the same port as the configured flag. 26 27 **The metrics endpoint exposes the following metrics:** 28 29 {{% metrics-table %}} 30 31 ## Sample Deployment 32 33 In the `/examples` directory there are example deployment files that can be used to spin up an example environment. 34 All deployments there are configured with annotations for prometheus to scrape by default, so it should be possible to utilize any of them with the following quickstart example instructions. 35 36 ### Deploy Prometheus 37 38 A sample deployment of Prometheus and Alertmanager is provided that uses temporary storage. This deployment can be used for testing and development, but might not be suitable for all environments. 39 40 #### Stateful Deployment 41 42 A stateful deployment of Prometheus should use persistent storage with [Persistent Volumes and Persistent Volume Claims][1] to maintain a correlation between a data volume and the Prometheus Pod. 43 Persistent volumes can be static or dynamic and depends on the backend storage implementation utilized in environment in which the cluster is deployed. For more information, see the [Kubernetes documentation on types of persistent volumes][2]. 44 45 #### Quick start 46 47 ```sh 48 # Deploy 49 $ kubectl apply -f examples/prometheus 50 ``` 51 52 #### Access the Prometheus web UI 53 54 ```sh 55 $ kubectl -n projectcontour-monitoring port-forward $(kubectl -n projectcontour-monitoring get pods -l app=prometheus -l component=server -o jsonpath='{.items[0].metadata.name}') 9090:9090 56 ``` 57 58 then go to `http://localhost:9090` in your browser. 59 60 #### Access the Alertmanager web UI 61 62 ```sh 63 $ kubectl -n projectcontour-monitoring port-forward $(kubectl -n projectcontour-monitoring get pods -l app=prometheus -l component=alertmanager -o jsonpath='{.items[0].metadata.name}') 9093:9093 64 ``` 65 66 then go to `http://localhost:9093` in your browser. 67 68 ### Deploy Grafana 69 70 A sample deployment of Grafana is provided that uses temporary storage. 71 72 #### Quick start 73 74 ```sh 75 # Deploy 76 $ kubectl apply -f examples/grafana/ 77 78 # Create secret with grafana credentials 79 $ kubectl create secret generic grafana -n projectcontour-monitoring \ 80 --from-literal=grafana-admin-password=admin \ 81 --from-literal=grafana-admin-user=admin 82 ``` 83 84 #### Access the Grafana UI 85 86 ```sh 87 $ kubectl port-forward $(kubectl get pods -l app=grafana -n projectcontour-monitoring -o jsonpath='{.items[0].metadata.name}') 3000 -n projectcontour-monitoring 88 ``` 89 90 then go to `http://localhost:3000` in your browser. 91 The username and password are from when you defined the Grafana secret in the previous step. 92 93 [1]: https://kubernetes.io/docs/concepts/storage/persistent-volumes/ 94 [2]: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#types-of-persistent-volumes