mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add Prometheus Helm 14.x metrics provider (#6157)
This commit is contained in:
parent
ba49ede36c
commit
f3ff5117e5
36
src/main/prometheus/helm-14.ts
Normal file
36
src/main/prometheus/helm-14.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { PrometheusLens } from "./lens";
|
||||||
|
import type { CoreV1Api } from "@kubernetes/client-node";
|
||||||
|
import type { PrometheusService } from "./provider-registry";
|
||||||
|
import { isRequestError } from "../../common/utils";
|
||||||
|
|
||||||
|
export class PrometheusHelm14 extends PrometheusLens {
|
||||||
|
readonly id: string = "helm14";
|
||||||
|
readonly name: string = "Helm 14.x";
|
||||||
|
readonly rateAccuracy: string = "5m";
|
||||||
|
readonly isConfigurable: boolean = true;
|
||||||
|
|
||||||
|
public async getPrometheusService(client: CoreV1Api): Promise<PrometheusService> {
|
||||||
|
try {
|
||||||
|
const selector = "app=prometheus,component=server,heritage=Helm";
|
||||||
|
const { body: { items: [service] }} = await client.listServiceForAllNamespaces(undefined, undefined, undefined, selector);
|
||||||
|
|
||||||
|
if (service?.metadata?.namespace && service.metadata.name && service.spec?.ports && service.metadata?.labels?.chart?.startsWith("prometheus-14")) {
|
||||||
|
return {
|
||||||
|
id: this.id,
|
||||||
|
namespace: service.metadata.namespace,
|
||||||
|
service: service.metadata.name,
|
||||||
|
port: service.spec.ports[0].port,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Failed to list services for Prometheus ${this.name} in all namespaces: ${isRequestError(error) ? error.response?.body.message : error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(`No service found for Prometheus ${this.name} from any namespace`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { PrometheusLens } from "../../prometheus/lens";
|
import { PrometheusLens } from "../../prometheus/lens";
|
||||||
import { PrometheusHelm } from "../../prometheus/helm";
|
import { PrometheusHelm } from "../../prometheus/helm";
|
||||||
|
import { PrometheusHelm14 } from "../../prometheus/helm-14";
|
||||||
import { PrometheusOperator } from "../../prometheus/operator";
|
import { PrometheusOperator } from "../../prometheus/operator";
|
||||||
import { PrometheusStacklight } from "../../prometheus/stacklight";
|
import { PrometheusStacklight } from "../../prometheus/stacklight";
|
||||||
import prometheusProviderRegistryInjectable from "../../prometheus/prometheus-provider-registry.injectable";
|
import prometheusProviderRegistryInjectable from "../../prometheus/prometheus-provider-registry.injectable";
|
||||||
@ -20,6 +21,7 @@ const setupPrometheusRegistryInjectable = getInjectable({
|
|||||||
run: () => {
|
run: () => {
|
||||||
prometheusProviderRegistry
|
prometheusProviderRegistry
|
||||||
.registerProvider(new PrometheusLens())
|
.registerProvider(new PrometheusLens())
|
||||||
|
.registerProvider(new PrometheusHelm14())
|
||||||
.registerProvider(new PrometheusHelm())
|
.registerProvider(new PrometheusHelm())
|
||||||
.registerProvider(new PrometheusOperator())
|
.registerProvider(new PrometheusOperator())
|
||||||
.registerProvider(new PrometheusStacklight());
|
.registerProvider(new PrometheusStacklight());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user