Merge pull request #9941 from rlankfo/agent-status-page-alertmanagers

disable fetching alertmanagers on status page in agent mode
This commit is contained in:
Julius Volz 2021-12-05 10:42:44 +01:00 committed by GitHub
commit 979db4fe44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 17 deletions

View file

@ -103,7 +103,7 @@ const App: FC<AppProps> = ({ consolesLink, agentMode }) => {
<ServiceDiscoveryPage /> <ServiceDiscoveryPage />
</Route> </Route>
<Route path="/status"> <Route path="/status">
<StatusPage /> <StatusPage agentMode={agentMode} />
</Route> </Route>
<Route path="/tsdb-status"> <Route path="/tsdb-status">
<TSDBStatusPage /> <TSDBStatusPage />

View file

@ -83,28 +83,35 @@ const StatusWithStatusIndicator = withStatusIndicator(StatusContent);
StatusContent.displayName = 'Status'; StatusContent.displayName = 'Status';
const Status: FC = () => { const StatusResult: FC<{ fetchPath: string; title: string }> = ({ fetchPath, title }) => {
const { response, isLoading, error } = useFetch(fetchPath);
return (
<StatusWithStatusIndicator
key={title}
data={response.data}
title={title}
isLoading={isLoading}
error={error}
componentTitle={title}
/>
);
};
const Status: FC<{ agentMode: boolean }> = ({ agentMode }) => {
const pathPrefix = usePathPrefix(); const pathPrefix = usePathPrefix();
const path = `${pathPrefix}/${API_PATH}`; const path = `${pathPrefix}/${API_PATH}`;
return ( return (
<> <>
{[ {[
{ fetchResult: useFetch<Record<string, string>>(`${path}/status/runtimeinfo`), title: 'Runtime Information' }, { fetchPath: `${path}/status/runtimeinfo`, title: 'Runtime Information' },
{ fetchResult: useFetch<Record<string, string>>(`${path}/status/buildinfo`), title: 'Build Information' }, { fetchPath: `${path}/status/buildinfo`, title: 'Build Information' },
{ fetchResult: useFetch<Record<string, string>>(`${path}/alertmanagers`), title: 'Alertmanagers' }, { fetchPath: `${path}/alertmanagers`, title: 'Alertmanagers' },
].map(({ fetchResult, title }) => { ].map(({ fetchPath, title }) => {
const { response, isLoading, error } = fetchResult; if (agentMode && title === 'Alertmanagers') {
return ( return null;
<StatusWithStatusIndicator }
key={title} return <StatusResult fetchPath={fetchPath} title={title} />;
data={response.data}
title={title}
isLoading={isLoading}
error={error}
componentTitle={title}
/>
);
})} })}
</> </>
); );