aws-embedded-metrics


Nameaws-embedded-metrics JSON
Version 3.2.0 PyPI version JSON
download
home_pagehttps://github.com/awslabs/aws-embedded-metrics-python
SummaryAWS Embedded Metrics Package
upload_time2023-09-14 18:53:31
maintainer
docs_urlNone
authorAmazon Web Services
requires_python>=3.6
license
keywords aws logs metrics emf
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aws-embedded-metrics

![](https://codebuild.us-west-2.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoidjNkYXpXTzMxdUY2dEdab2RaZTgvTXhUSGh2bjNmUlhmUEorejM0UytyOWNqeFptcUpBT2wzNkJ1MkExQXI3UFdNaGQzNlVmSzBPWkRhdmhkb2lqL05NPSIsIml2UGFyYW1ldGVyU3BlYyI6IkhKZS9rd2UwYzVud1VucVgiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master)
[![](https://img.shields.io/pypi/v/aws-embedded-metrics)](https://pypi.org/project/aws-embedded-metrics/)

Generate CloudWatch Metrics embedded within structured log events. The embedded metrics will be extracted so you can visualize and alarm on them for real-time incident detection. This allows you to monitor aggregated values while preserving the detailed event context that generated them.

- [Use Cases](#use-cases)
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
- [Examples](#examples)
- [Development](#development)

## Use Cases

- **Generate custom metrics across compute environments**

  - Easily generate custom metrics from Lambda functions without requiring custom batching code, making blocking network requests or relying on 3rd party software.
  - Other compute environments (EC2, On-prem, ECS, EKS, and other container environments) are supported by installing the [CloudWatch Agent](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Generation_CloudWatch_Agent.html).
  	- Examples can be found in [examples/README.md](examples/README.md)

- **Linking metrics to high cardinality context**

  Using the Embedded Metric Format, you will be able to visualize and alarm on custom metrics, but also retain the original, detailed and high-cardinality context which is queryable using [CloudWatch Logs Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html). For example, the library automatically injects environment metadata such as Lambda Function version, EC2 instance and image ids into the structured log event data.

## Installation

```
pip3 install aws-embedded-metrics
```

## Usage

To get a metric logger, you can decorate your function with a `metric_scope`:

```py
from aws_embedded_metrics import metric_scope
from aws_embedded_metrics.storage_resolution import StorageResolution

@metric_scope
def my_handler(metrics):
    metrics.put_dimensions({"Foo": "Bar"})
    metrics.put_metric("ProcessingLatency", 100, "Milliseconds", StorageResolution.STANDARD)
    metrics.put_metric("Memory.HeapUsed", 1600424.0, "Bytes", StorageResolution.HIGH)
    metrics.set_property("AccountId", "123456789012")
    metrics.set_property("RequestId", "422b1569-16f6-4a03")
    metrics.set_property("DeviceId", "61270781-c6ac-46f1")

    return {"message": "Hello!"}
```

## API

### MetricsLogger

The `MetricsLogger` is the interface you will use to publish embedded metrics.

- **put_metric**(key: str, value: float, unit: str = "None", storage_resolution: int = 60) -> MetricsLogger

Adds a new metric to the current logger context. Multiple metrics using the same key will be appended to an array of values. Multiple metrics cannot have same key and different storage resolution. The Embedded Metric Format supports a maximum of 100 values per key. If more metric values are added than are supported by the format, the logger will be flushed to allow for new metric values to be captured.

Requirements:

- Name Length 1-255 characters
- Name must be ASCII characters only
- Values must be in the range of 8.515920e-109 to 1.174271e+108. In addition, special values (for example, NaN, +Infinity, -Infinity) are not supported.
- Metrics must meet CloudWatch Metrics requirements, otherwise a `InvalidMetricError` will be thrown. See [MetricDatum](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html) for valid values.

- ##### Storage Resolution
An OPTIONAL value representing the storage resolution for the corresponding metric. Setting this to `High` specifies this metric as a high-resolution metric, so that CloudWatch stores the metric with sub-minute resolution down to one second. Setting this to `Standard` specifies this metric as a standard-resolution metric, which CloudWatch stores at 1-minute resolution. If a value is not provided, then a default value of `Standard` is assumed. See [Cloud Watch High-Resolution metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html#high-resolution-metrics)

Examples:

```py
# Standard Resolution example
put_metric("Latency", 200, "Milliseconds")
put_metric("Latency", 201, "Milliseconds", StorageResolution.STANDARD)

# High Resolution example
put_metric("Memory.HeapUsed", 1600424.0, "Bytes", StorageResolution.HIGH)
```

- **set_property**(key: str, value: Any) -> MetricsLogger

Adds or updates the value for a given property on this context. This value is not submitted to CloudWatch Metrics but is searchable by CloudWatch Logs Insights. This is useful for contextual and potentially high-cardinality data that is not appropriate for CloudWatch Metrics dimensions.

Requirements:

- Length 1-255 characters

Examples:

```py
set_property("RequestId", "422b1569-16f6-4a03-b8f0-fe3fd9b100f8")
set_property("InstanceId", "i-1234567890")
set_property("Device", {
  "Id": "61270781-c6ac-46f1-baf7-22c808af8162",
  "Name": "Transducer",
  "Model": "PT-1234"
})
```

- **put_dimensions**(dimensions: Dict[str, str]) -> MetricsLogger

Adds a new set of dimensions that will be associated to all metric values.

**WARNING**: Every distinct value will result in a new CloudWatch Metric.
If the cardinality of a particular value is expected to be high, you should consider
using `setProperty` instead.

Requirements:

- Length 1-255 characters
- ASCII characters only
- Dimensions must meet CloudWatch Dimensions requirements, otherwise a `InvalidDimensionError` or `DimensionSetExceededError` will be thrown. See [Dimensions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Dimension.html) for valid values.

Examples:

```py
put_dimensions({ "Operation": "Aggregator" })
put_dimensions({ "Operation": "Aggregator", "DeviceType": "Actuator" })
```

- **set_dimensions**(\*dimensions: Dict[str, str], use_default: bool = False) -> MetricsLogger

Explicitly override all dimensions. By default, this will disable the default dimensions, but can be configured using the *keyword-only* parameter `use_default`.

**WARNING**: Every distinct value will result in a new CloudWatch Metric.
If the cardinality of a particular value is expected to be high, you should consider
using `setProperty` instead.

Requirements:

- Length 1-255 characters
- ASCII characters only
- Dimensions must meet CloudWatch Dimensions requirements, otherwise a `InvalidDimensionError` or `DimensionSetExceededError` will be thrown. See [Dimensions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Dimension.html) for valid values.

Examples:

```py
set_dimensions(
  { "Operation": "Aggregator" },
  { "Operation": "Aggregator", "DeviceType": "Actuator" }
)
```

```py
set_dimensions(
  { "Operation": "Aggregator" },
  use_default=True  # default dimensions would be enabled
)
```

- **reset_dimensions**(use_default: bool) -> MetricsLogger

Explicitly clear all custom dimensions. The behavior of whether default dimensions should be used can be configured with the `use_default` parameter.

Examples:

```py
reset_dimensions(False)  # this will clear all custom dimensions as well as disable default dimensions
```

- **set_namespace**(value: str) -> MetricsLogger

Sets the CloudWatch [namespace](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace) that extracted metrics should be published to. If not set, a default value of aws-embedded-metrics will be used.

Requirements:

- Name Length 1-255 characters
- Name must be ASCII characters only
- Namespace must meet CloudWatch Namespace requirements, otherwise a `InvalidNamespaceError` will be thrown. See [Namespaces](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace) for valid values.

Examples:

```py
set_namespace("MyApplication")
```

- **set_timestamp**(timestamp: datetime) -> MetricsLogger

Sets the timestamp of the metrics. If not set, current time of the client will be used.

Timestamp must meet CloudWatch requirements, otherwise a InvalidTimestampError will be thrown. See [Timestamps](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#about_timestamp) for valid values.

Examples:

```py
    set_timestamp(datetime.datetime.now())
```



- **flush**()

Flushes the current MetricsContext to the configured sink and resets all properties and metric values. The namespace and default dimensions will be preserved across flushes.
Custom dimensions are **not** preserved by default, but this behavior can be changed by setting `logger.flush_preserve_dimensions = True`, so that custom dimensions would be preserved after each flushing thereafter.

Example:

```py
logger.flush()  # only default dimensions will be preserved after each flush()
```

```py
logger.flush_preserve_dimensions = True
logger.flush()  # custom dimensions and default dimensions will be preserved after each flush()
```

```py
logger.reset_dimensions(False)
logger.flush()  # default dimensions are disabled; no dimensions will be preserved after each flush()
```

### Configuration

All configuration values can be set using environment variables with the prefix (`AWS_EMF_`). Configuration should be performed as close to application start up as possible.

**ServiceName**: Overrides the name of the service. For services where the name cannot be inferred (e.g. Java process running on EC2), a default value of Unknown will be used if not explicitly set.

Requirements:

- Name Length 1-255 characters
- Name must be ASCII characters only

Example:

```py
# in process
from aws_embedded_metrics.config import get_config
Config = get_config()
Config.service_name = "MyApp"

# environment
AWS_EMF_SERVICE_NAME = MyApp
```

**ServiceType**: Overrides the type of the service. For services where the type cannot be inferred (e.g. Java process running on EC2), a default value of Unknown will be used if not explicitly set.

Requirements:

- Name Length 1-255 characters
- Name must be ASCII characters only

Example:

```py
# in process
from aws_embedded_metrics.config import get_config
Config = get_config()
Config.service_type = "NodeJSWebApp"

# environment
AWS_EMF_SERVICE_TYPE = NodeJSWebApp
```

**LogGroupName**: For agent-based platforms, you may optionally configure the destination log group that metrics should be delivered to. This value will be passed from the library to the agent in the Embedded Metric payload. If a LogGroup is not provided, the default value will be derived from the service name: <service-name>-metrics

Requirements:

- Name Length 1-512 characters
- Log group names consist of the following characters: a-z, A-Z, 0-9, '\_' (underscore), '-' (hyphen), '/' (forward slash), and '.' (period). Pattern: [\.\-_/#A-Za-z0-9]+

Example:

```py
# in process
from aws_embedded_metrics.config import get_config
Config = get_config()
Config.log_group_name = "LogGroupName"

# environment
AWS_EMF_LOG_GROUP_NAME = LogGroupName
```

**LogStreamName**: For agent-based platforms, you may optionally configure the destination log stream that metrics should be delivered to. This value will be passed from the library to the agent in the Embedded Metric payload. If a LogGroup is not provided, the default value will be derived by the agent (this will likely be the hostname).

Requirements:

- Name Length 1-512 characters
- The ':' (colon) and '\*' (asterisk) characters are not allowed. Pattern: [^:]\*

Example:

```py
# in process
from aws_embedded_metrics.config import get_config
Config = get_config()
Config.log_stream_name = "LogStreamName"

# environment
AWS_EMF_LOG_STREAM_NAME = LogStreamName
```

**NameSpace**: Overrides the CloudWatch [namespace](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace). If not set, a default value of aws-embedded-metrics will be used.

Requirements:

- Name Length 1-512 characters
- Name must be ASCII characters only

Example:

```py
# in process
from aws_embedded_metrics.config import get_config
Config = get_config()
Config.namespace = "MyApplication"

# environment
AWS_EMF_NAMESPACE = MyApplication
```

**DISABLE_METRIC_EXTRACTION**: Disables extraction of metrics by CloudWatch, by omitting EMF
metadata from serialized log records.

Example:

```py
# in process
from aws_embedded_metrics.config import get_config
Config = get_config()
Config.disable_metric_extraction = True

# environment
AWS_EMF_DISABLE_METRIC_EXTRACTION = true
```

## Examples

Check out the [examples](https://github.com/awslabs/aws-embedded-metrics-python/tree/master/examples) directory to get started.

## Development

1. Install Test Dependencies

```
pip install tox
```

2. Run tests

```
tox
```

3. Integration tests. These tests require Docker to run the CloudWatch Agent and valid AWS credentials. Tests can be run by:

```sh
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_REGION=us-west-2
./bin/run-integ-tests.sh
```

## License

This project is licensed under the Apache-2.0 License.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/awslabs/aws-embedded-metrics-python",
    "name": "aws-embedded-metrics",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "aws logs metrics emf",
    "author": "Amazon Web Services",
    "author_email": "jarnance@amazon.com",
    "download_url": "https://files.pythonhosted.org/packages/c1/08/1bb1f7392cd9c3a65c4571a7f7286056ec52b3cd3d432485ca2b9907e0f9/aws-embedded-metrics-3.2.0.tar.gz",
    "platform": null,
    "description": "# aws-embedded-metrics\n\n![](https://codebuild.us-west-2.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoidjNkYXpXTzMxdUY2dEdab2RaZTgvTXhUSGh2bjNmUlhmUEorejM0UytyOWNqeFptcUpBT2wzNkJ1MkExQXI3UFdNaGQzNlVmSzBPWkRhdmhkb2lqL05NPSIsIml2UGFyYW1ldGVyU3BlYyI6IkhKZS9rd2UwYzVud1VucVgiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master)\n[![](https://img.shields.io/pypi/v/aws-embedded-metrics)](https://pypi.org/project/aws-embedded-metrics/)\n\nGenerate CloudWatch Metrics embedded within structured log events. The embedded metrics will be extracted so you can visualize and alarm on them for real-time incident detection. This allows you to monitor aggregated values while preserving the detailed event context that generated them.\n\n- [Use Cases](#use-cases)\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n- [Examples](#examples)\n- [Development](#development)\n\n## Use Cases\n\n- **Generate custom metrics across compute environments**\n\n  - Easily generate custom metrics from Lambda functions without requiring custom batching code, making blocking network requests or relying on 3rd party software.\n  - Other compute environments (EC2, On-prem, ECS, EKS, and other container environments) are supported by installing the [CloudWatch Agent](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Generation_CloudWatch_Agent.html).\n  \t- Examples can be found in [examples/README.md](examples/README.md)\n\n- **Linking metrics to high cardinality context**\n\n  Using the Embedded Metric Format, you will be able to visualize and alarm on custom metrics, but also retain the original, detailed and high-cardinality context which is queryable using [CloudWatch Logs Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html). For example, the library automatically injects environment metadata such as Lambda Function version, EC2 instance and image ids into the structured log event data.\n\n## Installation\n\n```\npip3 install aws-embedded-metrics\n```\n\n## Usage\n\nTo get a metric logger, you can decorate your function with a `metric_scope`:\n\n```py\nfrom aws_embedded_metrics import metric_scope\nfrom aws_embedded_metrics.storage_resolution import StorageResolution\n\n@metric_scope\ndef my_handler(metrics):\n    metrics.put_dimensions({\"Foo\": \"Bar\"})\n    metrics.put_metric(\"ProcessingLatency\", 100, \"Milliseconds\", StorageResolution.STANDARD)\n    metrics.put_metric(\"Memory.HeapUsed\", 1600424.0, \"Bytes\", StorageResolution.HIGH)\n    metrics.set_property(\"AccountId\", \"123456789012\")\n    metrics.set_property(\"RequestId\", \"422b1569-16f6-4a03\")\n    metrics.set_property(\"DeviceId\", \"61270781-c6ac-46f1\")\n\n    return {\"message\": \"Hello!\"}\n```\n\n## API\n\n### MetricsLogger\n\nThe `MetricsLogger` is the interface you will use to publish embedded metrics.\n\n- **put_metric**(key: str, value: float, unit: str = \"None\", storage_resolution: int = 60) -> MetricsLogger\n\nAdds a new metric to the current logger context. Multiple metrics using the same key will be appended to an array of values. Multiple metrics cannot have same key and different storage resolution. The Embedded Metric Format supports a maximum of 100 values per key. If more metric values are added than are supported by the format, the logger will be flushed to allow for new metric values to be captured.\n\nRequirements:\n\n- Name Length 1-255 characters\n- Name must be ASCII characters only\n- Values must be in the range of 8.515920e-109 to 1.174271e+108. In addition, special values (for example, NaN, +Infinity, -Infinity) are not supported.\n- Metrics must meet CloudWatch Metrics requirements, otherwise a `InvalidMetricError` will be thrown. See [MetricDatum](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html) for valid values.\n\n- ##### Storage Resolution\nAn OPTIONAL value representing the storage resolution for the corresponding metric. Setting this to `High` specifies this metric as a high-resolution metric, so that CloudWatch stores the metric with sub-minute resolution down to one second. Setting this to `Standard` specifies this metric as a standard-resolution metric, which CloudWatch stores at 1-minute resolution. If a value is not provided, then a default value of `Standard` is assumed. See [Cloud Watch High-Resolution metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html#high-resolution-metrics)\n\nExamples:\n\n```py\n# Standard Resolution example\nput_metric(\"Latency\", 200, \"Milliseconds\")\nput_metric(\"Latency\", 201, \"Milliseconds\", StorageResolution.STANDARD)\n\n# High Resolution example\nput_metric(\"Memory.HeapUsed\", 1600424.0, \"Bytes\", StorageResolution.HIGH)\n```\n\n- **set_property**(key: str, value: Any) -> MetricsLogger\n\nAdds or updates the value for a given property on this context. This value is not submitted to CloudWatch Metrics but is searchable by CloudWatch Logs Insights. This is useful for contextual and potentially high-cardinality data that is not appropriate for CloudWatch Metrics dimensions.\n\nRequirements:\n\n- Length 1-255 characters\n\nExamples:\n\n```py\nset_property(\"RequestId\", \"422b1569-16f6-4a03-b8f0-fe3fd9b100f8\")\nset_property(\"InstanceId\", \"i-1234567890\")\nset_property(\"Device\", {\n  \"Id\": \"61270781-c6ac-46f1-baf7-22c808af8162\",\n  \"Name\": \"Transducer\",\n  \"Model\": \"PT-1234\"\n})\n```\n\n- **put_dimensions**(dimensions: Dict[str, str]) -> MetricsLogger\n\nAdds a new set of dimensions that will be associated to all metric values.\n\n**WARNING**: Every distinct value will result in a new CloudWatch Metric.\nIf the cardinality of a particular value is expected to be high, you should consider\nusing `setProperty` instead.\n\nRequirements:\n\n- Length 1-255 characters\n- ASCII characters only\n- Dimensions must meet CloudWatch Dimensions requirements, otherwise a `InvalidDimensionError` or `DimensionSetExceededError` will be thrown. See [Dimensions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Dimension.html) for valid values.\n\nExamples:\n\n```py\nput_dimensions({ \"Operation\": \"Aggregator\" })\nput_dimensions({ \"Operation\": \"Aggregator\", \"DeviceType\": \"Actuator\" })\n```\n\n- **set_dimensions**(\\*dimensions: Dict[str, str], use_default: bool = False) -> MetricsLogger\n\nExplicitly override all dimensions. By default, this will disable the default dimensions, but can be configured using the *keyword-only* parameter `use_default`.\n\n**WARNING**: Every distinct value will result in a new CloudWatch Metric.\nIf the cardinality of a particular value is expected to be high, you should consider\nusing `setProperty` instead.\n\nRequirements:\n\n- Length 1-255 characters\n- ASCII characters only\n- Dimensions must meet CloudWatch Dimensions requirements, otherwise a `InvalidDimensionError` or `DimensionSetExceededError` will be thrown. See [Dimensions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Dimension.html) for valid values.\n\nExamples:\n\n```py\nset_dimensions(\n  { \"Operation\": \"Aggregator\" },\n  { \"Operation\": \"Aggregator\", \"DeviceType\": \"Actuator\" }\n)\n```\n\n```py\nset_dimensions(\n  { \"Operation\": \"Aggregator\" },\n  use_default=True  # default dimensions would be enabled\n)\n```\n\n- **reset_dimensions**(use_default: bool) -> MetricsLogger\n\nExplicitly clear all custom dimensions. The behavior of whether default dimensions should be used can be configured with the `use_default` parameter.\n\nExamples:\n\n```py\nreset_dimensions(False)  # this will clear all custom dimensions as well as disable default dimensions\n```\n\n- **set_namespace**(value: str) -> MetricsLogger\n\nSets the CloudWatch [namespace](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace) that extracted metrics should be published to. If not set, a default value of aws-embedded-metrics will be used.\n\nRequirements:\n\n- Name Length 1-255 characters\n- Name must be ASCII characters only\n- Namespace must meet CloudWatch Namespace requirements, otherwise a `InvalidNamespaceError` will be thrown. See [Namespaces](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace) for valid values.\n\nExamples:\n\n```py\nset_namespace(\"MyApplication\")\n```\n\n- **set_timestamp**(timestamp: datetime) -> MetricsLogger\n\nSets the timestamp of the metrics. If not set, current time of the client will be used.\n\nTimestamp must meet CloudWatch requirements, otherwise a InvalidTimestampError will be thrown. See [Timestamps](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#about_timestamp) for valid values.\n\nExamples:\n\n```py\n    set_timestamp(datetime.datetime.now())\n```\n\n\n\n- **flush**()\n\nFlushes the current MetricsContext to the configured sink and resets all properties and metric values. The namespace and default dimensions will be preserved across flushes.\nCustom dimensions are **not** preserved by default, but this behavior can be changed by setting `logger.flush_preserve_dimensions = True`, so that custom dimensions would be preserved after each flushing thereafter.\n\nExample:\n\n```py\nlogger.flush()  # only default dimensions will be preserved after each flush()\n```\n\n```py\nlogger.flush_preserve_dimensions = True\nlogger.flush()  # custom dimensions and default dimensions will be preserved after each flush()\n```\n\n```py\nlogger.reset_dimensions(False)\nlogger.flush()  # default dimensions are disabled; no dimensions will be preserved after each flush()\n```\n\n### Configuration\n\nAll configuration values can be set using environment variables with the prefix (`AWS_EMF_`). Configuration should be performed as close to application start up as possible.\n\n**ServiceName**: Overrides the name of the service. For services where the name cannot be inferred (e.g. Java process running on EC2), a default value of Unknown will be used if not explicitly set.\n\nRequirements:\n\n- Name Length 1-255 characters\n- Name must be ASCII characters only\n\nExample:\n\n```py\n# in process\nfrom aws_embedded_metrics.config import get_config\nConfig = get_config()\nConfig.service_name = \"MyApp\"\n\n# environment\nAWS_EMF_SERVICE_NAME = MyApp\n```\n\n**ServiceType**: Overrides the type of the service. For services where the type cannot be inferred (e.g. Java process running on EC2), a default value of Unknown will be used if not explicitly set.\n\nRequirements:\n\n- Name Length 1-255 characters\n- Name must be ASCII characters only\n\nExample:\n\n```py\n# in process\nfrom aws_embedded_metrics.config import get_config\nConfig = get_config()\nConfig.service_type = \"NodeJSWebApp\"\n\n# environment\nAWS_EMF_SERVICE_TYPE = NodeJSWebApp\n```\n\n**LogGroupName**: For agent-based platforms, you may optionally configure the destination log group that metrics should be delivered to. This value will be passed from the library to the agent in the Embedded Metric payload. If a LogGroup is not provided, the default value will be derived from the service name: <service-name>-metrics\n\nRequirements:\n\n- Name Length 1-512 characters\n- Log group names consist of the following characters: a-z, A-Z, 0-9, '\\_' (underscore), '-' (hyphen), '/' (forward slash), and '.' (period). Pattern: [\\.\\-_/#A-Za-z0-9]+\n\nExample:\n\n```py\n# in process\nfrom aws_embedded_metrics.config import get_config\nConfig = get_config()\nConfig.log_group_name = \"LogGroupName\"\n\n# environment\nAWS_EMF_LOG_GROUP_NAME = LogGroupName\n```\n\n**LogStreamName**: For agent-based platforms, you may optionally configure the destination log stream that metrics should be delivered to. This value will be passed from the library to the agent in the Embedded Metric payload. If a LogGroup is not provided, the default value will be derived by the agent (this will likely be the hostname).\n\nRequirements:\n\n- Name Length 1-512 characters\n- The ':' (colon) and '\\*' (asterisk) characters are not allowed. Pattern: [^:]\\*\n\nExample:\n\n```py\n# in process\nfrom aws_embedded_metrics.config import get_config\nConfig = get_config()\nConfig.log_stream_name = \"LogStreamName\"\n\n# environment\nAWS_EMF_LOG_STREAM_NAME = LogStreamName\n```\n\n**NameSpace**: Overrides the CloudWatch [namespace](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace). If not set, a default value of aws-embedded-metrics will be used.\n\nRequirements:\n\n- Name Length 1-512 characters\n- Name must be ASCII characters only\n\nExample:\n\n```py\n# in process\nfrom aws_embedded_metrics.config import get_config\nConfig = get_config()\nConfig.namespace = \"MyApplication\"\n\n# environment\nAWS_EMF_NAMESPACE = MyApplication\n```\n\n**DISABLE_METRIC_EXTRACTION**: Disables extraction of metrics by CloudWatch, by omitting EMF\nmetadata from serialized log records.\n\nExample:\n\n```py\n# in process\nfrom aws_embedded_metrics.config import get_config\nConfig = get_config()\nConfig.disable_metric_extraction = True\n\n# environment\nAWS_EMF_DISABLE_METRIC_EXTRACTION = true\n```\n\n## Examples\n\nCheck out the [examples](https://github.com/awslabs/aws-embedded-metrics-python/tree/master/examples) directory to get started.\n\n## Development\n\n1. Install Test Dependencies\n\n```\npip install tox\n```\n\n2. Run tests\n\n```\ntox\n```\n\n3. Integration tests. These tests require Docker to run the CloudWatch Agent and valid AWS credentials. Tests can be run by:\n\n```sh\nexport AWS_ACCESS_KEY_ID=\nexport AWS_SECRET_ACCESS_KEY=\nexport AWS_REGION=us-west-2\n./bin/run-integ-tests.sh\n```\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "AWS Embedded Metrics Package",
    "version": "3.2.0",
    "project_urls": {
        "Homepage": "https://github.com/awslabs/aws-embedded-metrics-python"
    },
    "split_keywords": [
        "aws",
        "logs",
        "metrics",
        "emf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7abe2365cd3cc0e05613fd178cace777ba7df9faf54f34c0137788ae55dc522",
                "md5": "f9c09e12d2b9aa5dcd9827e1bf5bfcff",
                "sha256": "887b76d24914efa5fc42a7b77983e77fc670633e6e1195aac7653c425fee7399"
            },
            "downloads": -1,
            "filename": "aws_embedded_metrics-3.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f9c09e12d2b9aa5dcd9827e1bf5bfcff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 40432,
            "upload_time": "2023-09-14T18:53:28",
            "upload_time_iso_8601": "2023-09-14T18:53:28.882484Z",
            "url": "https://files.pythonhosted.org/packages/b7/ab/e2365cd3cc0e05613fd178cace777ba7df9faf54f34c0137788ae55dc522/aws_embedded_metrics-3.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c1081bb1f7392cd9c3a65c4571a7f7286056ec52b3cd3d432485ca2b9907e0f9",
                "md5": "7fb4ef7dd9be6fe6c615cef1c41f4361",
                "sha256": "f235f87ab25ff328f6f3afca1c6b3218e81eea6e96e6aee012d368bb813fae7b"
            },
            "downloads": -1,
            "filename": "aws-embedded-metrics-3.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7fb4ef7dd9be6fe6c615cef1c41f4361",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 25402,
            "upload_time": "2023-09-14T18:53:31",
            "upload_time_iso_8601": "2023-09-14T18:53:31.139925Z",
            "url": "https://files.pythonhosted.org/packages/c1/08/1bb1f7392cd9c3a65c4571a7f7286056ec52b3cd3d432485ca2b9907e0f9/aws-embedded-metrics-3.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-14 18:53:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "awslabs",
    "github_project": "aws-embedded-metrics-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "aws-embedded-metrics"
}
        
Elapsed time: 0.39952s