# AWS Cost Explorer by HTTP ## Overview The template to monitor AWS Cost Explorer by HTTP via Zabbix, which works without any external scripts. Most of the metrics are collected in one go, thanks to Zabbix bulk data collection. *NOTE* This template uses the Cost Explorer API calls to list and retrieve metrics. For more information, please refer to the (Cost Explorer pricing)[https://aws.amazon.com/aws-cost-management/aws-cost-explorer/pricing/] page. ## Requirements Zabbix version: 7.0 and higher. ## Tested versions This template has been tested on: - AWS by HTTP ## Configuration > Zabbix should be configured according to the instructions in the [Templates out of the box](https://www.zabbix.com/documentation/7.0/manual/config/templates_out_of_the_box) section. ## Setup Before using the template, you need to create an IAM policy for the Zabbix role in your AWS account with the necessary permissions. * [IAM policies for AWS Cost Management](https://docs.aws.amazon.com/cost-management/latest/userguide/billing-permissions-ref.html) Add the following required permissions to your Zabbix IAM policy in order to collect metrics. ```json { "Version": "2012-10-17", "Statement": [ { "Action": [ "ce:*" ], "Effect": "Allow", "Resource": "*" } ] } ``` Set macros {$AWS.ACCESS.KEY.ID}, {$AWS.SECRET.ACCESS.KEY}. For more information about managing access keys, see the [official documentation](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys). Also, see the Macros section for a list of macros used in LLD filters. Additional information about metrics and used API methods: * [Describe AWS Cost Explore API actions](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Operations.html) ### Macros used |Name|Description|Default| |----|-----------|-------| |{$AWS.PROXY}|
Sets HTTP proxy value. If this macro is empty, then no proxy is used.
|| |{$AWS.ACCESS.KEY.ID}|Access key ID.
|| |{$AWS.SECRET.ACCESS.KEY}|Secret access key.
|| |{$AWS.BILLING.REGION}|Amazon Billing region code.
|`us-east-1`| |{$AWS.BILLING.MONTH}|Months to get historical data from AWS Cost Explore API, no more than 12 months.
|`11`| |{$AWS.BILLING.LLD.FILTER.SERVICE.MATCHES}|Filter of discoverable discovered billing service by name.
|`.*`| |{$AWS.BILLING.LLD.FILTER.SERVICE.NOT_MATCHES}|Filter to exclude discovered billing service by name.
|`CHANGE_IF_NEEDED`| ### Items |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |AWS Cost: Get monthly costs||Script|aws.get.monthly.costs**Preprocessing**
Check for not supported value
⛔️Custom on fail: Discard value
Get raw data on the daily costs by service
|Script|aws.get.daily.costs**Preprocessing**
Check for not supported value
⛔️Custom on fail: Discard value
Discovery of daily blended costs by services.
|Dependent item|aws.daily.services.costs.discovery**Preprocessing**
JSON Path: `$..Groups.first()`
The daily blended cost of the {#AWS.BILLING.SERVICE.NAME} service for the previous day.
|Dependent item|aws.daily.service.cost["{#AWS.BILLING.SERVICE.NAME}"]**Preprocessing**
JSON Path: `The text is too long. Please see the template.`
⛔️Custom on fail: Discard value
Discovery of monthly costs by services.
|Dependent item|aws.cost.service.monthly.discovery**Preprocessing**
JSON Path: `$.monthly_service_costs`
The monthly cost by service {#AWS.BILLING.SERVICE.NAME}.
|Dependent item|aws.monthly.service.cost["{#AWS.BILLING.SERVICE.NAME}", "{#AWS.BILLING.MONTH}"]**Preprocessing**
JSON Path: `The text is too long. Please see the template.`
⛔️Custom on fail: Discard value
JSON Path: `The text is too long. Please see the template.`
⛔️Custom on fail: Discard value
Discovery of monthly costs.
|Dependent item|aws.monthly.cost.discovery**Preprocessing**
JSON Path: `$.monthly_costs`
The blended cost by month {#AWS.BILLING.MONTH}.
|Dependent item|aws.monthly.cost["{#AWS.BILLING.MONTH}"]**Preprocessing**
JSON Path: `The text is too long. Please see the template.`
⛔️Custom on fail: Discard value
Discard unchanged with heartbeat: `3h`