mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Prometheus: Display HELP and TYPE of metrics if available - Prometheus recently added a metadata API around HELP and TYPE of metrics - request metadata when datasource instance is created - use metadata to show help and type in typeahead suggestions and in metrics selector as tooltip * Fix types
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { groupMetricsByPrefix, RECORDING_RULES_GROUP } from './PromQueryField';
|
|
|
|
describe('groupMetricsByPrefix()', () => {
|
|
it('returns an empty group for no metrics', () => {
|
|
expect(groupMetricsByPrefix([])).toEqual([]);
|
|
});
|
|
|
|
it('returns options grouped by prefix', () => {
|
|
expect(groupMetricsByPrefix(['foo_metric'])).toMatchObject([
|
|
{
|
|
value: 'foo',
|
|
children: [
|
|
{
|
|
value: 'foo_metric',
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('returns options grouped by prefix with metadata', () => {
|
|
expect(groupMetricsByPrefix(['foo_metric'], { foo_metric: [{ type: 'TYPE', help: 'my help' }] })).toMatchObject([
|
|
{
|
|
value: 'foo',
|
|
children: [
|
|
{
|
|
value: 'foo_metric',
|
|
title: 'foo_metric\nTYPE\nmy help',
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('returns options without prefix as toplevel option', () => {
|
|
expect(groupMetricsByPrefix(['metric'])).toMatchObject([
|
|
{
|
|
value: 'metric',
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('returns recording rules grouped separately', () => {
|
|
expect(groupMetricsByPrefix([':foo_metric:'])).toMatchObject([
|
|
{
|
|
value: RECORDING_RULES_GROUP,
|
|
children: [
|
|
{
|
|
value: ':foo_metric:',
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
});
|
|
});
|