github.com/mweagle/Sparta@v1.15.0/docs_source/content/reference/operations/metrics_publisher.md (about)

     1  ---
     2  date: 2018-12-01 06:02:32
     3  title: Metrics Publisher
     4  weight: 30
     5  ---
     6  
     7  AWS Lambda is tightly integrated with other AWS services and provides excellent
     8  opportunities for improving your service's observability posture. Sparta includes
     9  a [CloudWatch Metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/working_with_metrics.html)
    10  publisher that periodically publishes metrics to CloudWatch.
    11  
    12  This periodic task publishes environment-level metrics that have been
    13  detected by the [gopsutil](https://github.com/shirou/gopsutil) package. Metrics include:
    14  
    15  - CPU
    16    - Percent used
    17  - Disk
    18    - Percent used
    19  - Host
    20    - Uptime (milliseconds)
    21  - Load
    22    - Load1 (no units)
    23    - Load5 (no units)
    24    - Load15 (no units)
    25  - Network
    26    - NetBytesSent (bytes)
    27    - NetBytesRecv (bytes)
    28    - NetErrin (count)
    29    - NetErrout (count)
    30  
    31  You can provide an optional `map[string]string` set of dimensions to which the metrics
    32  should be published. This enables targeted [alert conditions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Create-alarm-on-metric-math-expression.html)
    33  that can be used to improve system resiliency.
    34  
    35  To register the metric publisher, call the `RegisterLambdaUtilizationMetricPublisher` at some
    36  point in your `main()` call graph. For example:
    37  
    38  ```go
    39  import spartaCloudWatch "github.com/mweagle/Sparta/aws/cloudwatch"
    40  func main() {
    41    ...
    42    spartaCloudWatch.RegisterLambdaUtilizationMetricPublisher(map[string]string{
    43      "BuildId":    sparta.StampedBuildID,
    44    })
    45    ...
    46  }
    47  ```
    48  
    49  The optional `map[string]string` parameter is the custom Name-Value pairs to use as a [CloudWatch Dimension](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Dimension)