MetricsOptions: {
    customConfigService?: ConfigServiceInterface;
    defaultDimensions?: Dimensions;
    logger?: GenericLogger;
    namespace?: string;
    serviceName?: string;
    singleMetric?: boolean;
}

Options to configure the Metrics class.

Type declaration

  • OptionalcustomConfigService?: ConfigServiceInterface

    A custom configuration service to use for retrieving configuration values.

    undefined
    
  • OptionaldefaultDimensions?: Dimensions

    The default dimensions to add to all metrics.

    {}
    
  • Optionallogger?: GenericLogger

    Logger object to be used for emitting debug, warning, and error messages.

    If not provided, debug messages will be suppressed, and warning and error messages will be sent to stdout.

    Note that EMF metrics are always sent directly to stdout, regardless of the logger to avoid compatibility issues with custom loggers.

  • Optionalnamespace?: string

    The namespace to use for all metrics.

    undefined
    
  • OptionalserviceName?: string

    The service name to use for all metrics.

    undefined
    
  • OptionalsingleMetric?: boolean

    Whether to configure the Metrics class to emit a single metric as soon as it is added.

    false
    
import { Metrics } from '@aws-lambda-powertools/metrics';

const metrics = new Metrics({
namespace: 'serverlessAirline',
serviceName: 'orders',
singleMetric: true,
});