원클릭으로
mimir-metrics
Querying Prometheus/Mimir metrics and registering new metrics in the central metrics registry.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Querying Prometheus/Mimir metrics and registering new metrics in the central metrics registry.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
How to build UI in this repo — the bui (@backstage/ui) design system vs legacy @backstage/core-components + MUI v4, which to reach for, and how to read Backstage Storybook component/story source. Use when creating or changing pages, cards, layouts, buttons, or any frontend component.
Patterns for implementing tables. Covers the bui Table ('@backstage/ui') — preferred for new, simple tables — and the feature-rich '@backstage/core-components' Table with search, filtering, and column-visibility persistence.
Common rules for working with this repository
Read, classify, and triage Sentry issues for this Backstage app, propose mitigations, and decide their disposition (fix, resolve, mute, or escalate). Use when given a Sentry issue URL (giantswarm.sentry.io/issues/...), asked to investigate a Sentry error/exception/CSP violation, asked why an image/script/style/font was blocked on a page, or asked to mute/ignore noisy Sentry issues.
Build Backstage backend plugins with createBackendPlugin and core services: DI, httpRouter, secure-by-default auth, Knex DB, routes, testing. Use for APIs and background jobs.
Build Backstage frontend plugins with the new Frontend System: createFrontendPlugin, blueprints, routes, Utility APIs, testing. Use for pages, nav, entity content, or cards.
| name | mimir-metrics |
| description | Querying Prometheus/Mimir metrics and registering new metrics in the central metrics registry. |
All Prometheus/Mimir metrics the application queries are registered in a central file:
plugins/gs/src/apis/mimir/metrics.ts
Every metric used in a PromQL query must be defined here. This ensures a single place to see which metrics the application depends on.
Add a new exported constant using PascalCase, with as const satisfies PrometheusMetric:
export const MyNewMetric = {
name: 'my_new_metric_name',
description: 'What this metric measures.',
type: 'gauge', // 'counter' | 'gauge' | 'histogram' | 'summary'
source: 'exporter-name', // e.g. 'cAdvisor', 'kube-state-metrics'
} as const satisfies PrometheusMetric;
Then add it to the MetricsRegistry array in the same file.
Import the metric constant and reference its .name property in PromQL strings:
import { MyNewMetric } from '../../apis/mimir/metrics';
const query = `sum(rate(${MyNewMetric.name}{namespace="${ns}"}[5m]))`;
Never use raw metric name strings in queries — always go through the registry.
useMimirQuery hook (plugins/gs/src/components/hooks/useMimirQuery.ts) — generic hook for executing a single PromQL instant query against Mimir via @tanstack/react-query (30s stale time). Requires an installationName and obtains an OIDC token from the Kubernetes auth provider.useMimirResourceUsage hook (plugins/gs/src/components/hooks/useMimirResourceUsage.ts) — higher-level hook that composes four useMimirQuery calls to fetch CPU usage, memory usage, resource requests, and resource limits for a deployment.MimirClient (plugins/gs/src/apis/mimir/MimirClient.ts) — API client implementing MimirApi. Sends GET requests to the backend at /mimir/query with the OIDC token in the X-Mimir-Token header.MimirApi / mimirApiRef (plugins/gs/src/apis/mimir/types.ts) — API interface and ref (ID: plugin.gs.mimir).MimirService (plugins/gs-backend/src/services/MimirService.ts) — looks up the installation's baseDomain from config, constructs the Mimir URL (https://observability.${baseDomain}/prometheus/api/v1/query), forwards the OIDC token as Authorization: Bearer, and sets X-Scope-OrgID: giantswarm.plugins/gs-backend/src/router.ts) — GET /mimir/query validates query, installationName, and X-Mimir-Token header via Zod, then delegates to MimirService.query().metrics.ts (see above).plugins/gs/src/components/hooks/ (e.g. useMimirMyData.ts).useMimirQuery for each PromQL query, referencing metric names from the registry.extractScalar / extractScalarByResource patterns from useMimirResourceUsage.ts for parsing responses.