| 1 | import type * as Credentials from "@distilled.cloud/aws/Credentials"; |
| 2 | import type * as SigV4 from "@distilled.cloud/aws/SigV4"; |
| 3 | import type * as Effect from "effect/Effect"; |
| 4 | import * as Binding from "../../Binding.ts"; |
| 5 | import type { |
| 6 | PrometheusApiError, |
| 7 | PrometheusSeries, |
| 8 | PrometheusTime, |
| 9 | } from "./PrometheusTypes.ts"; |
| 10 | import type { Workspace } from "./Workspace.ts"; |
| 11 | |
| 12 | export interface GetSeriesRequest { |
| 13 | /** Series selectors — at least one is required, e.g. `['up', 'job:.*']`. */ |
| 14 | match: string[]; |
| 15 | /** Start of the lookup range. A `Date`, Unix seconds, or RFC 3339 string. */ |
| 16 | start?: PrometheusTime; |
| 17 | /** End of the lookup range. A `Date`, Unix seconds, or RFC 3339 string. */ |
| 18 | end?: PrometheusTime; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Runtime binding for `aps:GetSeries` — find series (full label sets) that |
| 23 | * match a selector via an AMP {@link Workspace}'s Prometheus-compatible |
| 24 | * `api/v1/series` endpoint, SigV4-signed with the host Function's credentials. |
| 25 | * |
| 26 | * ### Finding Series |
| 27 | * **Example:** Match Series by Selector |
| 28 | * ```typescript |
| 29 | * const getSeries = yield* AMP.GetSeries(workspace); |
| 30 | * const series = yield* getSeries({ match: ['{__name__="up"}'] }); |
| 31 | * // [{ __name__: "up", job: "api", instance: "..." }, ...] |
| 32 | * ``` |
| 33 | * |
| 34 | * @binding |
| 35 | */ |
| 36 | export interface GetSeries extends Binding.Service< |
| 37 | GetSeries, |
| 38 | "AWS.AMP.GetSeries", |
| 39 | ( |
| 40 | workspace: Workspace, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request: GetSeriesRequest, |
| 44 | ) => Effect.Effect< |
| 45 | PrometheusSeries[], |
| 46 | PrometheusApiError | Credentials.CredentialsError | SigV4.SigningError |
| 47 | > |
| 48 | > |
| 49 | > {} |
| 50 | export const GetSeries = Binding.Service<GetSeries>("AWS.AMP.GetSeries"); |