-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metrics Explorer updated with PromQL (#1303)
* 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
1 parent
3c57327
commit 958186a
Showing
10 changed files
with
2,366 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {}; | ||
}; |
Oops, something went wrong.