@stolostron/multicluster-sdk 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -4
- package/lib/api/useFleetPrometheusPoll.d.ts +70 -0
- package/lib/api/useFleetPrometheusPoll.d.ts.map +1 -1
- package/lib/api/useFleetPrometheusPoll.js +70 -0
- package/lib/api/useFleetPrometheusPoll.js.map +1 -1
- package/lib/api/useIsFleetObservabilityInstalled.d.ts +30 -2
- package/lib/api/useIsFleetObservabilityInstalled.d.ts.map +1 -1
- package/lib/api/useIsFleetObservabilityInstalled.js +30 -2
- package/lib/api/useIsFleetObservabilityInstalled.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -566,11 +566,74 @@ const [deployment, loaded, error] = useFleetK8sWatchResource({
|
|
|
566
566
|
|
|
567
567
|
### :gear: useFleetPrometheusPoll
|
|
568
568
|
|
|
569
|
+
A fleet version of [`usePrometheusPoll`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#useprometheuspoll) from
|
|
570
|
+
the [dynamic plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk) that polls Prometheus for metrics data from a specific cluster or across all clusters.
|
|
571
|
+
|
|
572
|
+
Although this is intended as a drop-in replacement for usePrometheusPoll there are a couple of considerations:
|
|
573
|
+
1. The Observabilty service must be running on the hub in order to access metric data outside of the hub. The useIsFleetObservabilityInstalled() hook can check this
|
|
574
|
+
2. The PromQL query will be different for clusters outside of the hub. The query may be completely different but at the very least it will contain the cluster name(s)
|
|
575
|
+
3. Ideally the Observabilty team will setup your queries so that you only need to add the cluster name-- see example
|
|
576
|
+
|
|
569
577
|
| Function | Type |
|
|
570
578
|
| ---------- | ---------- |
|
|
571
579
|
| `useFleetPrometheusPoll` | `(props: PrometheusPollProps and { cluster?: string or undefined; } and { allClusters?: boolean or undefined; }) => [response: PrometheusResponse or undefined, loaded: boolean, error: unknown]` |
|
|
572
580
|
|
|
573
|
-
|
|
581
|
+
Parameters:
|
|
582
|
+
|
|
583
|
+
* `endpoint`: - one of the PrometheusEndpoint (label, query, range, rules, targets)
|
|
584
|
+
* `cluster`: - The target cluster name. If not specified or matches hub cluster, queries local Prometheus
|
|
585
|
+
* `allClusters`: - If true, queries across all clusters in the fleet (requires observability)
|
|
586
|
+
* `query`: - (optional) Prometheus query string. If empty or undefined, polling is not started. (See note above on format)
|
|
587
|
+
* `delay`: - (optional) polling delay interval (ms)
|
|
588
|
+
* `endTime`: - (optional) for QUERY_RANGE enpoint, end of the query range
|
|
589
|
+
* `samples`: - (optional) for QUERY_RANGE enpoint
|
|
590
|
+
* `timespan`: - (optional) for QUERY_RANGE enpoint
|
|
591
|
+
* `namespace`: - (optional) a search param to append
|
|
592
|
+
* `timeout`: - (optional) a search param to append
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
Returns:
|
|
596
|
+
|
|
597
|
+
A tuple containing:
|
|
598
|
+
- `response`: PrometheusResponse object with query results, or undefined if loading/error
|
|
599
|
+
- `loaded`: Boolean indicating if the request has completed (successfully or with error)
|
|
600
|
+
- `error`: Any error that occurred during the request, including dependency check failures
|
|
601
|
+
|
|
602
|
+
Examples:
|
|
603
|
+
|
|
604
|
+
```typescript
|
|
605
|
+
// (OPTIONAL) Check if the Observability service has been installed
|
|
606
|
+
const [response, loaded, error] = useIsFleetObservabilityInstalled()
|
|
607
|
+
if (!loaded) {
|
|
608
|
+
return <Loading />
|
|
609
|
+
}
|
|
610
|
+
if (error) {
|
|
611
|
+
return <ErrorState error={error} />
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// Get the query
|
|
615
|
+
const [hubClusterName] = useHubClusterName();
|
|
616
|
+
const clusterFilter = cluster !== hubClusterName ? `,cluster='$cluster}'` : '';
|
|
617
|
+
const sumByCluster = !isEmpty(obj?.cluster) && obj?.cluster === hubClusterName ? ', cluster' : '';
|
|
618
|
+
// NOTE: this assumes your queries are identical between hub and other fleet clusters
|
|
619
|
+
// if not, you may need to use an entirely different query for fleet--consult the Observability team
|
|
620
|
+
const query = `sum(rate(kubevirt_vmi_cpu_usage_seconds_total{name='${name}',namespace='${namespace}'${clusterFilter}}[${duration}])) BY (name, namespace${sumByCluster})`,
|
|
621
|
+
|
|
622
|
+
// Query metrics data
|
|
623
|
+
const [response, loaded, error] = useFleetPrometheusPoll({
|
|
624
|
+
cluster: 'cluster',
|
|
625
|
+
query
|
|
626
|
+
});
|
|
627
|
+
if (!loaded) {
|
|
628
|
+
return <Loading />
|
|
629
|
+
}
|
|
630
|
+
if (error) {
|
|
631
|
+
return <ErrorState error={error} />
|
|
632
|
+
}
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetPrometheusPoll.ts#L86)
|
|
574
637
|
|
|
575
638
|
### :gear: useFleetSearchPoll
|
|
576
639
|
|
|
@@ -674,7 +737,7 @@ Returns:
|
|
|
674
737
|
|
|
675
738
|
### :gear: useIsFleetObservabilityInstalled
|
|
676
739
|
|
|
677
|
-
Hook that
|
|
740
|
+
Hook that determines if the Observability service has been installed on the hub
|
|
678
741
|
|
|
679
742
|
| Function | Type |
|
|
680
743
|
| ---------- | ---------- |
|
|
@@ -682,9 +745,32 @@ Hook that provides is observability installed.
|
|
|
682
745
|
|
|
683
746
|
Returns:
|
|
684
747
|
|
|
685
|
-
|
|
748
|
+
A tuple containing:
|
|
749
|
+
- `response`: Boolean indicating whether the Observability service has been installed
|
|
750
|
+
- `loaded`: Boolean indicating if the request has completed (successfully or with error)
|
|
751
|
+
- `error`: Any error that occurred during the request, including dependency check failures
|
|
752
|
+
|
|
753
|
+
Examples:
|
|
754
|
+
|
|
755
|
+
```typescript
|
|
756
|
+
// Check if the Observability service has been installed
|
|
757
|
+
const [response, loaded, error] = useIsFleetObservabilityInstalled()
|
|
758
|
+
if (!loaded) {
|
|
759
|
+
return <Loading />
|
|
760
|
+
}
|
|
761
|
+
if (error) {
|
|
762
|
+
return <ErrorState error={error} />
|
|
763
|
+
}
|
|
764
|
+
if (!loaded) {
|
|
765
|
+
return <Loading />
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
if (error) {
|
|
769
|
+
return <ErrorState error={error} />
|
|
770
|
+
}
|
|
771
|
+
|
|
686
772
|
|
|
687
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useIsFleetObservabilityInstalled.ts#
|
|
773
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useIsFleetObservabilityInstalled.ts#L37)
|
|
688
774
|
|
|
689
775
|
|
|
690
776
|
## :wrench: Constants
|
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
import { PrometheusPollProps, PrometheusResponse } from '@openshift-console/dynamic-plugin-sdk';
|
|
2
2
|
import { Fleet } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* A fleet version of [`usePrometheusPoll`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#useprometheuspoll) from
|
|
5
|
+
* the [dynamic plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk) that polls Prometheus for metrics data from a specific cluster or across all clusters.
|
|
6
|
+
*
|
|
7
|
+
* Although this is intended as a drop-in replacement for usePrometheusPoll there are a couple of considerations:
|
|
8
|
+
* 1. The Observabilty service must be running on the hub in order to access metric data outside of the hub. The useIsFleetObservabilityInstalled() hook can check this
|
|
9
|
+
* 2. The PromQL query will be different for clusters outside of the hub. The query may be completely different but at the very least it will contain the cluster name(s)
|
|
10
|
+
* 3. Ideally the Observabilty team will setup your queries so that you only need to add the cluster name-- see example
|
|
11
|
+
*
|
|
12
|
+
* @param {PrometheusEndpoint} endpoint - one of the PrometheusEndpoint (label, query, range, rules, targets)
|
|
13
|
+
* @param {string} [cluster] - The target cluster name. If not specified or matches hub cluster, queries local Prometheus
|
|
14
|
+
* @param {boolean} [allClusters] - If true, queries across all clusters in the fleet (requires observability)
|
|
15
|
+
* @param {string} [query] - (optional) Prometheus query string. If empty or undefined, polling is not started. (See note above on format)
|
|
16
|
+
* @param {number} [delay] - (optional) polling delay interval (ms)
|
|
17
|
+
* @param {number} [endTime] - (optional) for QUERY_RANGE enpoint, end of the query range
|
|
18
|
+
* @param {number} [samples] - (optional) for QUERY_RANGE enpoint
|
|
19
|
+
* @param {number} [timespan] - (optional) for QUERY_RANGE enpoint
|
|
20
|
+
* @param {string} [namespace] - (optional) a search param to append
|
|
21
|
+
* @param {string} [timeout] - (optional) a search param to append
|
|
22
|
+
*
|
|
23
|
+
* @returns A tuple containing:
|
|
24
|
+
* - `response`: PrometheusResponse object with query results, or undefined if loading/error
|
|
25
|
+
* - `loaded`: Boolean indicating if the request has completed (successfully or with error)
|
|
26
|
+
* - `error`: Any error that occurred during the request, including dependency check failures
|
|
27
|
+
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // (OPTIONAL) Check if the Observability service has been installed
|
|
31
|
+
* const [response, loaded, error] = useIsFleetObservabilityInstalled()
|
|
32
|
+
* if (!loaded) {
|
|
33
|
+
* return <Loading />
|
|
34
|
+
* }
|
|
35
|
+
* if (error) {
|
|
36
|
+
* return <ErrorState error={error} />
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* // Get the query
|
|
40
|
+
* const [hubClusterName] = useHubClusterName();
|
|
41
|
+
* const clusterFilter = cluster !== hubClusterName ? `,cluster='$cluster}'` : '';
|
|
42
|
+
* const sumByCluster = !isEmpty(obj?.cluster) && obj?.cluster === hubClusterName ? ', cluster' : '';
|
|
43
|
+
* // NOTE: this assumes your queries are identical between hub and other fleet clusters
|
|
44
|
+
* // if not, you may need to use an entirely different query for fleet--consult the Observability team
|
|
45
|
+
* const query = `sum(rate(kubevirt_vmi_cpu_usage_seconds_total{name='${name}',namespace='${namespace}'${clusterFilter}}[${duration}])) BY (name, namespace${sumByCluster})`,
|
|
46
|
+
*
|
|
47
|
+
* // Query metrics data
|
|
48
|
+
* const [response, loaded, error] = useFleetPrometheusPoll({
|
|
49
|
+
* cluster: 'cluster',
|
|
50
|
+
* query
|
|
51
|
+
* });
|
|
52
|
+
* if (!loaded) {
|
|
53
|
+
* return <Loading />
|
|
54
|
+
* }
|
|
55
|
+
* if (error) {
|
|
56
|
+
* return <ErrorState error={error} />
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* This hook intelligently routes Prometheus queries based on the target cluster:
|
|
62
|
+
* - If no cluster is specified or the cluster matches the hub cluster, it uses the local Prometheus instance
|
|
63
|
+
* - If a specific managed cluster is specified, it uses the fleet observability service (requires multicluster observability to be installed)
|
|
64
|
+
* - If `allClusters` is true, it queries across all clusters in the fleet using the observability service
|
|
65
|
+
*
|
|
66
|
+
* The hook automatically handles:
|
|
67
|
+
* - Checking if multicluster observability is installed when needed using useIsFleetObservabilityInstalled() hook
|
|
68
|
+
* - Determining the hub cluster name for comparison
|
|
69
|
+
* - Routing queries to the appropriate Prometheus endpoint
|
|
70
|
+
* - Providing appropriate error states when dependencies are not available
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
3
73
|
export declare const useFleetPrometheusPoll: (props: Fleet<PrometheusPollProps> & {
|
|
4
74
|
allClusters?: boolean;
|
|
5
75
|
}) => [response: PrometheusResponse | undefined, loaded: boolean, error: unknown];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFleetPrometheusPoll.d.ts","sourceRoot":"","sources":["../../src/api/useFleetPrometheusPoll.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAqB,MAAM,uCAAuC,CAAA;AAUlH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAGhC,eAAO,MAAM,sBAAsB,EAAE,CACnC,KAAK,EAAE,KAAK,CAAC,mBAAmB,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,KAC1D,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAsE9E,CAAA"}
|
|
1
|
+
{"version":3,"file":"useFleetPrometheusPoll.d.ts","sourceRoot":"","sources":["../../src/api/useFleetPrometheusPoll.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAqB,MAAM,uCAAuC,CAAA;AAUlH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAGhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,eAAO,MAAM,sBAAsB,EAAE,CACnC,KAAK,EAAE,KAAK,CAAC,mBAAmB,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,KAC1D,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAsE9E,CAAA"}
|
|
@@ -8,6 +8,76 @@ const constants_1 = require("../internal/constants");
|
|
|
8
8
|
const utils_1 = require("../internal/utils");
|
|
9
9
|
const useHubClusterName_1 = require("./useHubClusterName");
|
|
10
10
|
const useIsFleetObservabilityInstalled_1 = require("./useIsFleetObservabilityInstalled");
|
|
11
|
+
/**
|
|
12
|
+
* A fleet version of [`usePrometheusPoll`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#useprometheuspoll) from
|
|
13
|
+
* the [dynamic plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk) that polls Prometheus for metrics data from a specific cluster or across all clusters.
|
|
14
|
+
*
|
|
15
|
+
* Although this is intended as a drop-in replacement for usePrometheusPoll there are a couple of considerations:
|
|
16
|
+
* 1. The Observabilty service must be running on the hub in order to access metric data outside of the hub. The useIsFleetObservabilityInstalled() hook can check this
|
|
17
|
+
* 2. The PromQL query will be different for clusters outside of the hub. The query may be completely different but at the very least it will contain the cluster name(s)
|
|
18
|
+
* 3. Ideally the Observabilty team will setup your queries so that you only need to add the cluster name-- see example
|
|
19
|
+
*
|
|
20
|
+
* @param {PrometheusEndpoint} endpoint - one of the PrometheusEndpoint (label, query, range, rules, targets)
|
|
21
|
+
* @param {string} [cluster] - The target cluster name. If not specified or matches hub cluster, queries local Prometheus
|
|
22
|
+
* @param {boolean} [allClusters] - If true, queries across all clusters in the fleet (requires observability)
|
|
23
|
+
* @param {string} [query] - (optional) Prometheus query string. If empty or undefined, polling is not started. (See note above on format)
|
|
24
|
+
* @param {number} [delay] - (optional) polling delay interval (ms)
|
|
25
|
+
* @param {number} [endTime] - (optional) for QUERY_RANGE enpoint, end of the query range
|
|
26
|
+
* @param {number} [samples] - (optional) for QUERY_RANGE enpoint
|
|
27
|
+
* @param {number} [timespan] - (optional) for QUERY_RANGE enpoint
|
|
28
|
+
* @param {string} [namespace] - (optional) a search param to append
|
|
29
|
+
* @param {string} [timeout] - (optional) a search param to append
|
|
30
|
+
*
|
|
31
|
+
* @returns A tuple containing:
|
|
32
|
+
* - `response`: PrometheusResponse object with query results, or undefined if loading/error
|
|
33
|
+
* - `loaded`: Boolean indicating if the request has completed (successfully or with error)
|
|
34
|
+
* - `error`: Any error that occurred during the request, including dependency check failures
|
|
35
|
+
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // (OPTIONAL) Check if the Observability service has been installed
|
|
39
|
+
* const [response, loaded, error] = useIsFleetObservabilityInstalled()
|
|
40
|
+
* if (!loaded) {
|
|
41
|
+
* return <Loading />
|
|
42
|
+
* }
|
|
43
|
+
* if (error) {
|
|
44
|
+
* return <ErrorState error={error} />
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* // Get the query
|
|
48
|
+
* const [hubClusterName] = useHubClusterName();
|
|
49
|
+
* const clusterFilter = cluster !== hubClusterName ? `,cluster='$cluster}'` : '';
|
|
50
|
+
* const sumByCluster = !isEmpty(obj?.cluster) && obj?.cluster === hubClusterName ? ', cluster' : '';
|
|
51
|
+
* // NOTE: this assumes your queries are identical between hub and other fleet clusters
|
|
52
|
+
* // if not, you may need to use an entirely different query for fleet--consult the Observability team
|
|
53
|
+
* const query = `sum(rate(kubevirt_vmi_cpu_usage_seconds_total{name='${name}',namespace='${namespace}'${clusterFilter}}[${duration}])) BY (name, namespace${sumByCluster})`,
|
|
54
|
+
*
|
|
55
|
+
* // Query metrics data
|
|
56
|
+
* const [response, loaded, error] = useFleetPrometheusPoll({
|
|
57
|
+
* cluster: 'cluster',
|
|
58
|
+
* query
|
|
59
|
+
* });
|
|
60
|
+
* if (!loaded) {
|
|
61
|
+
* return <Loading />
|
|
62
|
+
* }
|
|
63
|
+
* if (error) {
|
|
64
|
+
* return <ErrorState error={error} />
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* This hook intelligently routes Prometheus queries based on the target cluster:
|
|
70
|
+
* - If no cluster is specified or the cluster matches the hub cluster, it uses the local Prometheus instance
|
|
71
|
+
* - If a specific managed cluster is specified, it uses the fleet observability service (requires multicluster observability to be installed)
|
|
72
|
+
* - If `allClusters` is true, it queries across all clusters in the fleet using the observability service
|
|
73
|
+
*
|
|
74
|
+
* The hook automatically handles:
|
|
75
|
+
* - Checking if multicluster observability is installed when needed using useIsFleetObservabilityInstalled() hook
|
|
76
|
+
* - Determining the hub cluster name for comparison
|
|
77
|
+
* - Routing queries to the appropriate Prometheus endpoint
|
|
78
|
+
* - Providing appropriate error states when dependencies are not available
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
11
81
|
const useFleetPrometheusPoll = ({ delay, endpoint, endTime, namespace, query, samples = constants_1.DEFAULT_PROMETHEUS_SAMPLES, timeout, timespan = constants_1.DEFAULT_PROMETHEUS_TIMESPAN, customDataSource, cluster, allClusters, }) => {
|
|
12
82
|
const [isObservabilityInstalled, isObservabilityInstalledLoaded, isObservabilityInstalledError] = (0, useIsFleetObservabilityInstalled_1.useIsFleetObservabilityInstalled)();
|
|
13
83
|
const [hubClusterName, hubClusterNameLoaded, hubClusterNameLoadedError] = (0, useHubClusterName_1.useHubClusterName)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFleetPrometheusPoll.js","sourceRoot":"","sources":["../../src/api/useFleetPrometheusPoll.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,8EAAkH;AAClH,uDAAsE;AACtE,qDAK8B;AAC9B,6CAAyD;AACzD,2DAAuD;AAEvD,yFAAqF;
|
|
1
|
+
{"version":3,"file":"useFleetPrometheusPoll.js","sourceRoot":"","sources":["../../src/api/useFleetPrometheusPoll.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,8EAAkH;AAClH,uDAAsE;AACtE,qDAK8B;AAC9B,6CAAyD;AACzD,2DAAuD;AAEvD,yFAAqF;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEI,MAAM,sBAAsB,GAEgD,CAAC,EAClF,KAAK,EACL,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,OAAO,GAAG,sCAA0B,EACpC,OAAO,EACP,QAAQ,GAAG,uCAA2B,EACtC,gBAAgB,EAChB,OAAO,EACP,WAAW,GACZ,EAAE,EAAE;IACH,MAAM,CAAC,wBAAwB,EAAE,8BAA8B,EAAE,6BAA6B,CAAC,GAC7F,IAAA,mEAAgC,GAAE,CAAA;IACpC,MAAM,CAAC,cAAc,EAAE,oBAAoB,EAAE,yBAAyB,CAAC,GAAG,IAAA,qCAAiB,GAAE,CAAA;IAE7F,MAAM,wBAAwB,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,oBAAoB,CAAA;IACnF,MAAM,YAAY,GAAG,WAAW,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,cAAc,CAAC,CAAA;IAE3E,0EAA0E;IAC1E,iHAAiH;IACjH,MAAM,QAAQ,GAAG,YAAY,IAAI,wBAAwB,IAAI,CAAC,wBAAwB,CAAA;IACtF,MAAM,QAAQ,GAAG,CAAC,YAAY,IAAI,CAAC,wBAAwB,CAAA;IAE3D,MAAM,kBAAkB,GAAG;QACzB,QAAQ;QACR,OAAO;QACP,SAAS;QACT,KAAK;QACL,OAAO;QACP,OAAO;QACP,QAAQ;KACT,CAAA;IAED,MAAM,SAAS,GAAG,IAAA,uBAAe,EAC/B,QAAQ,CAAC,CAAC,CAAC,IAAA,6BAAqB,EAAC,kBAAkB,EAAE,GAAG,uBAAW,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,EAC3F,KAAK,EACL,KAAK,EACL,QAAQ,CACT,CAAA;IAED,MAAM,SAAS,GAAG,IAAA,sCAAiB,EAAC;QAClC,KAAK;QACL,QAAQ;QACR,OAAO;QACP,SAAS;QACT,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;QACnC,OAAO;QACP,OAAO;QACP,QAAQ;QACR,gBAAgB;KACjB,CAAC,CAAA;IAEF,IAAI,wBAAwB,EAAE,CAAC;QAC7B,gDAAgD;QAChD,4FAA4F;QAC5F,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAA;IACtD,CAAC;SAAM,IAAI,YAAY,IAAI,CAAC,8BAA8B,EAAE,CAAC;QAC3D,yFAAyF;QACzF,uGAAuG;QACvG,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,6BAA6B,CAAC,CAAA;IAC1D,CAAC;SAAM,IAAI,YAAY,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACrD,wEAAwE;QACxE,qBAAqB;QACrB,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,oDAAwC,CAAC,CAAA;IACrE,CAAC;SAAM,CAAC;QACN,uFAAuF;QACvF,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;IACzC,CAAC;AACH,CAAC,CAAA;AAxEY,QAAA,sBAAsB,0BAwElC"}
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hook that
|
|
2
|
+
* Hook that determines if the Observability service has been installed on the hub
|
|
3
|
+
*
|
|
4
|
+
* @returns A tuple containing:
|
|
5
|
+
* - `response`: Boolean indicating whether the Observability service has been installed
|
|
6
|
+
* - `loaded`: Boolean indicating if the request has completed (successfully or with error)
|
|
7
|
+
* - `error`: Any error that occurred during the request, including dependency check failures
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Check if the Observability service has been installed
|
|
12
|
+
* const [response, loaded, error] = useIsFleetObservabilityInstalled()
|
|
13
|
+
* if (!loaded) {
|
|
14
|
+
* return <Loading />
|
|
15
|
+
* }
|
|
16
|
+
* if (error) {
|
|
17
|
+
* return <ErrorState error={error} />
|
|
18
|
+
* }
|
|
19
|
+
* if (!loaded) {
|
|
20
|
+
* return <Loading />
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* if (error) {
|
|
24
|
+
* return <ErrorState error={error} />
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* This hook
|
|
29
|
+
* - is used by the useFleetPrometheusPoll() hook to determine if metrics can be retrieved from clusters outside of the hub cluster.
|
|
30
|
+
* - see RHACM documentation for how to enable observability
|
|
31
|
+
* https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/2.14/html/observability/observing-environments-intro#enabling-observability-service
|
|
3
32
|
*
|
|
4
|
-
* @returns Array with `isObservabilityInstalled`, `loaded` and `error` values.
|
|
5
33
|
*/
|
|
6
34
|
export declare function useIsFleetObservabilityInstalled(): [
|
|
7
35
|
isObservabilityInstalled: boolean | undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFleetObservabilityInstalled.d.ts","sourceRoot":"","sources":["../../src/api/useIsFleetObservabilityInstalled.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"useIsFleetObservabilityInstalled.d.ts","sourceRoot":"","sources":["../../src/api/useIsFleetObservabilityInstalled.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gCAAgC,IAAI;IAClD,wBAAwB,EAAE,OAAO,GAAG,SAAS;IAC7C,MAAM,EAAE,OAAO;IACf,KAAK,EAAE,OAAO;CACf,CAEA"}
|
|
@@ -4,9 +4,37 @@ exports.useIsFleetObservabilityInstalled = useIsFleetObservabilityInstalled;
|
|
|
4
4
|
/* Copyright Contributors to the Open Cluster Management project */
|
|
5
5
|
const useHubConfigurationItem_1 = require("../internal/useHubConfigurationItem");
|
|
6
6
|
/**
|
|
7
|
-
* Hook that
|
|
7
|
+
* Hook that determines if the Observability service has been installed on the hub
|
|
8
|
+
*
|
|
9
|
+
* @returns A tuple containing:
|
|
10
|
+
* - `response`: Boolean indicating whether the Observability service has been installed
|
|
11
|
+
* - `loaded`: Boolean indicating if the request has completed (successfully or with error)
|
|
12
|
+
* - `error`: Any error that occurred during the request, including dependency check failures
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Check if the Observability service has been installed
|
|
17
|
+
* const [response, loaded, error] = useIsFleetObservabilityInstalled()
|
|
18
|
+
* if (!loaded) {
|
|
19
|
+
* return <Loading />
|
|
20
|
+
* }
|
|
21
|
+
* if (error) {
|
|
22
|
+
* return <ErrorState error={error} />
|
|
23
|
+
* }
|
|
24
|
+
* if (!loaded) {
|
|
25
|
+
* return <Loading />
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* if (error) {
|
|
29
|
+
* return <ErrorState error={error} />
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* This hook
|
|
34
|
+
* - is used by the useFleetPrometheusPoll() hook to determine if metrics can be retrieved from clusters outside of the hub cluster.
|
|
35
|
+
* - see RHACM documentation for how to enable observability
|
|
36
|
+
* https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/2.14/html/observability/observing-environments-intro#enabling-observability-service
|
|
8
37
|
*
|
|
9
|
-
* @returns Array with `isObservabilityInstalled`, `loaded` and `error` values.
|
|
10
38
|
*/
|
|
11
39
|
function useIsFleetObservabilityInstalled() {
|
|
12
40
|
return (0, useHubConfigurationItem_1.useHubConfigurationItem)('isObservabilityInstalled');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFleetObservabilityInstalled.js","sourceRoot":"","sources":["../../src/api/useIsFleetObservabilityInstalled.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"useIsFleetObservabilityInstalled.js","sourceRoot":"","sources":["../../src/api/useIsFleetObservabilityInstalled.ts"],"names":[],"mappings":";;AAoCA,4EAMC;AA1CD,mEAAmE;AACnE,iFAA6E;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,gCAAgC;IAK9C,OAAO,IAAA,iDAAuB,EAAC,0BAA0B,CAAC,CAAA;AAC5D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stolostron/multicluster-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|