Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #598 from Ygnas/gateway-api-state-metrics
Browse files Browse the repository at this point in the history
Gateway api state metrics
  • Loading branch information
david-martin authored Sep 27, 2023
2 parents f7c4fab + dbd9106 commit 3bae2e8
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 113 deletions.
84 changes: 84 additions & 0 deletions config/prometheus-for-federation/grafana_deployment_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,87 @@
value:
name: grafana-mgc-metrics
mountPath: /grafana-dashboard-definitions/0/grafana-mgc-metrics
- op: add
path: /spec/template/spec/volumes/-
value:
name: grafana-gatewayclasses
configMap:
defaultMode: 420
name: grafana-gatewayclasses
- op: add
path: /spec/template/spec/volumes/-
value:
name: grafana-gateways
configMap:
defaultMode: 420
name: grafana-gateways
- op: add
path: /spec/template/spec/volumes/-
value:
name: grafana-httproutes
configMap:
defaultMode: 420
name: grafana-httproutes
- op: add
path: /spec/template/spec/volumes/-
value:
name: grafana-grpcroutes
configMap:
defaultMode: 420
name: grafana-grpcroutes
- op: add
path: /spec/template/spec/volumes/-
value:
name: grafana-tlsroutes
configMap:
defaultMode: 420
name: grafana-tlsroutes
- op: add
path: /spec/template/spec/volumes/-
value:
name: grafana-tcproutes
configMap:
defaultMode: 420
name: grafana-tcproutes
- op: add
path: /spec/template/spec/volumes/-
value:
name: grafana-udproutes
configMap:
defaultMode: 420
name: grafana-udproutes
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: grafana-gatewayclasses
mountPath: /grafana-dashboard-definitions/0/grafana-gatewayclasses
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: grafana-gateways
mountPath: /grafana-dashboard-definitions/0/grafana-gateways
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: grafana-httproutes
mountPath: /grafana-dashboard-definitions/0/grafana-httproutes
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: grafana-grpcroutes
mountPath: /grafana-dashboard-definitions/0/grafana-grpcroutes
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: grafana-tlsroutes
mountPath: /grafana-dashboard-definitions/0/grafana-tlsroutes
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: grafana-tcproutes
mountPath: /grafana-dashboard-definitions/0/grafana-tcpcroutes
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: grafana-udproutes
mountPath: /grafana-dashboard-definitions/0/grafana-udproutes
26 changes: 26 additions & 0 deletions config/prometheus-for-federation/ksm_clusterrole_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
- op: add
path: /rules/-
value:
apiGroups:
- "apiextensions.k8s.io"
resources:
- customresourcedefinitions
verbs:
- list
- watch
- op: add
path: /rules/-
value:
apiGroups:
- "gateway.networking.k8s.io"
resources:
- gateways
- gatewayclasses
- httproutes
- grpcroutes
- tcproutes
- tlsroutes
- udproutes
verbs:
- list
- watch
21 changes: 21 additions & 0 deletions config/prometheus-for-federation/ksm_deployment_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- op: replace
path: /spec/template/spec/containers/0/image
value: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.9.2
- op: add
path: /spec/template/spec/volumes
value:
- name: custom-resource-state
configMap:
defaultMode: 420
name: custom-resource-state
- op: add
path: /spec/template/spec/containers/0/volumeMounts
value:
- name: custom-resource-state
mountPath: /custom-resource-state
- op: add
path: /spec/template/spec/containers/0/args/-
value: --custom-resource-state-config-file
- op: add
path: /spec/template/spec/containers/0/args/-
value: /custom-resource-state/custom-resource-state.yaml
14 changes: 14 additions & 0 deletions config/prometheus-for-federation/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: Kustomization

resources:
- github.com/prometheus-operator/kube-prometheus?ref=release-0.11
- github.com/Kuadrant/gateway-api-state-metrics?ref=main
- github.com/Kuadrant/gateway-api-state-metrics/config/examples/dashboards?ref=main
- grafana_ingress.yaml
# To scrape istio metrics, 3 configurations are required:
# 1. Envoy metrics directly from the istio ingress gateway pod
Expand Down Expand Up @@ -65,6 +67,18 @@ patches:
# Patch grafana deployment to include dashboard configmaps
patchesJson6902:
- target:
group: apps
version: v1
kind: Deployment
name: kube-state-metrics
path: ksm_deployment_patch.yaml
- target:
group: rbac.authorization.k8s.io
version: v1
kind: ClusterRole
name: kube-state-metrics
path: ksm_clusterrole_patch.yaml
- target:
group: apps
version: v1
Expand Down
103 changes: 0 additions & 103 deletions docs/how-to/metrics-federation.md

This file was deleted.

58 changes: 57 additions & 1 deletion docs/how-to/metrics-walkthrough.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Introduction

This walkthrough shows how to install a metrics federation stack locally and query Istio metrics from the hub.

![arch](../images/metrics/metrics-federation.png)

## Installation and Configuration of Metrics
This document will guide you in installing metrics for your application and provide directions on where to access them. Additionally, it will include dashboards set up to display these metrics.

Expand Down Expand Up @@ -36,6 +42,44 @@ To generate traffic to the application, use `curl` as follows:
while true; do curl -k https://$MGC_SUB_DOMAIN && sleep 5; done
```

### Accessing the Thanos UI

1. Access the Thanos UI by clicking or entering the provided URL for the Grafana UI in your web browser.

```
https://thanos-query.172.31.0.2.nip.io
```

2. In the Thanos UI query box, enter the below query and press 'Execute'

```
sum(rate(container_cpu_usage_seconds_total{namespace="monitoring",container="prometheus"}[5m]))
```

You should see a response in the table view.
In the Graph view you should see some data over time as well.

![arch](../images/metrics/metrics-federation-example-data.png)

```
sum(rate(istio_requests_total{}[5m])) by(destination_workload)
```

In the graph view you should see something that looks like the graph below.
This shows the rate of requests (per second) for each Isito workload.
In this case, there is 1 workload, balanced across 2 clusters.

![arch](../images/metrics/metrics-federation-traffic-data.png)

To see the rate of requests per cluster (actually per pod across all clusters), the below query can be used.
Over long periods of time, this graph can show traffic load balancing between application instances.

```
sum(rate(istio_requests_total{}[5m])) by(pod)
```

![arch](../images/metrics/metrics-federation-traffic-data-per-pod.png)

### Accessing the Grafana Dashboard
To view the operational metrics and status, proceed with the following steps:

Expand All @@ -48,7 +92,7 @@ https://grafana.172.31.0.2.nip.io
2. Navigate to the included Grafana Dashboard

Using the left sidebar in the Grafana UI, navigate to `Dashboards > Browse` and select either the `Istio Workload Dashboard` or `MGC SRE Dashboard`.
Using the left sidebar in the Grafana UI, navigate to `Dashboards > Browse` and select the `Istio Workload Dashboard`, `MGC SRE Dashboard` or any of the following `Gateway Api State` dashboards.

![arch](../images/metrics/metrics-federation-grafana-dashboard-3.png)

Expand All @@ -60,6 +104,18 @@ The `MGC SRE Dashboard` displays real-time insights and visualizations of resour

![arch](../images/metrics/metrics-federation-grafana-dashboard-4.png)

The `Gateway API State / Gateways` provides real-time insights and visualizations for Gateways. It offers information about gateway listeners, listener status, gateway status, addresses, and attached routes

![arch](../images/metrics/metrics-federation-grafana-dashboard-5.png)

The `Gateway API State / GatewayClasses` provides insights into Gateways organized by their respective Gateway Classes. It offers information about GatewayClasses and the supported features for each class.

![arch](../images/metrics/metrics-federation-grafana-dashboard-6.png)

The `Gateway API State / HTTPRoutes` or any of the remaining routes focuses on their `Routes` and provides insights into their configuration. It displays their targeted parent references, and attached parent references, offering a detailed view of how these routes are structured and associated with their respective resources.

![arch](../images/metrics/metrics-federation-grafana-dashboard-7.png)

The Grafana dashboard will provide you with real-time insights and visualizations of your gateway's performance and metrics.

By utilizing the Grafana dashboard, you can effectively monitor the health and behavior of your system, making informed decisions based on the displayed data. This monitoring capability enables you to proactively identify and address any potential issues to ensure the smooth operation of your environment.
Expand Down
Binary file modified docs/images/metrics/metrics-federation-grafana-dashboard-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/metrics/metrics-federation-grafana-dashboard-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3bae2e8

Please sign in to comment.