Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve bias metrics from thanos querier (#1472) (#1473) #1478

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions backend/src/routes/api/prometheus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
OauthFastifyRequest,
PrometheusQueryRangeResponse,
PrometheusQueryResponse,
QueryType,
} from '../../../types';
import { callPrometheusPVC, callPrometheusServing } from '../../../utils/prometheusUtils';
import { callPrometheusThanos, callPrometheusServing } from '../../../utils/prometheusUtils';
import { createCustomError } from '../../../utils/requestUtils';
import { logRequestDetails } from '../../../utils/fileUtils';

Expand Down Expand Up @@ -35,7 +36,22 @@ module.exports = async (fastify: KubeFastifyInstance) => {
): Promise<{ code: number; response: PrometheusQueryResponse }> => {
const { query } = request.body;

return callPrometheusPVC(fastify, request, query).catch(handleError);
return callPrometheusThanos(fastify, request, query).catch(handleError);
},
);

fastify.post(
'/bias',
async (
request: OauthFastifyRequest<{
Body: { query: string };
}>,
): Promise<{ code: number; response: PrometheusQueryResponse }> => {
const { query } = request.body;

return callPrometheusThanos(fastify, request, query, QueryType.QUERY_RANGE).catch(
handleError,
);
},
);

Expand Down
5 changes: 3 additions & 2 deletions backend/src/utils/prometheusUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,18 @@ const generatePrometheusHostURL = (
return `https://${instanceName}.${namespace}.svc.cluster.local:${port}`;
};

export const callPrometheusPVC = (
export const callPrometheusThanos = (
fastify: KubeFastifyInstance,
request: OauthFastifyRequest,
query: string,
queryType: QueryType = QueryType.QUERY,
): Promise<{ code: number; response: PrometheusQueryResponse }> =>
callPrometheus(
fastify,
request,
query,
generatePrometheusHostURL(fastify, 'thanos-querier', 'openshift-monitoring', '9092'),
QueryType.QUERY,
queryType,
);

export const callPrometheusServing = (
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/api/prometheus/serving.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const useModelServingMetrics = (
end,
timeframe,
trustyResponsePredicate,
'/api/prometheus/bias',
);

const modelTrustyAIDIR = useQueryRangeResourceData(
Expand All @@ -109,6 +110,7 @@ export const useModelServingMetrics = (
end,
timeframe,
trustyResponsePredicate,
'/api/prometheus/bias',
);

React.useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/api/prometheus/useQueryRangeResourceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ const useQueryRangeResourceData = <T = PrometheusQueryRangeResultValue>(
end: number,
timeframe: TimeframeTitle,
responsePredicate: ResponsePredicate<T>,
apiPath = '/api/prometheus/serving',
): ContextResourceData<T> =>
useRestructureContextResourceData<T>(
usePrometheusQueryRange<T>(
active,
'/api/prometheus/serving',
apiPath,
query,
TimeframeTimeRange[timeframe],
end,
Expand Down
Loading