createFleetMetric method

Future<CreateFleetMetricResponse> createFleetMetric({
  1. required String aggregationField,
  2. required AggregationType aggregationType,
  3. required String metricName,
  4. required int period,
  5. required String queryString,
  6. String? description,
  7. String? indexName,
  8. String? queryVersion,
  9. List<Tag>? tags,
  10. FleetMetricUnit? unit,
})

Creates a fleet metric.

Requires permission to access the CreateFleetMetric action.

May throw IndexNotReadyException. May throw InternalFailureException. May throw InvalidAggregationException. May throw InvalidQueryException. May throw InvalidRequestException. May throw LimitExceededException. May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException. May throw UnauthorizedException.

Parameter aggregationField : The field to aggregate.

Parameter aggregationType : The type of the aggregation query.

Parameter metricName : The name of the fleet metric to create.

Parameter period : The time in seconds between fleet metric emissions. Range [60(1 min), 86400(1 day)] and must be multiple of 60.

Parameter queryString : The search query string.

Parameter description : The fleet metric description.

Parameter indexName : The name of the index to search.

Parameter queryVersion : The query version.

Parameter tags : Metadata, which can be used to manage the fleet metric.

Parameter unit : Used to support unit transformation such as milliseconds to seconds. The unit must be supported by CW metric. Default to null.

Implementation

Future<CreateFleetMetricResponse> createFleetMetric({
  required String aggregationField,
  required AggregationType aggregationType,
  required String metricName,
  required int period,
  required String queryString,
  String? description,
  String? indexName,
  String? queryVersion,
  List<Tag>? tags,
  FleetMetricUnit? unit,
}) async {
  _s.validateNumRange(
    'period',
    period,
    60,
    86400,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'aggregationField': aggregationField,
    'aggregationType': aggregationType,
    'period': period,
    'queryString': queryString,
    if (description != null) 'description': description,
    if (indexName != null) 'indexName': indexName,
    if (queryVersion != null) 'queryVersion': queryVersion,
    if (tags != null) 'tags': tags,
    if (unit != null) 'unit': unit.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/fleet-metric/${Uri.encodeComponent(metricName)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateFleetMetricResponse.fromJson(response);
}