# GaugeWidget

A dashboard gauge widget that displays metrics.

Extends: [ConcreteWidget](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.ConcreteWidget.html) › GaugeWidget
Implements: [IWidget](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.IWidget.html)

- Source: [`aws-cloudwatch/lib/graph.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudwatch/lib/graph.ts#L249)
- Type last changed: v2.44.0 · 29 Sep 2022

## Example

TypeScript:

```ts
declare const dashboard: cloudwatch.Dashboard;
declare const errorAlarm: cloudwatch.Alarm;
declare const gaugeMetric: cloudwatch.Metric;

dashboard.addWidgets(new cloudwatch.GaugeWidget({
  metrics: [gaugeMetric],
  leftYAxis: {
    min: 0,
    max: 1000,
  }
}));
```

Python:

```python
# dashboard: cloudwatch.Dashboard
# error_alarm: cloudwatch.Alarm
# gauge_metric: cloudwatch.Metric

dashboard.add_widgets(cloudwatch.GaugeWidget(
    metrics=[gauge_metric],
    left_y_axis=cloudwatch.YAxisProps(
        min=0,
        max=1000
    )
))
```

Java:

```java
Dashboard dashboard;
Alarm errorAlarm;
Metric gaugeMetric;

dashboard.addWidgets(GaugeWidget.Builder.create()
        .metrics(List.of(gaugeMetric))
        .leftYAxis(YAxisProps.builder()
                .min(0)
                .max(1000)
                .build())
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Dashboard dashboard;
Alarm errorAlarm;
Metric gaugeMetric;

dashboard.AddWidgets(new GaugeWidget(new GaugeWidgetProps {
    Metrics = new [] { gaugeMetric },
    LeftYAxis = new YAxisProps {
        Min = 0,
        Max = 1000
    }
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var dashboard Dashboard
var errorAlarm Alarm
var gaugeMetric Metric

dashboard.AddWidgets(cloudwatch.NewGaugeWidget(&GaugeWidgetProps{
	Metrics: []IMetric{
		gaugeMetric,
	},
	LeftYAxis: &YAxisProps{
		Min: jsii.Number(0),
		Max: jsii.Number(1000),
	},
}))
```

## Initializer

TypeScript:

```ts
new GaugeWidget(props: GaugeWidgetProps)
```

Python:

```python
GaugeWidget(props: GaugeWidgetProps)
```

Java:

```java
new GaugeWidget(GaugeWidgetProps props)
```

C# / .NET:

```csharp
new GaugeWidget(GaugeWidgetProps props)
```

Golang:

```go
NewGaugeWidget(Props GaugeWidgetProps)
```

## Properties

- `height`: number — The amount of vertical grid units the widget will take up.

- `warnings`: string[] — Any warnings that are produced as a result of putting together this widget.

- `warningsV2`: { [key: string]: string } — Any warnings that are produced as a result of putting together this widget.

- `width`: number — The amount of horizontal grid units the widget will take up.

## Methods

- `addMetric(metric: IMetric): void` — Add another metric to the left Y axis of the GaugeWidget.

  **Parameters**

  - `metric` — the metric to add.

- `position(x: number, y: number): void` — Place the widget at a given position.

- `toJson(): any[]` — Return the widget JSON for use in the dashboard.
