forked from aws-samples/amazon-bedrock-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbedrock_cloudwatch_dashboard.py
133 lines (128 loc) · 3.68 KB
/
bedrock_cloudwatch_dashboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import boto3
import json
client = boto3.client('cloudwatch')
region = "us-west-2"
dashboard_body={
"variables": [],
"widgets": [
{
"height": 6,
"width": 6,
"y": 0,
"x": 6,
"type": "metric",
"properties": {
"metrics": [
[ "AWS/Bedrock", "Invocations", { "region": region } ]
],
"view": "timeSeries",
"stacked": False,
"region": region,
"title": "Invocation Count",
"period": 60,
"stat": "Sum"
}
},
{
"height": 6,
"width": 6,
"y": 6,
"x": 6,
"type": "metric",
"properties": {
"metrics": [
[ "AWS/Bedrock", "InvocationLatency", { "region": region } ]
],
"view": "timeSeries",
"stacked": False,
"region": region,
"period": 60,
"stat": "Average",
"title": "Invocation Latency"
}
},
{
"height": 6,
"width": 6,
"y": 12,
"x": 0,
"type": "metric",
"properties": {
"view": "timeSeries",
"stacked": False,
"metrics": [
[ "AWS/Bedrock", "InvocationClientErrors" ]
],
"region": region,
"title": "Invocation Error Count"
}
},
{
"height": 6,
"width": 6,
"y": 6,
"x": 0,
"type": "metric",
"properties": {
"metrics": [
[ { "expression": "AVG(METRICS())", "label": "Expression1", "id": "e1", "visible": False, "region": region, "period": 60 } ],
[ "AWS/Bedrock", "Invocations", { "id": "m1", "region": region } ]
],
"view": "gauge",
"region": region,
"stat": "Average",
"period": 60,
"yAxis": {
"left": {
"min": 0,
"max": 100000
}
},
"liveData": True,
"title": "Invocations Per Minute"
}
},
{
"height": 6,
"width": 6,
"y": 0,
"x": 0,
"type": "metric",
"properties": {
"metrics": [
[ "AWS/Bedrock", "InputTokenCount", { "region": region } ],
[ ".", "OutputTokenCount", { "region": region } ]
],
"view": "timeSeries",
"stacked": False,
"region": region,
"title": "Token Counts",
"period": 60,
"stat": "Average"
}
},
{
"type": "metric",
"x": 6,
"y": 12,
"width": 6,
"height": 6,
"properties": {
"metrics": [
[ "AWS/Bedrock", "OutputImageCount", { "region": region } ]
],
"view": "timeSeries",
"stacked": False,
"region": region,
"title": "Output Image Count",
"period": 60,
"stat": "Average"
}
}
]
}
print(json.dumps(dashboard_body))
response = client.put_dashboard(
DashboardName="AmazonBedrockDashboard",
DashboardBody=json.dumps(dashboard_body)
)