Skip to content

Commit 1033e88

Browse files
authored
Merge pull request #33 from aws-samples/feature/job-cost-tracking
Feature/job cost tracking
2 parents 9660c83 + 76f6858 commit 1033e88

7 files changed

+954
-9
lines changed

README.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Amazon Managed Grafana since version 9.4 comes with Prometheus and Cloudwatch pl
176176
1. On the **Default Region** menu, choose your **AWS Region**.
177177
1. Choose **Save & test**.
178178

179-
#### 3. Add Amazon Athena Data source
179+
#### 3. Add Amazon Athena Data source for Job metrics
180180

181181
Before starting, you will retrieve the S3 bucket name created to store the AWS Batch jobs data through Amazon Athena.
182182

@@ -206,7 +206,39 @@ In the Amazon Managed Grafana dashboard:
206206
1. On the **Output Location** menu, copy paste the bucket value **s3://DOC-EXAMPLE-BUCKET**.
207207
1. Choose **Save & test**.
208208

209-
#### 4. Create dashboard
209+
210+
#### 4. Add Amazon Athena Data source for Cost
211+
212+
Before starting, you will retrieve the S3 bucket name created to store the AWS Batch jobs data through Amazon Athena.
213+
214+
In a terminal:
215+
216+
```bash
217+
sam list stack-outputs --stack-name ${BATCH_DASHBOARD_NAME} \
218+
--output json | \
219+
jq -r '.[] | select(.OutputKey=="AthenaSpillBucket") | .OutputValue'
220+
```
221+
222+
Copy the output that you will use in the setup of Amazon Athena data source in Amazon Managed Grafana.
223+
224+
In the Amazon Managed Grafana dashboard:
225+
226+
1. Select the **hamburger** menu on the left pane.<br/>
227+
1. Expand **Administration**<br/>
228+
<img alt="Grafana Data sources" src="docs/images/grafana-data-sources.png" width="30%" height="30%"> <br />
229+
1. Choose **Data sources**.
230+
1. Choose **Add new data source**.
231+
1. Choose **Amazon Athena**.<br />
232+
<img alt="Grafana athena" src="docs/images/grafana-athena-cost.png" width="50%" height="50%"> <br />
233+
1. For **Name**, enter your **Amazon Athena Cost Data**.
234+
1. On the **Default Region** menu, choose your **AWS Region**.
235+
1. On the **Data source** menu, choose **AwsDataCatalog**.
236+
1. On the **Database** menu, choose **athenacurcfn_a_w_s_batch_cost_report**.
237+
1. On the **Workgroup** menu, choose **primary**.
238+
1. On the **Output Location** menu, copy paste the bucket value **s3://DOC-EXAMPLE-BUCKET**.
239+
1. Choose **Save & test**.
240+
241+
#### 5. Create AWS Batch job metrics dashboard
210242

211243
To create a dashboard in Amazon Managed Grafana for AWS Batch, you will start from the template provided in this repository to generate dashboard for your environment.
212244

@@ -240,6 +272,26 @@ You will be redirected to the dashboard you imported.
240272
Once you will have your first AWS Batch jobs running.
241273
You will be able to see the data associated with it in the dashboard.
242274

275+
#### 6. Create AWS Batch compute cost dashboard
276+
277+
Similar to step 3, you will import an template dashboard in Amazon Managed Grafana for AWS Batch that covers Amazon EC2 compute cost.
278+
You can see an example below.
279+
<img alt="Grafana AWS Batch Dashboard" src="docs/images/grafana-batch-cost-dashboard.png" width="100%" height="70%"> <br />
280+
281+
To import the dashboard in Amazon Managed Grafana:
282+
1. Select the **squares** on the side menu.<br/>
283+
<img alt="Grafana import" src="docs/images/grafana-import.png" width="20%" height="20%"> <br />
284+
1. Choose **Import**. <br />
285+
1. Choose **Upload JSON file**, select the `batch-grafana-cost-dashboard.json` file.
286+
1. Choose **Load**.
287+
1. Select the **Athena** and **CloudWatch** data sources your created previously.
288+
<img alt="Grafana import dashboard" src="docs/images/grafana-dashboard-import-cost.png" width="60%" height="60%"> <br />
289+
1. Choose **Import**.
290+
291+
You will be redirected to the dashboard you imported.
292+
AWS Cost and Usage report takes 24 hours to be populated.
293+
Split cost data will be able for AWS Batch for jobs that are executed after this deployment.
294+
243295
## Clean up
244296
To delete the SAM application deployment, you can use the terminal and enter:
245297

0 commit comments

Comments
 (0)