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

Add otel metrics #1314

Merged
merged 21 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
change to get request
Signed-off-by: Kavitha Conjeevaram Mohan <mohakavi@amazon.com>
kavithacm committed Jan 11, 2024
commit f22bbbbb6216ea4ee030cb83dcfac3bacada71c3
5 changes: 2 additions & 3 deletions common/types/metrics.ts
Original file line number Diff line number Diff line change
@@ -4,8 +4,7 @@
*/

import { VisualizationType } from './custom_panels';
import { OTEL_METRIC_SUBTYPE } from '../constants/shared';
type AllMetricTypes = 'savedCustomMetric' | 'prometheusMetric' | typeof OTEL_METRIC_SUBTYPE;
type MetricTypes = 'savedCustomMetric' | 'prometheusMetric' | 'openTelemetryMetric';

export interface MetricType extends VisualizationType {
id: string;
@@ -15,7 +14,7 @@ export interface MetricType extends VisualizationType {
w: number;
h: number;
query: {
type: AllMetricTypes;
type: MetricTypes;
aggregation: string;
attributesGroupBy: string[];
catalog: string;
Original file line number Diff line number Diff line change
@@ -29,8 +29,6 @@ import {
} from '../utils';
import { convertDateTime } from '../../../common/query_utils';

jest.setTimeout(60000);

describe('Utils helper functions', () => {
configure({ adapter: new Adapter() });

9 changes: 3 additions & 6 deletions public/components/custom_panels/helpers/utils.tsx
Original file line number Diff line number Diff line change
@@ -455,12 +455,9 @@ export const fetchAggregatedBinCount = async (
export const fetchSampleOTDocument = async (selectedOtelIndex: string, documentName: string) => {
const http = getOSDHttp();
try {
const response = await http.post(`${OBSERVABILITY_BASE}/metrics/otel/histogramSampleDocument`, {
body: JSON.stringify({
documentName,
index: selectedOtelIndex,
}),
});
const response = await http.get(
`${OBSERVABILITY_BASE}/metrics/otel/${selectedOtelIndex}/${documentName}`
);
return response;
} catch (error) {
console.error(error);
6 changes: 1 addition & 5 deletions public/components/metrics/redux/slices/metrics_slice.ts
Original file line number Diff line number Diff line change
@@ -186,11 +186,7 @@ export const fetchOpenTelemetryIndices = async () => {
export const fetchOpenTelemetryDocumentNames = (selectedOtelIndex: string) => async () => {
const http = getOSDHttp();
return http
.post(`${OBSERVABILITY_BASE}/metrics/otel/documentNames`, {
body: JSON.stringify({
index: selectedOtelIndex,
}),
})
.get(`${OBSERVABILITY_BASE}/metrics/otel/${selectedOtelIndex}/documentNames`)
.catch((error) => console.error(error));
};

20 changes: 10 additions & 10 deletions server/routes/metrics/metrics_rounter.ts
Original file line number Diff line number Diff line change
@@ -99,11 +99,11 @@ export function registerMetricsRoute(router: IRouter) {
}
);

router.post(
router.get(
{
path: `${OBSERVABILITY_BASE}/metrics/otel/documentNames`,
path: `${OBSERVABILITY_BASE}/metrics/otel/{index}/documentNames`,
validate: {
body: schema.object({
params: schema.object({
index: schema.string(),
}),
},
@@ -120,7 +120,7 @@ export function registerMetricsRoute(router: IRouter) {
try {
const resp = await metricsAnalyticsBackend.queryToFetchDocumentNames(
opensearchNotebooksClient,
request.body.index
request.params.index
);
return response.ok({
body: resp,
@@ -135,12 +135,12 @@ export function registerMetricsRoute(router: IRouter) {
}
);

router.post(
router.get(
{
path: `${OBSERVABILITY_BASE}/metrics/otel/histogramSampleDocument`,
path: `${OBSERVABILITY_BASE}/metrics/otel/{index}/{histogramSampleDocument}`,
validate: {
body: schema.object({
documentName: schema.string(),
params: schema.object({
histogramSampleDocument: schema.string(),
index: schema.string(),
}),
},
@@ -157,8 +157,8 @@ export function registerMetricsRoute(router: IRouter) {
try {
const resp = await metricsAnalyticsBackend.queryToFetchSampleDocument(
opensearchNotebooksClient,
request.body.documentName,
request.body.index
request.params.histogramSampleDocument,
request.params.index
);
return response.ok({
body: resp.hits,
Loading