

# Monitoring and billing for auto scaling

This topic applies to both ways of using auto scaling on AWS Glue: legacy auto scaling (`--enable-auto-scaling`) and the managed scaling profile (`--scaling-profile balanced`). You use the same metrics, logs, and billing information to monitor a run with either method.

## Billing
<a name="auto-scaling-billing"></a>

With both legacy auto scaling and the managed scaling profile, AWS Glue bills for the executors that a run actually uses, measured in DPU-seconds. It doesn't bill for the maximum number of workers that you allow. After a batch ETL job run finishes, `GetJobRun` returns the `DPUSeconds` field with the resources that the run used. For pricing details, see the [AWS Glue pricing](https://aws.amazon.com/glue/pricing/) page.

## Monitoring scaling with Amazon CloudWatch metrics
<a name="auto-scaling-monitor-cloud-watch"></a>

The CloudWatch executor metrics are available for your AWS Glue 3.0 or later jobs when you use auto scaling. The metrics can be used to monitor the demand and optimized usage of executors in their Spark applications that use auto scaling. For more information, see [Monitoring AWS Glue using Amazon CloudWatch metrics](monitoring-awsglue-with-cloudwatch-metrics.md).

 You can also utilize AWS Glue observability metrics to get insights about resource utilization. For example, by monitoring `glue.driver.workerUtilization`, you can monitor how much resource was actually used with and without auto scaling. For another example, by monitoring `glue.driver.skewness.job` and `glue.driver.skewness.stage`, you can see how the data is skewed. Those insights will help you decide to enable auto scaling and fine tune the configurations. For more information, see Monitoring with [Monitoring with AWS Glue Observability metrics](monitor-observability.md). 
+ glue.driver.ExecutorAllocationManager.executors.numberAllExecutors
+ glue.driver.ExecutorAllocationManager.executors.numberMaxNeededExecutors

For more details on these metrics, see [Monitoring for DPU capacity planning](monitor-debug-capacity.md).

**Note**  
 CloudWatch executor metrics are not available for interactive sessions. 

![Monitoring auto scaling with Amazon CloudWatch metrics.](https://docs.aws.amazon.com/glue/latest/dg/images/auto-scaling-monitor-metrics.png)


## Monitoring scaling with Amazon CloudWatch Logs
<a name="auto-scaling-monitor-cloudwatch-logs"></a>

 If you are using interactive sessions, you can monitor the number of executors by enabling continuous Amazon CloudWatch Logs and searching “executor” in the logs, or by using the Spark UI. To do this, use the `%%configure` magic to enable continuous logging along with `enable auto scaling`. 

```
%%configure{
    "--enable-continuous-cloudwatch-log": "true",
    "--enable-auto-scaling": "true"
}
```

 In the Amazon CloudWatch Logsevents, search "executor"in the logs: 

![Monitoring auto scaling with Amazon CloudWatch metrics.](https://docs.aws.amazon.com/glue/latest/dg/images/cloudwatch-metrics-search-executor.png)


## Monitoring scaling with Spark UI
<a name="auto-scaling-monitor-spark-ui"></a>

 With auto scaling, you can also monitor executors being added and removed with dynamic scale-up and scale-down based on the demand in your AWS Glue jobs using the Glue Spark UI. For more information, see [Enabling the Apache Spark web UI for AWS Glue jobs](monitor-spark-ui-jobs.md).

![Monitoring auto scaling with Spark UI.](https://docs.aws.amazon.com/glue/latest/dg/images/auto-scaling-monitor-spark-ui.png)


## Monitoring job run DPU usage
<a name="auto-scaling-monitor-dpu-usage"></a>

You may use the [AWS Glue Studio Job run view](https://docs.aws.amazon.com/glue/latest/ug/monitoring-chapter.html) to check the DPU usage of your jobs.

1. Choose **Monitoring** from the AWS Glue Studio navigation pane. The Monitoring page appears.

1. Scroll down to the Job runs chart.

1. Navigate to the job run you are interested and scroll to the DPU hours column to check the usage for the specific job run.