Connect / Client / create_metric

create_metric

Connect.Client.create_metric(**kwargs)

Creates a new metric definition for the specified Connect Customer instance. You can create custom metrics that use formulas referencing existing Amazon Web Services-managed metrics, optionally with filters applied.

See also: AWS API Documentation

Request Syntax

response = client.create_metric(
    InstanceId='string',
    Name='string',
    MetricCalculation={
        'CalculationComponents': [
            {
                'Alias': 'string',
                'MetricName': 'string',
                'MetricId': 'string',
                'MetricFilters': [
                    {
                        'MetricFilterKey': 'string',
                        'Negate': True|False,
                        'NumberCondition': {
                            'Comparison': 'LESSER'|'LESSER_OR_EQUAL'|'GREATER'|'GREATER_OR_EQUAL',
                            'Values': [
                                123.0,
                            ]
                        },
                        'StringCondition': {
                            'Comparison': 'MATCHES_ANY'|'MATCHES_NONE',
                            'Values': [
                                'string',
                            ]
                        },
                        'BooleanCondition': {
                            'Comparison': 'IS_TRUE'|'IS_FALSE'
                        }
                    },
                ]
            },
        ],
        'Calculation': 'string'
    },
    Unit='INTEGER'|'DOUBLE'|'PERCENT'|'SECONDS',
    Status='PUBLISHED'|'SAVED',
    ClientToken='string',
    Description='string',
    PositiveTrendIndicator='POSITIVE'|'NEGATIVE'|'NEUTRAL',
    Tags={
        'string': 'string'
    }
)
Parameters:
  • InstanceId (string) –

    [REQUIRED]

    The identifier of the Connect Customer instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.

  • Name (string) –

    [REQUIRED]

    The name of the metric.

  • MetricCalculation (dict) –

    [REQUIRED]

    The calculation definition for the metric, including the formula expression and the component metrics it references.

    • CalculationComponents (list) – [REQUIRED]

      The list of component metrics referenced in the calculation formula. Each component has an alias used in the formula expression.

      • (dict) –

        Represents a component metric referenced in a custom metric calculation formula.

        • Alias (string) – [REQUIRED]

          The alias used to reference this component in the calculation expression.

        • MetricName (string) –

          The name of an AWS-managed metric used in this calculation component (for example, CONTACTS_HANDLED). Mutually exclusive with MetricId.

        • MetricId (string) –

          The ARN of an AWS-managed metric used in this calculation component. Mutually exclusive with MetricName.

        • MetricFilters (list) –

          The filters applied to the calculation component.

          • (dict) –

            A filter condition applied to a metric component in a calculation. Filters restrict the data included in the metric computation.

            • MetricFilterKey (string) – [REQUIRED]

              The key identifying the field to filter on.

            • Negate (boolean) –

              Specifies whether the filter condition is negated. When set to true, the filter excludes matching data instead of including it.

            • NumberCondition (dict) –

              A numeric comparison condition.

              • Comparison (string) – [REQUIRED]

                The comparison operator. Valid values: LESSER (less than) | LESSER_OR_EQUAL (less than or equal to) | GREATER (greater than) | GREATER_OR_EQUAL (greater than or equal to).

              • Values (list) – [REQUIRED]

                The numeric values to compare against.

                • (float) –

            • StringCondition (dict) –

              A string comparison condition.

              • Comparison (string) – [REQUIRED]

                The comparison operator. Valid values: MATCHES_ANY (matches any of the specified values) | MATCHES_NONE (matches none of the specified values).

              • Values (list) – [REQUIRED]

                The string values to compare against.

                • (string) –

            • BooleanCondition (dict) –

              A boolean comparison condition.

              • Comparison (string) – [REQUIRED]

                The comparison operator. Valid values: IS_TRUE (matches when the field is true) | IS_FALSE (matches when the field is false).

    • Calculation (string) – [REQUIRED]

      The formula expression that defines how the metric is calculated. Uses component aliases (for example, 100 * SUM(M1) / SUM(M2)).

  • Unit (string) –

    [REQUIRED]

    The display unit for the metric’s data.

  • Status (string) – The publish status of the metric. Set to PUBLISHED to make the metric available for use in dashboards and reports, or SAVED to keep it in draft state.

  • ClientToken (string) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

    This field is autopopulated if not provided.

  • Description (string) – The description of the metric.

  • PositiveTrendIndicator (string) – How an increase in the metric value should be interpreted. Valid values: POSITIVE, NEUTRAL, NEGATIVE.

  • Tags (dict) –

    The tags used to organize, track, or control access for this resource. For example, { “Tags”: {“key1”:”value1”, “key2”:”value2”} }.

    • (string) –

      • (string) –

Return type:

dict

Returns:

Response Syntax

{
    'MetricArn': 'string',
    'MetricId': 'string'
}

Response Structure

  • (dict) –

    • MetricArn (string) –

      The Amazon Resource Name (ARN) of the metric.

    • MetricId (string) –

      The identifier of the metric.

Exceptions

  • Connect.Client.exceptions.InvalidRequestException

  • Connect.Client.exceptions.InvalidParameterException

  • Connect.Client.exceptions.ResourceNotFoundException

  • Connect.Client.exceptions.DuplicateResourceException

  • Connect.Client.exceptions.LimitExceededException

  • Connect.Client.exceptions.AccessDeniedException

  • Connect.Client.exceptions.ThrottlingException

  • Connect.Client.exceptions.InternalServiceException