Skip to content

Commit

Permalink
Metrics Explorer updated with PromQL (#1303)
Browse files Browse the repository at this point in the history
* Metrics Explorer updated with PromQL

including query for Prometheus Metrics and updated Export Panel

---------

Signed-off-by: Peter Fitzgibbons <peter.fitzgibbons@gmail.com>
(cherry picked from commit d16f2b2)
Signed-off-by: Peter Fitzgibbons <peter.fitzgibbons@gmail.com>
  • Loading branch information
pjfitzgibbons committed Dec 18, 2023
1 parent 3c57327 commit 958186a
Show file tree
Hide file tree
Showing 10 changed files with 2,366 additions and 0 deletions.
24 changes: 24 additions & 0 deletions common/utils/__tests__/visualization_helpers.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { getUserConfigFrom } from '../visualization_helpers';

describe('Utils helper functions', () => {
describe('getUserConfigFrom', () => {
it('should return empty object from empty input', () => {
expect(getUserConfigFrom(undefined)).toEqual({});
expect(getUserConfigFrom('')).toEqual({});
expect(getUserConfigFrom({})).toEqual({});
});
it('should get object from user_configs json', () => {
const container = { user_configs: '{ "key": "value" }' };
expect(getUserConfigFrom(container)).toEqual({ key: 'value' });
});
it('should get object from userConfigs', () => {
const container = { userConfigs: '{ "key": "value" }' };
expect(getUserConfigFrom(container)).toEqual({ key: 'value' });
});
});
});
19 changes: 19 additions & 0 deletions common/utils/visualization_helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { isEmpty, isString } from 'lodash';

/* The file contains helper functions for visualizaitons operations
* getUserConfigFrom - returns input objects' user_configs or userConfigs, JSON parsed if necessary
*/

export const getUserConfigFrom = (container: unknown): object => {
const config = container?.user_configs || container?.userConfigs || {};

if (isEmpty(config)) return {};

if (isString(config)) return JSON.parse(config);
else return {};
};
Loading

0 comments on commit 958186a

Please sign in to comment.