The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type * as Credentials from "@distilled.cloud/aws/Credentials"; |
| 2 | import type * as SigV4 from "@distilled.cloud/aws/SigV4"; |
| 3 | import * as Binding from "alchemy/Binding"; |
| 4 | import type { SourceError } from "effect/ConfigProvider"; |
| 5 | import type * as Effect from "effect/Effect"; |
| 6 | import type { PrometheusApiError, PrometheusTime } from "./PrometheusTypes.ts"; |
| 7 | import type { Workspace } from "./Workspace.ts"; |
| 8 | |
| 9 | export interface GetLabelsRequest { |
| 10 | /** Series selectors restricting which series' labels are returned. */ |
| 11 | match?: string[]; |
| 12 | /** Start of the lookup range. A `Date`, Unix seconds, or RFC 3339 string. */ |
| 13 | start?: PrometheusTime; |
| 14 | /** End of the lookup range. A `Date`, Unix seconds, or RFC 3339 string. */ |
| 15 | end?: PrometheusTime; |
| 16 | } |
| 17 | |
| 18 | export interface GetLabelValuesRequest extends GetLabelsRequest { |
| 19 | /** Label name to list the values of, e.g. `"__name__"` or `"job"`. */ |
| 20 | label: string; |
| 21 | } |
| 22 | |
| 23 | export interface GetLabelsClient { |
| 24 | /** List label names (`api/v1/labels`). */ |
| 25 | labelNames( |
| 26 | request?: GetLabelsRequest, |
| 27 | ): Effect.Effect< |
| 28 | string[], |
| 29 | PrometheusApiError | Credentials.CredentialsError | SourceError | SigV4.SigningError |
| 30 | >; |
| 31 | /** List the values of one label (`api/v1/label/{name}/values`). */ |
| 32 | labelValues( |
| 33 | request: GetLabelValuesRequest, |
| 34 | ): Effect.Effect< |
| 35 | string[], |
| 36 | PrometheusApiError | Credentials.CredentialsError | SourceError | SigV4.SigningError |
| 37 | >; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Runtime binding for `aps:GetLabels` — list label names and label values |
| 42 | * from an AMP {@link Workspace}'s Prometheus-compatible query API, |
| 43 | * SigV4-signed with the host Function's credentials. |
| 44 | * |
| 45 | * ### Exploring Labels |
| 46 | * **Example:** List Label Names |
| 47 | * ```typescript |
| 48 | * const labels = yield* AMP.GetLabels(workspace); |
| 49 | * const names = yield* labels.labelNames(); |
| 50 | * ``` |
| 51 | * |
| 52 | * **Example:** List Metric Names |
| 53 | * ```typescript |
| 54 | * const metricNames = yield* labels.labelValues({ label: "__name__" }); |
| 55 | * ``` |
| 56 | * |
| 57 | * @binding |
| 58 | */ |
| 59 | export interface GetLabels extends Binding.Service< |
| 60 | GetLabels, |
| 61 | "AWS.AMP.GetLabels", |
| 62 | (workspace: Workspace) => Effect.Effect<GetLabelsClient> |
| 63 | > {} |
| 64 | export const GetLabels = Binding.Service<GetLabels>("AWS.AMP.GetLabels"); |