Skip to content

Commit

Permalink
Add user guide for Gateway API State Metrics
Browse files Browse the repository at this point in the history
Signed-off-by: David Martin <davmarti@redhat.com>
  • Loading branch information
david-martin committed Sep 7, 2023
1 parent 2e6211a commit 75f4bbe
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions docs/latest/user/gateway-api-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Gateway API Metrics

Resource metrics for Gateway API objects are available using the [Gateway API State Metrics](https://github.com/Kuadrant/gateway-api-state-metrics) project.
The project also provides example dashboard for visualising the metrics using Grafana, and example alerts using Prometheus & Alertmanager.

## Prerequisites

Follow the steps from the [Quickstart Guide](quickstart.md) to install Envoy Gateway and the example manifest.
Before proceeding, you should be able to query the example backend using HTTP.

[Kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/) is used to install the metrics stack.
Install Kustomize by following the instructions on the kustomize site.
Once Kustomize is installed, run the following commands to install the metrics stack, with the Gateway API State Metrics configuration, on your kubernetes cluster.

```shell
kustomize build github.com/kuadrant/gateway-api-state-metrics.git/examples/kube-prometheus | docker run --rm -i ryane/kfilt -i kind=CustomResourceDefinition | kubectl apply --server-side -f -
kustomize build github.com/kuadrant/gateway-api-state-metrics.git/examples/kube-prometheus | docker run --rm -i ryane/kfilt -x kind=CustomResourceDefinition | kubectl apply -f -
```

## Metrics and Alerts

To access the Prometheus UI, wait for the statefulset to be ready, then use the port-forward command:

```shell
# This first command may fail if the statefulset has not been created yet.
# In that case, try again until you get a message like 'Waiting for 2 pods to be ready...'
# or 'statefulset rolling update complete 2 pods...'
kubectl -n monitoring rollout status --watch --timeout=5m statefulset/prometheus-k8s
kubectl -n monitoring port-forward service/prometheus-k8s 9090:9090 > /dev/null &
```

Navigate to [http://localhost:9090](http://localhost:9090).
Metrics can be queried from the 'Graph' tab e.g. `gatewayapi_gateway_created`
See the [Gateway API State Metrics README](https://github.com/Kuadrant/gateway-api-state-metrics/tree/main#metrics) for the full list of Gateway API metrics available.

Alerts can be see in the 'Alerts' tab.
Gateway API specific alerts will be grouped under the 'gateway-api.rules' heading.

***Note:*** Alerts are defined in a PrometheusRules custom resource in the 'monitoring' namespace. You can modify the alert rules by updating this resource.

## Dashboards

To view the dashboards in Grafana, wait for the deployment to be ready, then use the port-forward command:

```shell
kubectl -n monitoring wait --timeout=5m deployment/grafana --for=condition=Available
kubectl -n monitoring port-forward service/grafana 3000:3000 > /dev/null &
```

Navigate to [http://localhost:3000](http://localhost:3000) and sign in with admin/admin.
The Gateway API State dashboards will be available in the 'Default' folder and tagged with 'gateway-api'.
See the [Gateway API State Metrics README](https://github.com/Kuadrant/gateway-api-state-metrics/tree/main#dashboards) for further information on available dashboards.

***Note:*** Dashboards are loaded from configmaps. You can modify the dashboards in the Grafana UI, however you will need to export them from the UI and update the json in the configmaps to persist changes.
1 change: 1 addition & 0 deletions docs/latest/user_docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ Learn how to deploy, use, and operate Envoy Gateway.
user/gateway-address
user/gatewayapi-support
user/proxy-observability
user/gateway-api-metrics
user/multicluster-service

0 comments on commit 75f4bbe

Please sign in to comment.