@rawdash/connector-aws-cloudwatch 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,22 +1,59 @@
1
+ <!-- This file is generated from connector metadata by scripts/generate-connector-docs.ts. Do not edit by hand. -->
2
+
1
3
  # @rawdash/connector-aws-cloudwatch
2
4
 
3
- Rawdash connector for [AWS CloudWatch](https://docs.aws.amazon.com/cloudwatch/) — pulls the specific metric queries you declare into the `metric` storage shape via the [`GetMetricData`](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html) API.
5
+ [![npm version](https://img.shields.io/npm/v/@rawdash/connector-aws-cloudwatch)](https://www.npmjs.com/package/@rawdash/connector-aws-cloudwatch)
6
+ [![license](https://img.shields.io/npm/l/@rawdash/connector-aws-cloudwatch)](https://github.com/rawdash/rawdash/blob/main/LICENSE)
7
+
8
+ Pull declared CloudWatch metric time series (any namespace, statistic, and period) into a single metric series per query.
4
9
 
5
- CloudWatch is far too broad to mirror wholesale, so this connector takes a list of explicit **metric queries** (namespace + metric + statistic + period + dimensions) and emits one metric sample per returned data point. Requests are signed with AWS Signature V4 using the Web Crypto API the package carries **no AWS SDK dependency**.
10
+ > **Cost & frequency.** CloudWatch GetMetricData is billed per metric requested on the paid tier; high-frequency syncs over many metrics add up.
6
11
 
7
- ## Auth setup
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install @rawdash/connector-aws-cloudwatch
16
+ ```
8
17
 
9
- Two mutually exclusive modes, selected by which fields you supply:
18
+ ## Authentication
10
19
 
11
- - **Static credentials** `accessKeyId` + `secretAccessKey` for an IAM principal with the `cloudwatch:GetMetricData` permission. Create an access key under AWS Console → **IAM → Users → Security credentials**.
12
- - **Role assumption** — `roleArn` (plus optional `externalId`). The connector calls STS `AssumeRole` to obtain temporary credentials, then signs CloudWatch with them. The _base_ credentials used for the `AssumeRole` call come from `accessKeyId`/`secretAccessKey` if provided, otherwise from the ambient AWS environment (`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN`) — the path rawdash cloud uses with its task role.
20
+ Authenticate with either static IAM access keys or an assumed IAM role (STS). The principal needs cloudwatch:GetMetricData on the target region.
13
21
 
14
- The role's trust policy must allow your base principal to `sts:AssumeRole`, and (if you set `externalId`) must require that external ID.
22
+ 1. Create an IAM user or role with a policy granting `cloudwatch:GetMetricData`.
23
+ 2. For static credentials, generate an access key ID and secret access key for that IAM user and store them as secrets.
24
+ 3. For role assumption, set `roleArn` to the role to assume (and `externalId` if its trust policy requires one); the base credentials must be allowed to `sts:AssumeRole` it.
25
+ 4. Set `region` to the AWS region whose CloudWatch endpoint holds the metrics, e.g. `us-east-1`.
26
+ 5. Reference the keys from config, e.g. `accessKeyId: secret("AWS_ACCESS_KEY_ID")` and `secretAccessKey: secret("AWS_SECRET_ACCESS_KEY")`.
15
27
 
16
28
  ## Configuration
17
29
 
30
+ | Field | Type | Required | Description |
31
+ | ----------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
32
+ | `region` | string | Yes | The AWS region whose service endpoint you want to call, e.g. us-east-1. |
33
+ | `accessKeyId` | secret | No | AWS access key ID for an IAM principal with permission to call the relevant service. Use together with the secret access key for static-credential auth. |
34
+ | `secretAccessKey` | secret | No | AWS secret access key paired with the access key ID above. |
35
+ | `roleArn` | string | No | IAM role to assume via STS instead of using static keys. The base credentials (the access key above, or the ambient AWS environment) must be allowed to sts:AssumeRole this role. |
36
+ | `externalId` | string | No | External ID required by the trust policy of the role being assumed. Only used with Role ARN. |
37
+ | `metricQueries` | array | Yes | CloudWatch is too broad to mirror wholesale; declare the specific metrics to pull. Each query needs an id, namespace, metric name, statistic, and period (seconds, multiple of 60), with optional dimensions. |
38
+ | `lookbackMinutes` | number | No | How far back to pull data points on a full sync when the host does not supply a since bound. Defaults to 180. |
39
+
40
+ ## Resources
41
+
42
+ - **`<namespace>/<metric>`** _(metric)_ - One metric series per declared metric query. The series name is the query namespace/metric (e.g. `AWS/EC2/CPUUtilization`), so the actual keys depend on the configured `metricQueries`. Each sample carries the query statistic, period, query id, the upstream status code, and label as attributes.
43
+ - Endpoint: `POST / (GetMetricData)`
44
+ - Granularity: Per query period (periodSeconds, a multiple of 60)
45
+ - Dimensions: `stat`, `period`, `queryId`, `statusCode`, `label`
46
+ - Each sync replaces the full set of samples for the metric names it owns (idempotent).
47
+
48
+ ## Example
49
+
18
50
  ```ts
19
- import { secret } from '@rawdash/core';
51
+ import {
52
+ defineConfig,
53
+ defineDashboard,
54
+ defineMetric,
55
+ secret,
56
+ } from '@rawdash/core';
20
57
 
21
58
  const cloudwatch = {
22
59
  name: 'cloudwatch',
@@ -25,8 +62,6 @@ const cloudwatch = {
25
62
  region: 'us-east-1',
26
63
  accessKeyId: secret('AWS_ACCESS_KEY_ID'),
27
64
  secretAccessKey: secret('AWS_SECRET_ACCESS_KEY'),
28
- // roleArn: 'arn:aws:iam::123456789012:role/rawdash-cloudwatch', // instead of static keys
29
- // externalId: 'rawdash', // optional, with roleArn
30
65
  metricQueries: [
31
66
  {
32
67
  id: 'ec2_cpu',
@@ -36,49 +71,9 @@ const cloudwatch = {
36
71
  periodSeconds: 300,
37
72
  dimensions: { InstanceId: 'i-0123456789abcdef0' },
38
73
  },
39
- {
40
- id: 'alb_5xx',
41
- namespace: 'AWS/ApplicationELB',
42
- metric: 'HTTPCode_Target_5XX_Count',
43
- stat: 'Sum',
44
- periodSeconds: 300,
45
- },
46
74
  ],
47
- // lookbackMinutes: 180, // optional — full-sync window when no `since` is supplied (default 180)
48
75
  },
49
76
  };
50
- ```
51
-
52
- Register the connector class when mounting the engine:
53
-
54
- ```ts
55
- import { CloudWatchConnector } from '@rawdash/connector-aws-cloudwatch';
56
- import { mountEngine } from '@rawdash/hono';
57
-
58
- mountEngine(config, {
59
- connectorRegistry: { 'aws-cloudwatch': CloudWatchConnector },
60
- });
61
- ```
62
-
63
- ### Metric queries
64
-
65
- Each entry of `metricQueries` becomes one [`MetricDataQuery`](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDataQuery.html):
66
-
67
- | Field | Notes |
68
- | --------------- | ----------------------------------------------------------------------------------- |
69
- | `id` | Must match `^[a-z][a-zA-Z0-9_]*$` (CloudWatch's query-id rule). |
70
- | `namespace` | e.g. `AWS/EC2`, `AWS/Lambda`, or a custom namespace. |
71
- | `metric` | The metric name within that namespace. |
72
- | `stat` | Any CloudWatch statistic — `Average`, `Sum`, `Minimum`, `Maximum`, `p99`, etc. |
73
- | `periodSeconds` | Aggregation period, in seconds. Must be a multiple of 60 (minimum 1 minute). |
74
- | `dimensions` | Optional `{ Name: Value }` map narrowing the metric (e.g. `{ InstanceId: 'i-…' }`). |
75
-
76
- Queries are batched at most 500 per `GetMetricData` call, and `NextToken` pagination is followed automatically.
77
-
78
- ### Example dashboard
79
-
80
- ```ts
81
- import { defineConfig, defineDashboard, defineMetric } from '@rawdash/core';
82
77
 
83
78
  export default defineConfig({
84
79
  connectors: [cloudwatch],
@@ -87,15 +82,13 @@ export default defineConfig({
87
82
  widgets: {
88
83
  cpu: {
89
84
  kind: 'timeseries',
90
- title: 'EC2 CPU %',
85
+ title: 'EC2 CPU Utilization',
91
86
  window: '24h',
92
87
  metric: defineMetric({
93
88
  connector: cloudwatch,
94
89
  shape: 'metric',
95
90
  name: 'AWS/EC2/CPUUtilization',
96
91
  fn: 'avg',
97
- window: '24h',
98
- groupBy: { field: 'ts', granularity: 'hour' },
99
92
  }),
100
93
  },
101
94
  },
@@ -104,38 +97,23 @@ export default defineConfig({
104
97
  });
105
98
  ```
106
99
 
107
- ## Data model
108
-
109
- | Storage shape | Metric name | Value / attributes |
110
- | ------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
111
- | metric | `${namespace}/${metric}` | `value` = the data point for that period; attributes = the query's `dimensions` plus `stat`, `period`, `queryId`, `label`, `statusCode` |
112
-
113
- Timestamps are stored as Unix epoch milliseconds. Data points with a non-finite value or unparseable timestamp are skipped.
114
-
115
- ## Schemas
116
-
117
- `CloudWatchConnector.schemas.metric_data` is the Zod schema for the logical `GetMetricData` response (the connector parses the AWS Query-protocol XML into this shape). It powers the cloud shape-drift pipeline and the package's property tests.
118
-
119
- ## Sync behaviour
120
-
121
- - **Window**: when the host supplies `since`, the connector fetches `[since, now]`. Otherwise a full sync uses `lookbackMinutes` (default 180) and a `latest` sync uses a short window covering the last few periods.
122
- - **Idempotent**: every sync replaces the full set of samples for the metric names it owns (`storage.metrics(samples, { names })`), so re-syncing the same window converges.
123
- - **Batched + paginated**: up to 500 queries per `GetMetricData` request, with `NextToken` followed until exhausted.
124
- - **Single-call**: the windowed pull fits in one invocation, so `sync()` returns `{ done: true }` without a resume cursor.
100
+ ## Rate limits
125
101
 
126
- ## Errors
102
+ GetMetricData is batched at most 500 metrics per call with NextToken pagination; throttling (Throttling / RequestLimitExceeded / TooManyRequests) is retried with backoff.
127
103
 
128
- CloudWatch and STS return AWS error codes inside the response body even on a `400`, so the connector inspects the body and maps:
104
+ ## Limitations
129
105
 
130
- - `Throttling` / `RequestLimitExceeded` / `TooManyRequests` `RateLimitError` host backs off and reschedules.
131
- - `AccessDenied` / `InvalidClientTokenId` / `SignatureDoesNotMatch` / `AuthFailure` `AuthError` host pauses until credentials are fixed.
132
- - `5xx` `TransientError` host retries on the next tick.
106
+ - CloudWatch is too broad to mirror wholesale; only the metrics declared in `metricQueries` are synced; there is no automatic metric discovery.
107
+ - The series name is derived from the query namespace/metric, so two queries against the same metric with different statistics or dimensions share one series name and are distinguished only by sample attributes.
108
+ - Each query period must be a multiple of 60 seconds; sub-minute resolution is not supported.
109
+ - A full sync uses lookbackMinutes; a latest sync uses a short window covering the last few periods.
133
110
 
134
- ## Out of scope
111
+ ## Links
135
112
 
136
- - **AWS Cost Explorer** — tracked separately.
137
- - **CloudWatch Logs / Logs Insights** — a different API surface; deferred.
113
+ - [Rawdash docs](https://rawdash.dev/docs/connectors/)
114
+ - [Amazon Web Services API docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html)
115
+ - [GitHub](https://github.com/rawdash/rawdash)
138
116
 
139
- ## Property tests
117
+ ## License
140
118
 
141
- `src/property.test.ts` generates synthetic `GetMetricData` responses from the Zod schema, serializes them to the Query-protocol XML the connector parses, pipes them through `connector.sync()` against `InMemoryStorage`, and asserts universal invariants (finite metric values/timestamps, no `undefined` reaching storage, no throws) plus one metric sample per paired timestamp/value.
119
+ Apache-2.0
package/dist/index.d.ts CHANGED
@@ -1,16 +1,8 @@
1
- import { BaseConnector, ConnectorContext, SyncOptions, StorageHandle, SyncResult } from '@rawdash/core';
1
+ import { BaseAWSConnector, BaseAWSSettings } from '@rawdash/connector-aws-shared';
2
+ import { ConnectorCost, ConnectorContext, SyncOptions, StorageHandle, SyncResult, ConnectorDoc } from '@rawdash/core';
2
3
  import { z } from 'zod';
3
4
 
4
5
  declare const configFields: z.ZodObject<{
5
- region: z.ZodString;
6
- accessKeyId: z.ZodOptional<z.ZodObject<{
7
- $secret: z.ZodString;
8
- }, z.core.$strip>>;
9
- secretAccessKey: z.ZodOptional<z.ZodObject<{
10
- $secret: z.ZodString;
11
- }, z.core.$strip>>;
12
- roleArn: z.ZodOptional<z.ZodString>;
13
- externalId: z.ZodOptional<z.ZodString>;
14
6
  metricQueries: z.ZodArray<z.ZodObject<{
15
7
  id: z.ZodString;
16
8
  namespace: z.ZodString;
@@ -20,7 +12,17 @@ declare const configFields: z.ZodObject<{
20
12
  dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
21
13
  }, z.core.$strip>>;
22
14
  lookbackMinutes: z.ZodOptional<z.ZodNumber>;
15
+ region: z.ZodString;
16
+ accessKeyId: z.ZodOptional<z.ZodObject<{
17
+ $secret: z.ZodString;
18
+ }, z.core.$strip>>;
19
+ secretAccessKey: z.ZodOptional<z.ZodObject<{
20
+ $secret: z.ZodString;
21
+ }, z.core.$strip>>;
22
+ roleArn: z.ZodOptional<z.ZodString>;
23
+ externalId: z.ZodOptional<z.ZodString>;
23
24
  }, z.core.$strip>;
25
+ declare const doc: ConnectorDoc;
24
26
  interface CloudWatchMetricQuery {
25
27
  id: string;
26
28
  namespace: string;
@@ -29,26 +31,100 @@ interface CloudWatchMetricQuery {
29
31
  periodSeconds: number;
30
32
  dimensions?: Record<string, string>;
31
33
  }
32
- interface CloudWatchSettings {
33
- region: string;
34
- roleArn?: string;
35
- externalId?: string;
34
+ interface CloudWatchSettings extends BaseAWSSettings {
36
35
  metricQueries: CloudWatchMetricQuery[];
37
36
  lookbackMinutes?: number;
38
37
  }
39
- declare const cloudWatchCredentials: {
40
- accessKeyId: {
41
- description: string;
42
- auth: "optional";
43
- };
44
- secretAccessKey: {
45
- description: string;
46
- auth: "optional";
38
+ declare const awsCloudwatchResources: {
39
+ readonly '<namespace>/<metric>': {
40
+ readonly shape: "metric";
41
+ readonly dynamic: true;
42
+ readonly description: "One metric series per declared metric query. The series name is the query namespace/metric (e.g. `AWS/EC2/CPUUtilization`), so the actual keys depend on the configured `metricQueries`. Each sample carries the query statistic, period, query id, the upstream status code, and label as attributes.";
43
+ readonly endpoint: "POST / (GetMetricData)";
44
+ readonly granularity: "Per query period (periodSeconds, a multiple of 60)";
45
+ readonly notes: "Each sync replaces the full set of samples for the metric names it owns (idempotent).";
46
+ readonly dimensions: [{
47
+ readonly name: "stat";
48
+ readonly description: "The CloudWatch statistic requested for the query, e.g. Average, Sum, or p99.";
49
+ }, {
50
+ readonly name: "period";
51
+ readonly description: "The aggregation period in seconds for the data points.";
52
+ }, {
53
+ readonly name: "queryId";
54
+ readonly description: "The configured id of the metric query that produced the sample.";
55
+ }, {
56
+ readonly name: "statusCode";
57
+ readonly description: "GetMetricData result status for the series (Complete, PartialData, InternalError, or Forbidden).";
58
+ }, {
59
+ readonly name: "label";
60
+ readonly description: "The human-readable label CloudWatch returned for the series.";
61
+ }];
62
+ readonly responses: {
63
+ readonly metric_data: z.ZodObject<{
64
+ MetricDataResults: z.ZodArray<z.ZodObject<{
65
+ Id: z.ZodString;
66
+ Label: z.ZodString;
67
+ Timestamps: z.ZodArray<z.ZodISODateTime>;
68
+ Values: z.ZodArray<z.ZodNumber>;
69
+ StatusCode: z.ZodEnum<{
70
+ Complete: "Complete";
71
+ InternalError: "InternalError";
72
+ PartialData: "PartialData";
73
+ Forbidden: "Forbidden";
74
+ }>;
75
+ }, z.core.$strip>>;
76
+ NextToken: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strip>;
78
+ };
47
79
  };
48
80
  };
49
- type CloudWatchCredentials = typeof cloudWatchCredentials;
50
- declare class CloudWatchConnector extends BaseConnector<CloudWatchSettings, CloudWatchCredentials> {
81
+ declare const id = "aws-cloudwatch";
82
+ declare const cost: ConnectorCost;
83
+ declare class CloudWatchConnector extends BaseAWSConnector<CloudWatchSettings> {
51
84
  static readonly id = "aws-cloudwatch";
85
+ static readonly resources: {
86
+ readonly '<namespace>/<metric>': {
87
+ readonly shape: "metric";
88
+ readonly dynamic: true;
89
+ readonly description: "One metric series per declared metric query. The series name is the query namespace/metric (e.g. `AWS/EC2/CPUUtilization`), so the actual keys depend on the configured `metricQueries`. Each sample carries the query statistic, period, query id, the upstream status code, and label as attributes.";
90
+ readonly endpoint: "POST / (GetMetricData)";
91
+ readonly granularity: "Per query period (periodSeconds, a multiple of 60)";
92
+ readonly notes: "Each sync replaces the full set of samples for the metric names it owns (idempotent).";
93
+ readonly dimensions: [{
94
+ readonly name: "stat";
95
+ readonly description: "The CloudWatch statistic requested for the query, e.g. Average, Sum, or p99.";
96
+ }, {
97
+ readonly name: "period";
98
+ readonly description: "The aggregation period in seconds for the data points.";
99
+ }, {
100
+ readonly name: "queryId";
101
+ readonly description: "The configured id of the metric query that produced the sample.";
102
+ }, {
103
+ readonly name: "statusCode";
104
+ readonly description: "GetMetricData result status for the series (Complete, PartialData, InternalError, or Forbidden).";
105
+ }, {
106
+ readonly name: "label";
107
+ readonly description: "The human-readable label CloudWatch returned for the series.";
108
+ }];
109
+ readonly responses: {
110
+ readonly metric_data: z.ZodObject<{
111
+ MetricDataResults: z.ZodArray<z.ZodObject<{
112
+ Id: z.ZodString;
113
+ Label: z.ZodString;
114
+ Timestamps: z.ZodArray<z.ZodISODateTime>;
115
+ Values: z.ZodArray<z.ZodNumber>;
116
+ StatusCode: z.ZodEnum<{
117
+ Complete: "Complete";
118
+ InternalError: "InternalError";
119
+ PartialData: "PartialData";
120
+ Forbidden: "Forbidden";
121
+ }>;
122
+ }, z.core.$strip>>;
123
+ NextToken: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>;
125
+ };
126
+ };
127
+ };
52
128
  static readonly schemas: {
53
129
  readonly metric_data: z.ZodObject<{
54
130
  MetricDataResults: z.ZodArray<z.ZodObject<{
@@ -65,30 +141,14 @@ declare class CloudWatchConnector extends BaseConnector<CloudWatchSettings, Clou
65
141
  }, z.core.$strip>>;
66
142
  NextToken: z.ZodOptional<z.ZodString>;
67
143
  }, z.core.$strip>;
68
- };
144
+ } & Readonly<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
145
+ static readonly cost: ConnectorCost;
69
146
  static create(input: unknown, ctx?: ConnectorContext): CloudWatchConnector;
70
147
  readonly id = "aws-cloudwatch";
71
- readonly credentials: {
72
- accessKeyId: {
73
- description: string;
74
- auth: "optional";
75
- };
76
- secretAccessKey: {
77
- description: string;
78
- auth: "optional";
79
- };
80
- };
81
- private assumedCreds;
82
- private baseCredentials;
83
- private resolveSigningCredentials;
84
- private assumeRole;
85
- private cacheAssumedCredentials;
86
- private signedPost;
87
- private classifyAwsError;
88
148
  private computeWindow;
89
149
  private buildGetMetricDataBody;
90
150
  sync(options: SyncOptions, storage: StorageHandle, signal?: AbortSignal): Promise<SyncResult>;
91
151
  private collectSamples;
92
152
  }
93
153
 
94
- export { CloudWatchConnector, type CloudWatchMetricQuery, type CloudWatchSettings, configFields, CloudWatchConnector as default };
154
+ export { CloudWatchConnector, type CloudWatchMetricQuery, type CloudWatchSettings, configFields, cost, CloudWatchConnector as default, doc, id, awsCloudwatchResources as resources };