# Amazon CloudWatch

imgproxy can send its metrics to Amazon CloudWatch. To use this feature, do the following:

1. Set the `IMGPROXY_CLOUD_WATCH_SERVICE_NAME` environment variable. imgproxy will use the value of this variable as a value for the `ServiceName` dimension.
2. [Set up the necessary credentials](#set-up-credentials) to grant access to CloudWatch.
3. _(optional)_ Specify the AWS region with `IMGPROXY_CLOUD_WATCH_REGION` or `AWS_REGION`. Default: `us-west-1`
4. _(optional)_ Set the `IMGPROXY_CLOUD_WATCH_NAMESPACE` environment variable to be the desired CloudWatch namespace. Default: `imgproxy`

imgproxy sends the following metrics to CloudWatch:

* `RequestsInProgress`: the number of requests currently in progress
* `ImagesInProgress`: the number of images currently in progress
* `WorkersUtilization`, `ConcurrencyUtilization`: the percentage of imgproxy's workers utilization. Calculated as `RequestsInProgress / IMGPROXY_WORKERS * 100`
* `BufferSize`: a summary of the download buffers sizes (in bytes)
* `BufferDefaultSize`: calibrated default buffer size (in bytes)
* `BufferMaxSize`: calibrated maximum buffer size (in bytes)
* `VipsMemory`: libvips memory usage (in bytes)
* `VipsMaxMemory`: libvips maximum memory usage (in bytes)
* `VipsAllocs`: the number of active vips allocations

### Set up credentials

There are three ways to specify your AWS credentials. The credentials need to have rights to write metrics to CloudWatch:

#### IAM Roles

If you're running imgproxy on an Amazon Web Services platform, you can use IAM roles to to get the security credentials to make calls to AWS CloudWatch.

* **Elastic Container Service (ECS):** Assign an [IAM role to a task](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html).
* **Elastic Kubernetes Service (EKS):** Assign a [service account to a pod](https://docs.aws.amazon.com/eks/latest/userguide/pod-configuration.html).
* **Elastic Beanstalk:** Assign an [IAM role to an instance](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/iam-instanceprofile.html).

#### Environment variables

You can specify an AWS Access Key ID and a Secret Access Key by setting the standard `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables.

``` bash
AWS_ACCESS_KEY_ID=my_access_key AWS_SECRET_ACCESS_KEY=my_secret_key imgproxy

# same for Docker
docker run -e AWS_ACCESS_KEY_ID=my_access_key -e AWS_SECRET_ACCESS_KEY=my_secret_key -it ghcr.io/imgproxy/imgproxy
```

#### Shared credentials file

Alternatively, you can create the `.aws/credentials` file in your home directory with the following content:

```ini
[default]
aws_access_key_id = %access_key_id
aws_secret_access_key = %secret_access_key
```

---

## Navigation

- [Getting started](/3.26.x/getting_started)
- [imgproxy Pro](https://imgproxy.net#pro)
- [Installation](/3.26.x/installation)
- [Configuration](/3.26.x/category/configuration)
  - [Configuration options](/3.26.x/configuration/options)
  - [Loading environment variables](/3.26.x/configuration/loading_environment_variables)
- [Usage](/3.26.x/category/usage)
  - [Processing an image](/3.26.x/usage/processing)
  - [Getting an image info](/3.26.x/usage/getting_info)
  - [Signing a URL](/3.26.x/usage/signing_url)
  - [Encrypting a source URL](/3.26.x/usage/encrypting_source_url)
  - [Presets](/3.26.x/usage/presets)
- [Features](/3.26.x/category/features)
  - [Watermark](/3.26.x/features/watermark)
  - [Object detection](/3.26.x/features/object_detection)
  - [Autoquality](/3.26.x/features/autoquality)
  - [Best format](/3.26.x/features/best_format)
  - [Chained pipelines](/3.26.x/features/chained_pipelines)
- [Image sources](/3.26.x/category/image-sources)
  - [Serving local files](/3.26.x/image_sources/local_files)
  - [Serving files from Amazon S3](/3.26.x/image_sources/amazon_s3)
  - [Serving files from Google Cloud Storage](/3.26.x/image_sources/google_cloud_storage)
  - [Serving files from Azure Blob Storage](/3.26.x/image_sources/azure_blob_storage)
  - [Serving files from OpenStack Object Storage ("Swift")](/3.26.x/image_sources/openstack_swift)
- [Monitoring](/3.26.x/category/monitoring)
  - [New Relic](/3.26.x/monitoring/new_relic)
  - [Prometheus](/3.26.x/monitoring/prometheus)
  - [Datadog](/3.26.x/monitoring/datadog)
  - [OpenTelemetry](/3.26.x/monitoring/open_telemetry)
  - [Amazon CloudWatch](/3.26.x/monitoring/cloud_watch)
- [Image formats support](/3.26.x/image_formats_support)
- [About the processing pipeline](/3.26.x/about_processing_pipeline)
- [Health check](/3.26.x/healthcheck)
- [Memory usage tweaks](/3.26.x/memory_usage_tweaks)

## Other versions

- [4.0.x (current)](/monitoring/cloud_watch)
- [latest (unstable)](/latest/monitoring/cloud_watch)
- [3.31.x](/3.31.x/monitoring/cloud_watch)
- [3.30.x](/3.30.x/monitoring/cloud_watch)
- [3.29.x](/3.29.x/monitoring/cloud_watch)
- [3.28.x](/3.28.x/monitoring/cloud_watch)
- [3.27.x](/3.27.x/monitoring/cloud_watch)
- [3.25.x](/3.25.x/monitoring/cloud_watch)
- [3.24.x](/3.24.x/monitoring/cloud_watch)
- [3.23.x](/3.23.x/monitoring/cloud_watch)
- [3.22.x](/3.22.x/monitoring/cloud_watch)
- [3.21.x](/3.21.x/monitoring/cloud_watch)
- [3.20.x](/3.20.x/monitoring/cloud_watch)
- [3.19.x](/3.19.x/monitoring/cloud_watch)
