You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/api-management/how-to-configure-local-metrics-logs.md
+29-28Lines changed: 29 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
-
title: Configure local metrics and logs for Azure API Management self-hosted gateway | Microsoft Docs
2
+
title: Configure Local Metrics and Logs for Azure API Management Self-Hosted Gateway | Microsoft Docs
3
3
description: Learn how to configure local metrics and logs for Azure API Management self-hosted gateway on a Kubernetes cluster.
4
4
services: api-management
5
5
author: dlepow
6
6
manager: gwallace
7
7
ms.service: azure-api-management
8
8
ms.topic: how-to
9
-
ms.date: 04/12/2024
9
+
ms.date: 10/7/2025
10
10
ms.author: danlep
11
11
---
12
12
@@ -18,14 +18,14 @@ This article provides details for configuring local metrics and logs for the [se
18
18
19
19
## Metrics
20
20
21
-
The self-hosted gateway supports [StatsD](https://github.com/statsd/statsd), which has become a unifying protocol for metrics collection and aggregation. This section walks through the steps for deploying StatsD to Kubernetes, configuring the gateway to emit metrics via StatsD, and using [Prometheus](https://prometheus.io/) to monitor the metrics.
21
+
The self-hosted gateway supports [StatsD](https://github.com/statsd/statsd), which is a unifying protocol for metrics collection and aggregation. This section walks through the steps for deploying StatsD to Kubernetes, configuring the gateway to emit metrics via StatsD, and using [Prometheus](https://prometheus.io/) to monitor the metrics.
22
22
23
23
### Deploy StatsD and Prometheus to the cluster
24
24
25
-
The following sample YAML configuration deploys StatsD and Prometheus to the Kubernetes cluster where a self-hosted gateway is deployed. It also creates a [Service](https://kubernetes.io/docs/concepts/services-networking/service/) for each. The self-hosted gateway then publishes metrics to the StatsD Service. We'll access the Prometheus dashboard via its Service.
25
+
The following sample YAML configuration deploys StatsD and Prometheus to the Kubernetes cluster where a self-hosted gateway is deployed. It also creates a [Service](https://kubernetes.io/docs/concepts/services-networking/service/) for each. The self-hosted gateway then publishes metrics to the StatsD Service. You access the Prometheus dashboard via its Service.
26
26
27
27
> [!NOTE]
28
-
> The following example pulls public container images from Docker Hub. We recommend that you set up a pull secret to authenticate using a Docker Hub account instead of making an anonymous pull request. To improve reliability when working with public content, import and manage the images in a private Azure Container Registry. [Learn more about working with public images.](/azure/container-registry/buffer-gate-public-content)
28
+
> The following example pulls public container images from Docker Hub. Set up a pull secret to authenticate using a Docker Hub account instead of making an anonymous pull request. To improve reliability when working with public content, import and manage the images in a private Azure Container Registry. [Learn more about working with public images.](/azure/container-registry/buffer-gate-public-content)
29
29
30
30
```yaml
31
31
apiVersion: v1
@@ -125,15 +125,15 @@ Save the configurations to a file named `metrics.yaml`. Use the following comman
125
125
kubectl apply -f metrics.yaml
126
126
```
127
127
128
-
Once the deployment finishes, run the following command to check the Pods are running. Your pod name will be different.
128
+
Once the deployment finishes, run the following command to check the Pods are running. Your pod name is different.
129
129
130
130
```console
131
131
kubectl get pods
132
132
NAME READY STATUS RESTARTS AGE
133
133
sputnik-metrics-f6d97548f-4xnb7 2/2 Running 0 1m
134
134
```
135
135
136
-
Run the below command to check the `services` are running. Take a note of the `CLUSTER-IP` and `PORT` of the StatsD Service, which we use later. You can visit the Prometheus dashboard using its `EXTERNAL-IP` and `PORT`.
136
+
Run the following command to check the `services` are running. Take a note of the `CLUSTER-IP` and `PORT` of the StatsD Service, which you use later. You can visit the Prometheus dashboard using its `EXTERNAL-IP` and `PORT`.
### Configure the self-hosted gateway to emit metrics
146
146
147
-
Now that both StatsD and Prometheus are deployed, we can update the configurations of the self-hosted gateway to start emitting metrics through StatsD. The feature can be enabled or disabled using the `telemetry.metrics.local` key in the ConfigMap of the self-hosted gateway Deployment with additional options. The following are the available options:
147
+
Now that both StatsD and Prometheus are deployed, you can update the configurations of the self-hosted gateway to start emitting metrics through StatsD. Use the `telemetry.metrics.local` key in the ConfigMap of the self-hosted gateway Deployment to enable or disable this feature. You can also set additional options. The following options are available:
Now we have everything deployed and configured, the self-hosted gateway should report metrics via StatsD. Prometheus then picks up the metrics from StatsD. Go to the Prometheus dashboard using the `EXTERNAL-IP` and `PORT` of the Prometheus Service.
185
+
Now that you deployed and configured everything, the self-hosted gateway reports metrics through StatsD. Prometheus then picks up the metrics from StatsD. Go to the Prometheus dashboard by using the `EXTERNAL-IP` and `PORT` of the Prometheus Service.
186
186
187
-
Make some API calls through the self-hosted gateway, if everything is configured correctly, you should be able to view below metrics:
187
+
Make some API calls through the self-hosted gateway. If everything is configured correctly, you can view the following metrics:
188
188
189
189
| Metric | Description |
190
190
| ------------- | ------------- |
@@ -195,26 +195,26 @@ Make some API calls through the self-hosted gateway, if everything is configured
195
195
196
196
## Logs
197
197
198
-
The self-hosted gateway outputs logs to `stdout` and `stderr` by default. You can easily view the logs using the following command:
198
+
By default, the self-hosted gateway outputs logs to `stdout` and `stderr`. You can easily view the logs by using the following command:
199
199
200
200
```console
201
201
kubectl logs <pod-name>
202
202
```
203
203
204
-
If your self-hosted gateway is deployed in Azure Kubernetes Service, you can enable [Azure Monitor for containers](/azure/azure-monitor/containers/container-insights-overview) to collect `stdout` and `stderr` from your workloads and view the logs in Log Analytics.
204
+
If you deploy your self-hosted gateway in Azure Kubernetes Service, you can enable [Azure Monitor for containers](/azure/azure-monitor/containers/container-insights-overview) to collect `stdout` and `stderr` from your workloads and view the logs in Log Analytics.
205
205
206
-
The self-hosted gateway also supports many protocols including `localsyslog`, `rfc5424`, and `journal`. The following table summarizes all the options supported.
206
+
The self-hosted gateway also supports many protocols, including `localsyslog`, `rfc5424`, and `journal`. The following table summarizes all the supported options.
207
207
208
208
| Field | Default | Description |
209
209
| ------------- | ------------- | ------------- |
210
210
| telemetry.logs.std | `text` | Enables logging to standard streams. Value can be `none`, `text`, `json` |
211
211
| telemetry.logs.local | `auto` | Enables local logging. Value can be `none`, `auto`, `localsyslog`, `rfc5424`, `journal`, `json` |
212
212
| telemetry.logs.local.localsyslog.endpoint | n/a | Specifies local syslog endpoint. For details, see [using local syslog logs](#using-local-syslog-logs). |
| telemetry.logs.local.json.endpoint | 127.0.0.1:8888 | Specifies UDP endpoint that accepts JSON data: file path, IP:port, or hostname:port.
217
+
| telemetry.logs.local.json.endpoint | 127.0.0.1:8888 | Specifies UDP endpoint that accepts JSON data: file path, IP:port, or hostname:port. |
218
218
219
219
Here's a sample configuration of local logging:
220
220
@@ -234,13 +234,13 @@ Here's a sample configuration of local logging:
234
234
235
235
#### Known limitations
236
236
237
-
- We only support up to 3072 bytes of request/response payload for local diagnostics. Anything above, may break JSON format due to chunking.
237
+
- The local diagnostics feature supports up to 3,072 bytes of request and response payload. If the payload size exceeds this limit, chunking might break the JSON format.
238
238
239
239
### Using local syslog logs
240
240
241
241
#### Configuring gateway to stream logs
242
242
243
-
When using local syslog as a destination for logs, the runtime needs to allow streaming logs to the destination. For Kubernetes, a volume needs to be mounted which that matches the destination.
243
+
When you use local syslog as a destination for logs, the runtime needs to allow streaming logs to the destination. For Azure Kubernetes Service, you need to mount a volume that matches the destination.
244
244
245
245
Given the following configuration:
246
246
@@ -294,17 +294,17 @@ spec:
294
294
295
295
#### Consuming local syslog logs on Azure Kubernetes Service (AKS)
296
296
297
-
When configuring to use local syslog on Azure Kubernetes Service, you can choose two ways to explore the logs:
297
+
When you configure local syslog on Azure Kubernetes Service, you can choose two ways to explore the logs:
298
298
299
299
- Use [Syslog collection with Container Insights](/azure/azure-monitor/containers/container-insights-syslog)
300
-
- Connect & explore logs on the worker nodes
300
+
- Connect and explore logs on the worker nodes
301
301
302
302
#### Consuming logs from worker nodes
303
303
304
-
You can easily consume them by getting access to the worker nodes:
304
+
You can easily consume logs by getting access to the worker nodes:
305
305
306
-
1. Create an SSH connection to the node ([docs](/azure/aks/node-access))
307
-
2. Logs can be found under `host/var/log/syslog`
306
+
1. Create an SSH connection to the node ([docs](/azure/aks/node-access)).
307
+
1. Find logs under `host/var/log/syslog`.
308
308
309
309
For example, you can filter all syslogs to just the ones from the self-hosted gateway:
0 commit comments