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