Setting per cluster for mountpoints in the filesystem metrics

Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
This commit is contained in:
Piotr Roszatycki committed 2023-10-21 23:21:00 +02:00
1 parent f1a960fd78
commit 4ff49bdbd7
7 files changed
+45 -18

No files matched your search

@@ -125,6 +125,7 @@ export interface ClusterPrometheusPreferences {
prometheusProvider?: {
type: string;
};
filesystemMountpoints?: string;
}
/**
@@ -69,6 +69,7 @@ const addMetricsRouteInjectable = getRouteInjectable({
const queryParams: Partial<Record<string, string>> = Object.fromEntries(query.entries());
const prometheusMetadata: ClusterPrometheusMetadata = {};
const prometheusHandler = di.inject(prometheusHandlerInjectable, cluster);
const mountpoints = cluster.preferences.filesystemMountpoints || "/";
try {
const { prometheusPath, provider } = await prometheusHandler.getPrometheusDetails();
@@ -99,7 +100,7 @@ const addMetricsRouteInjectable = getRouteInjectable({
const data = payload as Record<string, Record<string, string>>;
const queries = object.entries(data)
.map(([queryName, queryOpts]) => (
provider.getQuery(queryOpts, queryName)
provider.getQuery({ ...queryOpts, mountpoints }, queryName)
));
const result = await loadMetrics(queries, cluster, prometheusPath, queryParams);
@@ -32,6 +32,7 @@ interface Dependencies {
@observer
class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometheusSettingProps & Dependencies> {
@observable mountpoints = "";
@observable path = "";
@observable selectedOption: ProviderValue = autoDetectPrometheus;
@observable loading = true;
@@ -68,7 +69,7 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
componentDidMount() {
disposeOnUnmount(this,
autorun(() => {
const { prometheus, prometheusProvider } = this.props.cluster.preferences;
const { prometheus, prometheusProvider, filesystemMountpoints } = this.props.cluster.preferences;
if (prometheus) {
const prefix = prometheus.prefix || "";
@@ -83,6 +84,10 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
} else {
this.selectedOption = autoDetectPrometheus;
}
if (filesystemMountpoints) {
this.mountpoints = filesystemMountpoints;
}
}),
);
@@ -122,6 +127,10 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
this.props.cluster.preferences.prometheus = this.parsePrometheusPath();
};
onSaveMountpoints = () => {
this.props.cluster.preferences.filesystemMountpoints = this.mountpoints;
};
render() {
return (
<>
@@ -165,6 +174,22 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
</section>
</>
)}
<>
<hr />
<section>
<SubTitle title="Filesystem mountpoints" />
<Input
theme="round-black"
value={this.mountpoints}
onChange={(value) => this.mountpoints = value}
onBlur={this.onSaveMountpoints}
placeholder="/"
/>
<small className="hint">
{`A regexp for the label with the filesystem mountpoints that will create a graph for disk usage. For the root disk only use "/" and for all disks use ".*".`}
</small>
</section>
</>
</>
);
}