Skip to content

Commit ba3a2a5

Browse files
committed
Line edits4
1 parent c2dc918 commit ba3a2a5

1 file changed

Lines changed: 29 additions & 28 deletions

File tree

articles/api-management/how-to-configure-local-metrics-logs.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
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
33
description: Learn how to configure local metrics and logs for Azure API Management self-hosted gateway on a Kubernetes cluster.
44
services: api-management
55
author: dlepow
66
manager: gwallace
77
ms.service: azure-api-management
88
ms.topic: how-to
9-
ms.date: 04/12/2024
9+
ms.date: 10/7/2025
1010
ms.author: danlep
1111
---
1212

@@ -18,14 +18,14 @@ This article provides details for configuring local metrics and logs for the [se
1818

1919
## Metrics
2020

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.
2222

2323
### Deploy StatsD and Prometheus to the cluster
2424

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.
2626

2727
> [!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)
2929
3030
```yaml
3131
apiVersion: v1
@@ -125,15 +125,15 @@ Save the configurations to a file named `metrics.yaml`. Use the following comman
125125
kubectl apply -f metrics.yaml
126126
```
127127

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.
129129

130130
```console
131131
kubectl get pods
132132
NAME READY STATUS RESTARTS AGE
133133
sputnik-metrics-f6d97548f-4xnb7 2/2 Running 0 1m
134134
```
135135

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`.
137137

138138
```console
139139
kubectl get services
@@ -144,7 +144,7 @@ sputnik-metrics-statsd NodePort 10.0.41.179 <none> 8125:3
144144

145145
### Configure the self-hosted gateway to emit metrics
146146

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:
148148

149149
| Field | Default | Description |
150150
| ------------- | ------------- | ------------- |
@@ -168,23 +168,23 @@ data:
168168
telemetry.metrics.local.statsd.tag-format: "dogStatsD"
169169
```
170170

171-
Update the YAML file of the self-hosted gateway deployment with the above configurations and apply the changes using the below command:
171+
Update the YAML file of the self-hosted gateway deployment with the preceding configurations and apply the changes with the following command:
172172

173173
```console
174174
kubectl apply -f <file-name>.yaml
175175
```
176176

177-
To pick up the latest configuration changes, restart the gateway deployment using the below command:
177+
To pick up the latest configuration changes, restart the gateway deployment with the following command:
178178

179179
```console
180180
kubectl rollout restart deployment/<deployment-name>
181181
```
182182

183183
### View the metrics
184184

185-
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.
186186

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:
188188

189189
| Metric | Description |
190190
| ------------- | ------------- |
@@ -195,26 +195,26 @@ Make some API calls through the self-hosted gateway, if everything is configured
195195

196196
## Logs
197197

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:
199199

200200
```console
201201
kubectl logs <pod-name>
202202
```
203203

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.
205205

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.
207207

208208
| Field | Default | Description |
209209
| ------------- | ------------- | ------------- |
210210
| telemetry.logs.std | `text` | Enables logging to standard streams. Value can be `none`, `text`, `json` |
211211
| telemetry.logs.local | `auto` | Enables local logging. Value can be `none`, `auto`, `localsyslog`, `rfc5424`, `journal`, `json` |
212212
| telemetry.logs.local.localsyslog.endpoint | n/a | Specifies local syslog endpoint. For details, see [using local syslog logs](#using-local-syslog-logs). |
213-
| telemetry.logs.local.localsyslog.facility | n/a | Specifies local syslog [facility code](https://en.wikipedia.org/wiki/Syslog#Facility). Example: `7`
213+
| telemetry.logs.local.localsyslog.facility | n/a | Specifies local syslog [facility code](https://en.wikipedia.org/wiki/Syslog#Facility). Example: `7` |
214214
| telemetry.logs.local.rfc5424.endpoint | n/a | Specifies rfc5424 endpoint. |
215215
| telemetry.logs.local.rfc5424.facility | n/a | Specifies facility code per [rfc5424](https://tools.ietf.org/html/rfc5424). Example: `7` |
216216
| telemetry.logs.local.journal.endpoint | n/a | Specifies journal endpoint. |
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.
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. |
218218

219219
Here's a sample configuration of local logging:
220220

@@ -234,13 +234,13 @@ Here's a sample configuration of local logging:
234234

235235
#### Known limitations
236236

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.
238238

239239
### Using local syslog logs
240240

241241
#### Configuring gateway to stream logs
242242

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.
244244

245245
Given the following configuration:
246246

@@ -294,17 +294,17 @@ spec:
294294

295295
#### Consuming local syslog logs on Azure Kubernetes Service (AKS)
296296

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:
298298

299299
- 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
301301

302302
#### Consuming logs from worker nodes
303303

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:
305305

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`.
308308

309309
For example, you can filter all syslogs to just the ones from the self-hosted gateway:
310310

@@ -313,11 +313,12 @@ $ cat host/var/log/syslog | grep "apimuser"
313313
May 15 05:54:20 aks-agentpool-43853532-vmss000000 apimuser[8]: Timestamp=2023-05-15T05:54:20.0445178Z, isRequestSuccess=True, totalTime=290, category=GatewayLogs, callerIpAddress=141.134.132.243, timeGenerated=2023-05-15T05:54:20.0445178Z, region=Repro, correlationId=aaaa0000-bb11-2222-33cc-444444dddddd, method=GET, url="http://20.126.242.200/echo/resource?param1\=sample", backendResponseCode=200, responseCode=200, responseSize=628, cache=none, backendTime=287, apiId=echo-api, operationId=retrieve-resource, apimSubscriptionId=master, clientProtocol=HTTP/1.1, backendProtocol=HTTP/1.1, apiRevision=1, backendMethod=GET, backendUrl="http://echoapi.cloudapp.net/api/resource?param1\=sample"
314314
May 15 05:54:21 aks-agentpool-43853532-vmss000000 apimuser[8]: Timestamp=2023-05-15T05:54:21.1189171Z, isRequestSuccess=True, totalTime=150, category=GatewayLogs, callerIpAddress=141.134.132.243, timeGenerated=2023-05-15T05:54:21.1189171Z, region=Repro, correlationId=bbbb1111-cc22-3333-44dd-555555eeeeee, method=GET, url="http://20.126.242.200/echo/resource?param1\=sample", backendResponseCode=200, responseCode=200, responseSize=628, cache=none, backendTime=148, apiId=echo-api, operationId=retrieve-resource, apimSubscriptionId=master, clientProtocol=HTTP/1.1, backendProtocol=HTTP/1.1, apiRevision=1, backendMethod=GET, backendUrl="http://echoapi.cloudapp.net/api/resource?param1\=sample"
315315
```
316+
316317
> [!NOTE]
317-
> If you have changed the root with `chroot`, for example `chroot /host`, then the above path needs to reflect that change.
318+
> If you change the root with `chroot`, for example `chroot /host`, then the above path needs to reflect that change.
318319

319320
## Related content
320321

321-
* Learn about the [observability capabilities of the Azure API Management gateways](observability.md).
322-
* Learn more about the [Azure API Management self-hosted gateway](self-hosted-gateway-overview.md).
323-
* Learn about [configuring and persisting logs in the cloud](how-to-configure-cloud-metrics-logs.md).
322+
- Learn about the [observability capabilities of the Azure API Management gateways](observability.md).
323+
- Learn more about the [Azure API Management self-hosted gateway](self-hosted-gateway-overview.md).
324+
- Learn about [configuring and persisting logs in the cloud](how-to-configure-cloud-metrics-logs.md).

0 commit comments

Comments
 (0)