... | @@ -64,4 +64,7 @@ from prometheus_flask_exporter import PrometheusMetrics |
... | @@ -64,4 +64,7 @@ from prometheus_flask_exporter import PrometheusMetrics |
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
PrometheusMetrics(app)
|
|
PrometheusMetrics(app)
|
|
```
|
|
```
|
|
Now we need to make Prometheus aware of this new target. For this we will use ServiceMonitor object, that will get deployed into the same namespace as our webapp and will monitor a service given by the `selector` property. By default, Prometheus only monitors objects in the same namespace, we need to add `serviceMonitorNamespaceSelector` that will match common labels on all namespaces we want to monitor. |
|
Now we need to make Prometheus aware of this new target. For this we will use ServiceMonitor object, that will get deployed into the same namespace as our webapp and will monitor a service given by the `selector` property. By default, Prometheus only monitors objects in the same namespace, we need to add `serviceMonitorNamespaceSelector` that will match common labels on all namespaces we want to monitor.
|
|
\ No newline at end of file |
|
To export metrics from `frontend` we will use [nginx-prometheus-exporter](https://github.com/nginxinc/nginx-prometheus-exporter). Since nginx exporter is a docker container, it is easiest to add it to our frontend pod as a [sidecar](https://medium.com/bb-tutorials-and-thoughts/kubernetes-learn-sidecar-container-pattern-6d8c21f873d). Next we edit our `nginx.conf` to return [stub-stats](http://nginx.org/en/docs/http/ngx_http_stub_status_module.html) at specified port, and that should be it.
|
|
|
|
|
|
|
|
#### Preview |